Permalink
Browse files

Added a little more complex unit test for comments processing.

  • Loading branch information...
1 parent 5254f04 commit 2b4f6831b0f7ac56bb935d753b1ab7a5f9abe73c @tomaz committed Sep 22, 2010
@@ -0,0 +1,83 @@
+//
+// GBCommentsProcessor-ComplexTesting.m
+// appledoc
+//
+// Created by Tomaz Kragelj on 22.9.10.
+// Copyright (C) 2010 Gentle Bytes. All rights reserved.
+//
+
+#import "GBComment.h"
+#import "GBCommentsProcessor.h"
+
+@interface GBCommentsProcessorComplexTesting : GBObjectsAssertor
+
+- (void)assertFirstParagraph:(GBCommentParagraph *)paragraph;
+- (void)assertSecondParagraph:(GBCommentParagraph *)paragraph;
+- (void)assertThirdParagraph:(GBCommentParagraph *)paragraph;
+
+@end
+
+#pragma mark -
+
+@implementation GBCommentsProcessorComplexTesting
+
+- (void)testProcesCommentWithStore_shouldProcessTrickyComment {
+ // setup
+ GBCommentsProcessor *processor = [GBCommentsProcessor processorWithSettingsProvider:[GBTestObjectsRegistry mockSettingsProvider]];
+ GBClassData *class = [GBClassData classDataWithName:@"Second"];
+ GBStore *store = [GBTestObjectsRegistry storeByPerformingSelector:@selector(registerClass:) withObject:class];
+ NSString *value = [GBRealLifeDataProvider trickyMethodComment];
+ GBComment *comment = [GBComment commentWithStringValue:value];
+ // execute
+ [processor processComment:comment withStore:store];
+ // verify
+ assertThatInteger([comment.paragraphs count], equalToInteger(3));
+ [self assertFirstParagraph:[comment.paragraphs objectAtIndex:0]];
+ [self assertSecondParagraph:[comment.paragraphs objectAtIndex:1]];
+ [self assertThirdParagraph:[comment.paragraphs objectAtIndex:2]];
+}
+
+- (void)assertFirstParagraph:(GBCommentParagraph *)paragraph {
+ [self assertParagraph:paragraph containsTexts:@"Short description.", nil];
+}
+
+- (void)assertSecondParagraph:(GBCommentParagraph *)paragraph {
+ [self assertParagraph:paragraph containsItems:
+ [GBParagraphLinkItem class], @"Second",
+ [GBParagraphTextItem class], @"paragraph with lot's of text split into two lines.",
+ [GBParagraphListItem class], [NSNull null],
+ [GBParagraphSpecialItem class], @"Source line 1\n\n\tSource line with tab",
+ nil];
+ [self assertList:[paragraph.items objectAtIndex:2] describesHierarchy:
+ @"Nested 1", NO, 1,
+ @"Nested 1.1", NO, 2,
+ @"Nested 2", NO, 1,
+ @"Nested 2.1", YES, 2,
+ @"Nested 2.1.1", YES, 3,
+ @"Nested 2.2", YES, 2,
+ nil];
+}
+
+- (void)assertThirdParagraph:(GBCommentParagraph *)paragraph {
+ [self assertParagraph:paragraph containsItems:
+ [GBParagraphTextItem class], @"Third paragraph.",
+ [GBParagraphSpecialItem class], [NSNull null],
+ [GBParagraphSpecialItem class], [NSNull null],
+ nil];
+
+ GBParagraphSpecialItem *warning = [paragraph.items objectAtIndex:1];
+ assertThatInteger(warning.specialItemType, equalToInteger(GBSpecialItemTypeWarning));
+ [self assertParagraph:warning.specialItemDescription containsItems:
+ [GBParagraphDecoratorItem class], @"Important:",
+ [GBParagraphTextItem class], @"There is something important about this! We even write it in two lines!",
+ nil];
+
+ GBParagraphSpecialItem *bug = [paragraph.items objectAtIndex:2];
+ assertThatInteger(bug.specialItemType, equalToInteger(GBSpecialItemTypeBug));
+ [self assertParagraph:bug.specialItemDescription containsItems:
+ [GBParagraphDecoratorItem class], @"ID215:",
+ [GBParagraphTextItem class], @"Khm, still not working...",
+ nil];
+}
+
+@end
@@ -1,5 +1,5 @@
//
-// GBCommentsProcessor-LinkItemsTesting.m
+// GBCommentsProcessor-MethodItemsTesting.m
// appledoc
//
// Created by Tomaz Kragelj on 19.9.10.
@@ -31,9 +31,7 @@
- (void)assertList:(GBParagraphListItem *)list isOrdered:(BOOL)ordered containsParagraphs:(NSString *)first,... NS_REQUIRES_NIL_TERMINATION;
- (void)assertList:(GBParagraphListItem *)list describesHierarchy:(NSString *)first,... NS_REQUIRES_NIL_TERMINATION;
-
- (void)assertDecoratedItem:(GBParagraphItem *)item describesHierarchy:(Class)first,... NS_REQUIRES_NIL_TERMINATION;
-
- (void)assertLinkItem:(GBParagraphLinkItem *)item hasLink:(NSString *)link context:(id)context member:(id)member local:(BOOL)local;
- (void)assertArgument:(GBCommentArgument *)argument hasName:(NSString *)name descriptions:(NSString *)first,... NS_REQUIRES_NIL_TERMINATION;
@@ -12,6 +12,6 @@
+ (NSString *)headerWithClassCategoryAndProtocol;
+ (NSString *)codeWithClassAndCategory;
-+ (NSString *)fullMethodComment;
++ (NSString *)trickyMethodComment;
@end
@@ -64,7 +64,7 @@ + (NSString *)codeWithClassAndCategory {
@"\n";
}
-+ (NSString *)fullMethodComment {
++ (NSString *)trickyMethodComment {
return
// Short description.
@"Short description.\n"
@@ -75,15 +75,13 @@ + (NSString *)fullMethodComment {
@"split into two lines.\n"
@"\n\n\n"
- // Two unordered list separated with an empty line.
- @"- Unordered item 1.\n"
- @"- Unordered item 2.\n"
- @"\n\n"
- @"- Second unordered list\n"
-
- // Ordered list (should work even if no empty line before unordered list!)
- @"1. Ordered item 1.\n"
- @"999. Ordered item 2.\n"
+ // Nested lists.
+ @"- Nested 1\n"
+ @" - Nested 1.1\n"
+ @"- Nested 2\n"
+ @" 999. Nested 2.1\n"
+ @" 1. Nested 2.1.1\n"
+ @" 2. Nested 2.2\n"
@"\n"
// Example with empty line and tabs.
@@ -92,22 +90,26 @@ + (NSString *)fullMethodComment {
@"\t\tSource line with tab\n"
@"\n"
- // Second example without empty line before next paragraph.
- @"\tSecond example\n"
-
// Third paragraph.
@"Third paragraph.\n"
+ @"\n"
// Warning and bug.
- @"@warning Warning\n"
- @"@bug Bug\n"
+ @"@warning *Important:* There is something important about this!\n"
+ @"We even write it in two lines!\n"
+ @"\n"
+ @"@bug *ID215:* Khm, still not working...\n"
+ @"\n"
- // Parameters block, note there's no empty line before!
+ // Method block.
@"@param name1 Description1\n"
@"@param name2 Description2\n"
- @"@return Return\n"
+ @"@return Return value\n"
+ @"\tsplit into several lines.\n"
@"@exception exc1 Exception1\n"
@"@exception exc2 Exception2\n"
+
+ // Cross references.
@"@see link1\n"
@"@sa link2\n";
}
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 7307B2A6124A0888007EC6B8 /* GBCommentsProcessor-ComplexTesting.m in Sources */ = {isa = PBXBuildFile; fileRef = 7307B2A5124A0888007EC6B8 /* GBCommentsProcessor-ComplexTesting.m */; };
731D2BF512045A61003180E7 /* NSString+GBString.m in Sources */ = {isa = PBXBuildFile; fileRef = 731D2BF412045A61003180E7 /* NSString+GBString.m */; };
731E7CE811F9962D00AAF15D /* NSException+GBException.m in Sources */ = {isa = PBXBuildFile; fileRef = 731E7CE711F9962D00AAF15D /* NSException+GBException.m */; };
73329896122E4DFC00AEBA2B /* GBCommentsProcessor-UnorderedListsTesting.m in Sources */ = {isa = PBXBuildFile; fileRef = 73329895122E4DFC00AEBA2B /* GBCommentsProcessor-UnorderedListsTesting.m */; };
@@ -133,6 +134,7 @@
/* Begin PBXFileReference section */
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 7307B2A5124A0888007EC6B8 /* GBCommentsProcessor-ComplexTesting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GBCommentsProcessor-ComplexTesting.m"; sourceTree = "<group>"; };
731D2BF312045A61003180E7 /* NSString+GBString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+GBString.h"; sourceTree = "<group>"; };
731D2BF412045A61003180E7 /* NSString+GBString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+GBString.m"; sourceTree = "<group>"; };
731E7CE611F9962D00AAF15D /* NSException+GBException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSException+GBException.h"; sourceTree = "<group>"; };
@@ -615,6 +617,7 @@
7377404512301CDC00E29F1E /* GBCommentsProcessor-DecoratorItemsTesting.m */,
73A32FAF1236491400040070 /* GBCommentsProcessor-LinkItemsTesting.m */,
7389461412468B2E00A4A3A0 /* GBCommentsProcessor-MethodArgumentsTesting.m */,
+ 7307B2A5124A0888007EC6B8 /* GBCommentsProcessor-ComplexTesting.m */,
);
name = Processing;
sourceTree = "<group>";
@@ -885,6 +888,7 @@
73F2CA75123E4161009B406B /* GBProcessor.m in Sources */,
738945D61246857500A4A3A0 /* GBCommentArgument.m in Sources */,
7389461512468B2E00A4A3A0 /* GBCommentsProcessor-MethodArgumentsTesting.m in Sources */,
+ 7307B2A6124A0888007EC6B8 /* GBCommentsProcessor-ComplexTesting.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 2b4f683

Please sign in to comment.