Changeset 382 for trunk


Ignore:
Timestamp:
02/11/08 06:29:28 (17 years ago)
Author:
Nicholas Riley
Message:

TestParser.m: Don't permit empty strings to pass through; they break
ICCF_ParseURL. Print invalid range in ICCF_CheckRange. Support
delimiters in 'uri' or 'text' for initialSelectionRange; can be used
in addition to | |, which as before tries every single-character
starting range.

urls.plist: A few more tests, for IPv6 address recognition, delimited
expansion and multiple ending delimiters.

Location:
trunk/ICeCoffEE/ICeCoffEE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/TestParser.m

    r377 r382  
    1111
    1212#include <stdarg.h>
    13 
    14 NSString *ICCF_ErrString(OSStatus err, NSString *context) {   
    15     return [NSString stringWithFormat: @"%@ (%d)", context, (int)err];
    16 }
    17 
    18 void ICCF_CheckRange(NSRange range) {}
    1913
    2014static void ps(NSString *format, ...) {
     
    3226        [@"" stringByPaddingToLength: r.length withString: @"-" startingAtIndex: 0]]);
    3327}
     28
     29NSString *ICCF_ErrString(OSStatus err, NSString *context) {   
     30    return [NSString stringWithFormat: @"%@ (%d)", context, (int)err];
     31}
     32
     33void ICCF_CheckRange(NSRange range) {
     34    if (range.length > 0)
     35        return;
     36   
     37    pr(@"Invalid   ", range);
     38    @throw([NSException exceptionWithName: NSRangeException
     39                                   reason: @"No URL is selected"
     40                                 userInfo: nil]);
     41}
     42
    3443
    3544static BOOL check_parse(NSString *uri, NSString *text,
     
    97106            delimitedURIRange.location = 0;
    98107            delimitedURIRange.length = [uri length];
    99         } // XXX add ^ ^ to indicate initialSelectionRange?
     108        }
     109       
     110        NSArray *bits = [text componentsSeparatedByString: @"^"];
     111        if ([bits count] == 3) {
     112            NSString *joined = [bits componentsJoinedByString: @""];
     113            NSRange initialSelectionRange = {
     114                [(NSString *)[bits objectAtIndex: 0] length],
     115                [(NSString *)[bits objectAtIndex: 1] length]
     116            };
     117            delimitedURIRange.length -= 2; // remove ^^
     118            if (check_parse(uri == text ? joined : uri, joined,
     119                            delimitedURIRange, initialSelectionRange)) {
     120                pass++;
     121            } else {
     122                fail++;
     123                goto summary;
     124            }
     125            if (uri == text)
     126                continue;
     127            text = joined;
     128        }
    100129       
    101130        for (unsigned startOffset = 0 ; startOffset < delimitedURIRange.length ; ++startOffset) {
  • trunk/ICeCoffEE/ICeCoffEE/urls.plist

    r374 r382  
    99  },
    1010 
     11  { /* Start with caret-delimited selection */
     12    uri = "https://www-s.acm.uiuc.edu/wiki/space/^(user)^mloar2";
     13  },
     14
     15  {
     16    uri = "https://www-s.acm.uiuc.edu/wiki/space/(u^ser)m^loar2";
     17  },
     18
     19  {
     20    uri = "https://www-s.acm.uiuc.edu/wiki/space/mloar2^(user)^";
     21  },
     22
    1123  {
    1224    uri = "https://www-s.acm.uiuc.edu/wiki/space/usermloar2";
    13     text = "|<https://www-s.acm.uiuc.edu/wiki/space/usermloar2>| foo";
     25    text = "|<https://www-s.acm.uiuc.edu/wiki/space/usermloar2>|foo";
    1426  },
    1527 
     
    6880  },
    6981 
     82  {
     83    uri = "telnet:foo";
     84    text = "foo bar baz|[telnet:foo]|baz bar foo";
     85  },
     86
     87  {
     88    uri = "http://en.wikipedia.org/wiki/Paprika_(2006_film)";
     89    text = "|<http://en.wikipedia.org/wiki/Paprika_(2006_film)>|foo";
     90  },
    7091)
    7192
Note: See TracChangeset for help on using the changeset viewer.