Skip to content

Commit 49f2b7c

Browse files
committed
Improved unit test
1 parent 49a1c5d commit 49f2b7c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

unittest/unittest.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ static void alphabet_tests() {
4040
printf("%d alphabets\n", MAPCODE_ALPHABETS_TOTAL);
4141

4242
for (i = 0; i < MAPCODE_ALPHABETS_TOTAL; i++) {
43-
UWORD enc[69];
44-
char dec[69];
43+
UWORD enc[64];
44+
char dec[64];
4545

4646
// see if convertToAlphabet survives empty string
4747
nrTests++;
4848
str = "";
4949
convertToAlphabet(enc, 64, str, i);
5050
if (*enc) {
5151
nrErrors++;
52-
printf("*** ERROR *** empty string: convertToAlphabet(\"%s\",%d) = \"%s\"\n", str, i, dec);
52+
printf("*** ERROR *** convertToAlphabet(\"%s\",%d) = \"%s\"\n", str, i, dec);
5353
}
5454
else {
5555
// see if empty UTF16 converts to empty string
@@ -62,38 +62,40 @@ static void alphabet_tests() {
6262
}
6363

6464
// see if alphabets (re)convert as expected
65-
str = "OEUoi OIoi#%?-.abcdfghjklmnpqrstvwxyz0123456789ABCDFGHJKLMNPQRSTVWXYZ";
66-
expect = "OEUoi OIOI#%?-.ABCDFGHJKLMNPQRSTVWXYZ0123456789ABCDFGHJKLMNPQRSTVWXYZ";
67-
convertToAlphabet(enc, sizeof(enc), str, i);
68-
convertToRoman(dec, sizeof(dec), enc);
65+
str = "OEUoi OIoi#%?-.abcdfghjklmnpqrstvwxyz0123456789ABCDFGHJKLMNPQRSTVWXYZ";
66+
expect = "OEUoi OIOI#%?-.ABCDFGHJKLMNPQRSTVWXYZ0123456789ABCDFGHJKLMN";
67+
convertToAlphabet(enc, 64, str, i);
68+
convertToRoman(dec, 60, enc);
6969
nrTests++;
7070
if (strlen(dec) != 59 || strcmp(dec, expect)) {
7171
nrErrors++;
72-
printf("*** ERROR *** all chars: convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\", expected=\"%s\"\n", str, i, dec, expect);
72+
printf("*** ERROR *** convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\", expect=\"%s\"\n", str, i, dec, expect);
7373
}
7474

7575
// see if E/U voweled mapcodes (re)convert as expected
7676
str = "OMN 112.3EU";
77-
convertToAlphabet(enc, sizeof(enc), str, i);
78-
convertToRoman(dec, sizeof(dec), enc);
77+
convertToAlphabet(enc, 64, str, i);
78+
convertToRoman(dec, 64, enc);
7979
nrTests++;
8080
if (strcmp(dec, str) != 0) {
8181
nrErrors++;
82-
printf("*** ERROR *** vowels EU: convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\", expected=\"%s\"\n", str, i, dec, expect);
82+
printf("*** ERROR *** convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\"\n", str, i, dec);
8383
}
8484
else {
8585
nrTests++;
8686
{
8787
str = " Oio 112.3AU ";
88-
convertToAlphabet(enc, sizeof(enc), str, i);
89-
convertToRoman(dec, sizeof(dec), enc);
88+
convertToAlphabet(enc, 64, str, i);
89+
convertToRoman(dec, 64, enc);
9090
nrTests++;
9191
if (strcmp(dec, "Oio 112.3AU") != 0) {
9292
nrErrors++;
93-
printf("*** ERROR *** vowels AU: convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\"\n", str, i, dec);
93+
printf("*** ERROR *** convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\"\n", str, i, dec);
9494
}
9595
}
9696
}
97+
98+
9799
}
98100
}
99101

0 commit comments

Comments
 (0)