Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 66 lines (50 sloc) 1.656 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 "TDDigitTest.h"
16
17 @interface PKAssembly ()
18 - (BOOL)hasMore;
19 @end
20
21 @implementation TDDigitTest
22
23 - (void)test123 {
24 s = @"123";
25 a = [PKCharacterAssembly assemblyWithString:s];
26
27 TDEqualObjects(@"[]^123", [a description]);
28 p = [PKDigit digit];
29
30 result = [p bestMatchFor:a];
31 TDNotNil(a);
32 TDEqualObjects(@"[1]1^23", [result description]);
33 TDTrue([a hasMore]);
34 }
35
36
37 - (void)testAbc {
38 s = @"abc";
39 a = [PKCharacterAssembly assemblyWithString:s];
40
41 TDEqualObjects(@"[]^abc", [a description]);
42 p = [PKDigit digit];
43
44 result = [p bestMatchFor:a];
45 TDNotNil(a);
46 TDNil(result);
47 TDTrue([a hasMore]);
48 }
49
50
51 - (void)testRepetition {
52 s = @"123";
53 a = [PKCharacterAssembly assemblyWithString:s];
54
55 TDEqualObjects(@"[]^123", [a description]);
56 p = [PKDigit digit];
57 PKParser *r = [PKRepetition repetitionWithSubparser:p];
58
59 result = [r bestMatchFor:a];
60 TDNotNil(a);
61 TDEqualObjects(@"[1, 2, 3]123^", [result description]);
62 TDFalse([result hasMore]);
63 }
64
65 @end
Something went wrong with that request. Please try again.