Changeset 377
- Timestamp:
- 02/11/08 02:38:11 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/TestParser.m
r375 r377 18 18 void ICCF_CheckRange(NSRange range) {} 19 19 20 void ps(NSString *format, ...) {20 static void ps(NSString *format, ...) { 21 21 va_list args; 22 22 va_start(args, format); … … 27 27 } 28 28 29 void pr(NSString *s, NSRange r) {29 static void pr(NSString *s, NSRange r) { 30 30 ps([[NSString alloc] initWithFormat: @"%@%@>%@<", 31 31 s, [@"" stringByPaddingToLength: r.location withString: @" " startingAtIndex: 0], 32 32 [@"" stringByPaddingToLength: r.length withString: @"-" startingAtIndex: 0]]); 33 } 34 35 static BOOL check_parse(NSString *uri, NSString *text, 36 NSRange delimitedURIRange, NSRange initialSelectionRange) { 37 // XXX figure XFAIL-type error checking 38 39 NSRange enclosingRange; 40 NSString *parsedURI = nil; 41 NSException *parseException = nil; 42 @try { 43 enclosingRange = ICCF_URLEnclosingRange(text, initialSelectionRange); 44 parsedURI = [text substringWithRange: enclosingRange]; 45 } @catch (NSException *e) { 46 parseException = e; 47 } 48 49 if ([uri isEqualToString: parsedURI]) { 50 return YES; 51 } 52 53 ps(@"Text %@", text); 54 pr(@"Available ", delimitedURIRange); 55 pr(@"Starting ", initialSelectionRange); 56 57 if (parseException != nil) { 58 ps(@"Exception %@", parseException); 59 } else { 60 pr(@"Parsed ", enclosingRange); 61 ps(@"Parsed %@", parsedURI); 62 ps(@"Desired %@", uri); 63 } 64 return NO; 33 65 } 34 66 … … 65 97 delimitedURIRange.location = 0; 66 98 delimitedURIRange.length = [uri length]; 67 } 99 } // XXX add ^ ^ to indicate initialSelectionRange? 68 100 69 101 for (unsigned startOffset = 0 ; startOffset < delimitedURIRange.length ; ++startOffset) { … … 73 105 }; 74 106 75 // XXX figure XFAIL-type error checking 76 77 NSRange enclosingRange; 78 NSString *parsedURI = nil; 79 NSException *parseException = nil; 80 @try { 81 enclosingRange = ICCF_URLEnclosingRange(text, delimitedURIRange); 82 parsedURI = [text substringWithRange: enclosingRange]; 83 } @catch (NSException *e) { 84 parseException = e; 107 if (check_parse(uri, text, delimitedURIRange, initialSelectionRange)) { 108 pass++; 109 } else { 110 fail++; 111 goto summary; 85 112 } 86 87 if ([uri isEqualToString: parsedURI]) {88 ++pass;89 continue;90 }91 92 ps(@"Text %@", text);93 pr(@"Available ", delimitedURIRange);94 pr(@"Starting ", initialSelectionRange);95 96 if (parseException != nil) {97 ps(@"Exception %@", parseException);98 } else {99 pr(@"Parsed ", enclosingRange);100 ps(@"Parsed %@", parsedURI);101 ps(@"Desired %@", uri);102 }103 ++fail;104 goto summary;105 113 } 106 114 }
Note:
See TracChangeset
for help on using the changeset viewer.