Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 171 lines (135 sloc) 5.195 kb
05eedb5 @itod initial add
authored
1 // Copyright 2010 Todd Ditchendorf
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #import "TDSignificantWhitespaceStateTest.h"
16
17
18 @implementation TDSignificantWhitespaceStateTest
19
20 - (void)setUp {
21 whitespaceState = [[TDSignificantWhitespaceState alloc] init];
22 }
23
24
25 - (void)tearDown {
26 [whitespaceState release];
27 [r release];
28 }
29
30
31 - (void)testSpace {
32 s = @" ";
33 r = [[PKReader alloc] initWithString:s];
34 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
35 STAssertNotNil(t, @"");
36 STAssertEqualObjects(s, t.stringValue, @"");
37 STAssertEquals(PKEOF, [r read], @"");
38 }
39
40
41 - (void)testTwoSpaces {
42 s = @" ";
43 r = [[PKReader alloc] initWithString:s];
44 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
45 STAssertNotNil(t, @"");
46 STAssertEqualObjects(s, t.stringValue, @"");
47 STAssertEquals(PKEOF, [r read], @"");
48 }
49
50
51 - (void)testEmptyString {
52 s = @"";
53 r = [[PKReader alloc] initWithString:s];
54 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
55 STAssertNotNil(t, @"");
56 STAssertEqualObjects(s, t.stringValue, @"");
57 STAssertEquals(PKEOF, [r read], @"");
58 }
59
60
61 - (void)testTab {
62 s = @"\t";
63 r = [[PKReader alloc] initWithString:s];
64 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
65 STAssertNotNil(t, @"");
66 STAssertEqualObjects(s, t.stringValue, @"");
67 STAssertEquals(PKEOF, [r read], @"");
68 }
69
70
71 - (void)testNewLine {
72 s = @"\n";
73 r = [[PKReader alloc] initWithString:s];
74 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
75 STAssertNotNil(t, @"");
76 STAssertEqualObjects(s, t.stringValue, @"");
77 STAssertEquals(PKEOF, [r read], @"");
78 }
79
80
81 - (void)testCarriageReturn {
82 s = @"\r";
83 r = [[PKReader alloc] initWithString:s];
84 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
85 STAssertNotNil(t, @"");
86 STAssertEqualObjects(s, t.stringValue, @"");
87 STAssertEquals(PKEOF, [r read], @"");
88 }
89
90
91 - (void)testSpaceCarriageReturn {
92 s = @" \r";
93 r = [[PKReader alloc] initWithString:s];
94 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
95 STAssertNotNil(t, @"");
96 STAssertEqualObjects(s, t.stringValue, @"");
97 STAssertEquals(PKEOF, [r read], @"");
98 }
99
100
101 - (void)testSpaceTabNewLineSpace {
102 s = @" \t\n ";
103 r = [[PKReader alloc] initWithString:s];
104 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
105 STAssertNotNil(t, @"");
106 STAssertEqualObjects(s, t.stringValue, @"");
107 STAssertEquals(PKEOF, [r read], @"");
108 }
109
110
111 - (void)testSpaceA {
112 s = @" a";
113 r = [[PKReader alloc] initWithString:s];
114 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
115 STAssertNotNil(t, @"");
116 STAssertEqualObjects(@" ", t.stringValue, @"");
117 STAssertEquals((PKUniChar)'a', [r read], @"");
118 }
119
120 - (void)testSpaceASpace {
121 s = @" a ";
122 r = [[PKReader alloc] initWithString:s];
123 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
124 STAssertNotNil(t, @"");
125 STAssertEqualObjects(@" ", t.stringValue, @"");
126 STAssertEquals((PKUniChar)'a', [r read], @"");
127 }
128
129
130 - (void)testTabA {
131 s = @"\ta";
132 r = [[PKReader alloc] initWithString:s];
133 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
134 STAssertNotNil(t, @"");
135 STAssertEqualObjects(@"\t", t.stringValue, @"");
136 STAssertEquals((PKUniChar)'a', [r read], @"");
137 }
138
139
140 - (void)testNewLineA {
141 s = @"\na";
142 r = [[PKReader alloc] initWithString:s];
143 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
144 STAssertNotNil(t, @"");
145 STAssertEqualObjects(@"\n", t.stringValue, @"");
146 STAssertEquals((PKUniChar)'a', [r read], @"");
147 }
148
149
150 - (void)testCarriageReturnA {
151 s = @"\ra";
152 r = [[PKReader alloc] initWithString:s];
153 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
154 STAssertNotNil(t, @"");
155 STAssertEqualObjects(@"\r", t.stringValue, @"");
156 STAssertEquals((PKUniChar)'a', [r read], @"");
157 }
158
159
160 - (void)testNewLineSpaceCarriageReturnA {
161 s = @"\n \ra";
162 r = [[PKReader alloc] initWithString:s];
163 PKToken *t = [whitespaceState nextTokenFromReader:r startingWith:[r read] tokenizer:nil];
164 STAssertNotNil(t, @"");
165 STAssertEqualObjects(@"\n \r", t.stringValue, @"");
166 STAssertEquals((PKUniChar)'a', [r read], @"");
167 }
168
169
170 @end
Something went wrong with that request. Please try again.