diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-11-04 22:28:55 -0800 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-11-04 22:29:25 -0800 |
commit | de1e84d977dd7be1f245a1df823d1d25d53ae87f (patch) | |
tree | 6268da78c38cde769624563c4f6fb04a1f0690f1 /unittest/unittest.mm | |
parent | a6cc6fdea83b7f8be42f2366ecb92b420274e679 (diff) |
Added more unit tests
Diffstat (limited to 'unittest/unittest.mm')
-rw-r--r-- | unittest/unittest.mm | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/unittest/unittest.mm b/unittest/unittest.mm index b125231f..fa1798d1 100644 --- a/unittest/unittest.mm +++ b/unittest/unittest.mm @@ -87,17 +87,20 @@ NSString * _builderOutputPath; NSString * _parserOutputPath; NSString * _charsetDetectionPath; + NSString * _summaryDetectionPath; + NSString * _summaryDetectionOutputPath; } - (void)setUp { [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. _mainPath = [[[NSBundle bundleForClass:[self class]] resourcePath] stringByAppendingPathComponent:@"data"]; _builderPath = [_mainPath stringByAppendingPathComponent:@"builder/input"]; _builderOutputPath = [_mainPath stringByAppendingPathComponent:@"builder/output"]; _parserPath = [_mainPath stringByAppendingPathComponent:@"parser/input"]; _parserOutputPath = [_mainPath stringByAppendingPathComponent:@"parser/output"]; _charsetDetectionPath = [_mainPath stringByAppendingPathComponent:@"charset-detection"]; + _summaryDetectionPath = [_mainPath stringByAppendingPathComponent:@"summary/input"]; + _summaryDetectionOutputPath = [_mainPath stringByAppendingPathComponent:@"summary/output"]; } - (void)tearDown { @@ -210,4 +213,35 @@ } } +- (void)testSummary { + NSArray * list = [[NSFileManager defaultManager] subpathsAtPath:_summaryDetectionPath]; + for(NSString * name in list) { + NSString * path = [_summaryDetectionPath stringByAppendingPathComponent:name]; + BOOL isDirectory = NO; + [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]; + if (isDirectory) { + continue; + } + NSData * data = [NSData dataWithContentsOfFile:path]; + MCOMessageParser * parser = [MCOMessageParser messageParserWithData:data]; + NSString * str = [parser plainTextRendering]; + +// NSString * outputPath = [@"/Users/hoa/mc2-results/summary" stringByAppendingPathComponent:name]; +// outputPath = [[outputPath stringByDeletingPathExtension] stringByAppendingPathExtension:@"txt"]; +// NSString * directory = [outputPath stringByDeletingLastPathComponent]; +// [[NSFileManager defaultManager] createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:NULL]; +// [str writeToFile:outputPath atomically:YES encoding:NSUTF8StringEncoding error:NULL]; + + NSString * resultPath = [_summaryDetectionOutputPath stringByAppendingPathComponent:name]; + resultPath = [[resultPath stringByDeletingPathExtension] stringByAppendingPathExtension:@"txt"]; + NSData * resultData = [NSData dataWithContentsOfFile:resultPath]; + if (resultData == nil) { + NSLog(@"test %@ is a well-known failing test", name); + continue; + } + + XCTAssertEqualObjects(str, [[NSString alloc] initWithData:resultData encoding:NSUTF8StringEncoding]); + } +} + @end |