Skip to content

Commit b9f6405

Browse files
committed
Fixed unit test
1 parent 356e650 commit b9f6405

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

unitttest/unittest.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#define UNITTEST_VERSION "2.2.1"
18-
1917
/**
2018
* This application performs a number of tests on the Mapcode C library.
2119
* It helps to establish that all routines work properly.
@@ -629,11 +627,8 @@ void territory_code_tests() {
629627

630628

631629
int main(const int argc, const char **argv) {
632-
#ifdef XSIDE3
633-
const char *mapcode_dataversion = "undefined";
634-
#endif
635-
printf("Mapcode C Library Unit test %s\n", UNITTEST_VERSION);
636-
printf("Library version %s (Data version %s)\n", mapcode_cversion, mapcode_dataversion);
630+
printf("Mapcode C Library Unit Tests\n");
631+
printf("Library version %s (data version %s)\n", mapcode_cversion, mapcode_dataversion);
637632

638633
printf("-----------------------------------------------------------\nAlphabet tests\n");
639634
alphabet_tests();
@@ -647,27 +642,22 @@ int main(const int argc, const char **argv) {
647642
territory_code_tests();
648643
test_territory_insides();
649644

650-
printf("-----------------------------------------------------------\nFailing decode tests\n");
651-
test_failing_decodes();
652-
653-
printf("-----------------------------------------------------------\nFailing decodes tests\n");
645+
printf("-----------------------------------------------------------\nIncorrect format tests\n");
654646
test_failing_decodes();
655647

656-
printf("-----------------------------------------------------------\nEncode/Decode tests\n");
657-
{
658-
//clock_t c_start = clock();
659-
encode_decode_tests();
660-
//fprintf(stderr,"%ld time\n", (clock() - c_start));
661-
}
648+
printf("-----------------------------------------------------------\nEncode/decode tests\n");
649+
encode_decode_tests();
662650

663651
printf("-----------------------------------------------------------\nRe-encode tests\n");
664652
re_encode_tests();
665653

666654
printf("-----------------------------------------------------------\n");
667-
printf("Done.\nExecuted %d tests, found %d errors", nrTests, nrErrors);
668-
if (nrWarnings) {
669-
printf(", %d warnings\n", nrWarnings);
655+
printf("Done.\nExecuted %d tests, found %d errors (and %d warnings)\n", nrTests, nrErrors, nrWarnings);
656+
if ((nrWarnings > 0) || (nrErrors > 0)) {
657+
printf("UNIT TESTS FAILED!\n");
658+
}
659+
else {
660+
printf("Unit tests passed\n");
670661
}
671-
printf("\n");
672662
return ((nrErrors + nrWarnings) == 0) ? 0 : -1;
673663
}

0 commit comments

Comments
 (0)