| 269 | } |
| 270 | |
| 271 | static void testSummary(String * path) |
| 272 | { |
| 273 | printf("testSummary\n"); |
| 274 | String * inputPath = path->stringByAppendingPathComponent(MCSTR("input")); |
| 275 | String * outputPath = path->stringByAppendingPathComponent(MCSTR("output")); |
| 276 | Array * list = pathsInDirectory(inputPath); |
| 277 | int failure = 0; |
| 278 | int success = 0; |
| 279 | mc_foreacharray(String, filename, list) { |
| 280 | MessageParser * parser = MessageParser::messageParserWithContentsOfFile(filename); |
| 281 | prepareHeaderForUnitTest(parser->header()); |
| 282 | preparePartForUnitTest(parser->mainPart()); |
| 283 | String * str = parser->plainTextRendering(); |
| 284 | String * resultPath = outputPath->stringByAppendingPathComponent(filename->substringFromIndex(inputPath->length())); |
| 285 | resultPath = resultPath->stringByDeletingPathExtension()->stringByAppendingString(MCSTR(".txt")); |
| 286 | Data * resultData = Data::dataWithContentsOfFile(resultPath); |
| 287 | if (resultData == NULL) { |
| 288 | fprintf(stderr, "test %s is a well-known failing test", MCUTF8(filename)); |
| 289 | continue; |
| 290 | } |
| 291 | String * resultString = resultData->stringWithCharset("utf-8"); |
| 292 | str = tweakDateFromSummary(str); |
| 293 | resultString = tweakDateFromSummary(resultString); |
| 294 | |
| 295 | if (!resultString->isEqual(str)) { |
| 296 | failure ++; |
| 297 | fprintf(stderr, "testSummary: failed for %s\n", MCUTF8(filename)); |
| 298 | fprintf(stderr, "got: %s\n", MCUTF8(str)); |
| 299 | fprintf(stderr, "expected: %s\n", MCUTF8(resultData->stringWithCharset("utf-8"))); |
| 300 | } |
| 301 | else { |
| 302 | success ++; |
| 303 | } |
| 304 | } |
| 305 | if (failure > 0) { |
| 306 | printf("testSummary ok: %i succeeded, %i failed\n", success, failure); |
| 307 | global_failure ++; |
| 308 | return; |
| 309 | } |
| 310 | printf("testSummary ok: %i succeeded\n", success); |
| 311 | global_success ++; |
| 312 | } |
| 313 | |
| 314 | static void testMUTF7(void) |
| 315 | { |
no test coverage detected