aboutsummaryrefslogtreecommitdiffhomepage
path: root/unittest/unittest.mm
diff options
context:
space:
mode:
Diffstat (limited to 'unittest/unittest.mm')
-rw-r--r--unittest/unittest.mm36
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