Skip to content
Browse files

Added some more unit tests to make sure comment line number is proper…

…ly detected.
  • Loading branch information...
1 parent c80c3fe commit 4247d9b3ba10df1a06c71dd4a428b8a36bb5a3cf @tomaz committed Sep 24, 2010
Showing with 24 additions and 0 deletions.
  1. +24 −0 Testing/GBTokenizerTesting.m
View
24 Testing/GBTokenizerTesting.m
@@ -317,6 +317,30 @@ - (void)testLastCommentString_shouldKeepExampleTabs {
assertThat([tokenizer.lastComment stringValue], is(@"line1\n\n\texample1\n\texample2\n\nline2"));
}
+- (void)testLastCommentString_shouldDetectSingleLineCommentSourceInformation {
+ // setup & execute
+ GBTokenizer *tokenizer = [GBTokenizer tokenizerWithSource:[PKTokenizer tokenizerWithString:@"\n\n\n/// comment\nONE"] filename:@"file"];
+ // verify
+ assertThat([tokenizer.lastComment.sourceInfo filename], is(@"file"));
+ assertThatInteger([tokenizer.lastComment.sourceInfo lineNumber], equalToInteger(4));
+}
+
+- (void)testLastCommentString_shouldAssignSingleLineCommentLineNumberOfFirstLine {
+ // setup & execute
+ GBTokenizer *tokenizer = [GBTokenizer tokenizerWithSource:[PKTokenizer tokenizerWithString:@"/// line1\n/// line2\n/// line3\nONE"] filename:@"file"];
+ // verify
+ assertThat([tokenizer.lastComment.sourceInfo filename], is(@"file"));
+ assertThatInteger([tokenizer.lastComment.sourceInfo lineNumber], equalToInteger(1));
+}
+
+- (void)testLastCommentString_shouldDetectMultipleLineCommentSourceInformation {
+ // setup & execute
+ GBTokenizer *tokenizer = [GBTokenizer tokenizerWithSource:[PKTokenizer tokenizerWithString:@"\n\n\n/** comment */\nONE"] filename:@"file"];
+ // verify
+ assertThat([tokenizer.lastComment.sourceInfo filename], is(@"file"));
+ assertThatInteger([tokenizer.lastComment.sourceInfo lineNumber], equalToInteger(4));
+}
+
#pragma mark Creation methods
- (PKTokenizer *)defaultTokenizer {

0 comments on commit 4247d9b

Please sign in to comment.
Something went wrong with that request. Please try again.