Skip to content

Commit

Permalink
Added remaining failure conditions to scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Oct 21, 2013
1 parent 8e698ca commit 7cd0b3f
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Test/Source/NSScannerDTMarkdownTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,64 @@ - (void)testNormalRefLine
STAssertEqualObjects(title, @"Title", @"incorrect title");
}

- (void)testMissingRefEmptyID
{
NSString *string = @"[]: http://foo.com (Title)";

NSScanner *scanner = [NSScanner scannerWithString:string];
scanner.charactersToBeSkipped = nil;

NSString *href;
NSString *title;
NSString *ref;

BOOL b = [scanner scanMarkdownHyperlinkReferenceLine:&ref URLString:&href title:&title];

STAssertFalse(b, @"Should not be able to scan hyperlink");

STAssertNil(href, @"href should be nil");
STAssertNil(title, @"Title should be nil");
STAssertNil(ref, @"href should be nil");
}

- (void)testMissingRefClosingBracket
{
NSString *string = @"[foo] http://foo.com (Title)";

NSScanner *scanner = [NSScanner scannerWithString:string];
scanner.charactersToBeSkipped = nil;

NSString *href;
NSString *title;
NSString *ref;

BOOL b = [scanner scanMarkdownHyperlinkReferenceLine:&ref URLString:&href title:&title];

STAssertFalse(b, @"Should not be able to scan hyperlink");

STAssertNil(href, @"href should be nil");
STAssertNil(title, @"Title should be nil");
STAssertNil(ref, @"href should be nil");
}

- (void)testMissingSpacesAfterID
{
NSString *string = @"[foo]:http://foo.com (Title)";

NSScanner *scanner = [NSScanner scannerWithString:string];
scanner.charactersToBeSkipped = nil;

NSString *href;
NSString *title;
NSString *ref;

BOOL b = [scanner scanMarkdownHyperlinkReferenceLine:&ref URLString:&href title:&title];

STAssertFalse(b, @"Should not be able to scan hyperlink");

STAssertNil(href, @"href should be nil");
STAssertNil(title, @"Title should be nil");
STAssertNil(ref, @"href should be nil");
}

@end

0 comments on commit 7cd0b3f

Please sign in to comment.