Skip to content

Commit ca96d99

Browse files
committed
Fixed layout
1 parent 1a3587f commit ca96d99

File tree

1 file changed

+66
-67
lines changed

1 file changed

+66
-67
lines changed

unittest/unittest.c

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -34,82 +34,84 @@ int nrTests = 0, nrErrors = 0, nrWarnings = 0;
3434

3535
// test the alphabet conversion routines
3636
static void alphabet_tests() {
37-
int i,j;
37+
int i, j;
3838
const char *str, *expect;
3939
static const char *testpairs[] = {
40-
".123",".123",
41-
"","",
42-
"-","-",
43-
".",".",
44-
"-123","-123",
45-
"-xyz","-XYZ",
46-
".xyz",".XYZ",
47-
"12.34","12.34",
48-
"OEUoi OIoi#%?-.abcdfghjklmnpqrstvwxyz0123456789euEUABCDFGHJKLMNPQRSTVWXYZ" , "OEUoi OIOI#%?-.ABCDFGHJKLMNPQRSTVWXYZ0123456789EUEUABCDFGHJ",
49-
"OEUoi OIoi#%?abcdfghjklmnpqrstvwxyz0123456789euEUABCDFGHJKLMNPQRSTVWXYZ" , "OEUoi OIOI#%?ABCDFGHJKLMNPQRSTVWXYZ0123456789EUEUABCDFGHJKL",
50-
" Oio 12.AU ","Oio 12.AU",
51-
"OMN 112.3EU","OMN 112.3EU",
52-
"49.4V","49.4V",
53-
"NLD 49.4V-xx123","NLD 49.4V-XX123",
54-
"xx.xx","XX.XX",
55-
"xx.xxx","XX.XXX",
56-
"xxx.xx","XXX.XX",
57-
"xx.xxxx","XX.XXXX",
58-
"xxx.xxx","XXX.XXX",
59-
"xxxx.xx","XXXX.XX",
60-
"xxx.xxxx","XXX.XXXX",
61-
"xxxx.xxx","XXXX.XXX",
62-
"xxxx.xxxx","XXXX.XXXX",
63-
"xxxxx.xxxx","XXXXX.XXXX",
64-
"pq.rs","PQ.RS",
65-
"bc.123","BC.123",
66-
"123.xy","123.XY",
67-
" nld 12.34E0","nld 12.34E0",
68-
"VVX.xxx","VVX.XXX",
69-
"x123.xx","X123.XX",
70-
"xxx.xxxx","XXX.XXXX",
71-
"12xx.xxx","12XX.XXX",
72-
"xxxx.xx12","XXXX.XX12",
73-
"99zxx.xxxx","99ZXX.XXXX",
74-
"xx.xx-P","XX.XX-P",
75-
"xx.xxx-pq","XX.XXX-PQ",
76-
"xxx.xx-123","XXX.XX-123",
77-
"xx.xxxx-pqRS","XX.XXXX-PQRS",
78-
"xxx.xxx-PQRSTUVW","XXX.XXX-PQRSTUVW",
79-
"xxxx.xx-pqrstuvw","XXXX.XX-PQRSTUVW",
80-
"xxx.xxxx-PQrsTU","XXX.XXXX-PQRSTU",
81-
"xxxx.xxx-09876543","XXXX.XXX-09876543",
82-
"xxxx.xxxx-PQRSTUVW","XXXX.XXXX-PQRSTUVW",
83-
"xxxxx.xxxx-PQRSTUVW","XXXXX.XXXX-PQRSTUVW",
84-
"pq.rs-PQRSTUVW","PQ.RS-PQRSTUVW",
85-
"bc.123-PQRSTUVW","BC.123-PQRSTUVW",
86-
"123.xy-PQRSTUVW","123.XY-PQRSTUVW",
87-
"12.34E0-PQRSTUVW","12.34E0-PQRSTUVW",
88-
"VVX.xxx-PQRSTUVW","VVX.XXX-PQRSTUVW",
89-
"x123.xx-PQRSTUVW","X123.XX-PQRSTUVW",
90-
"xxx.xxxx-PQRSTUVW","XXX.XXXX-PQRSTUVW",
91-
"12xx.xxx-PQRSTUVW","12XX.XXX-PQRSTUVW",
92-
"xxxx.xx12-PQRSTUVW","XXXX.XX12-PQRSTUVW",
93-
"99zxx.xxxx-PQRSTUVW","99ZXX.XXXX-PQRSTUVW",
94-
NULL
40+
".123", ".123",
41+
"", "",
42+
"-", "-",
43+
".", ".",
44+
"-123", "-123",
45+
"-xyz", "-XYZ",
46+
".xyz", ".XYZ",
47+
"12.34", "12.34",
48+
"OEUoi OIoi#%?-.abcdfghjklmnpqrstvwxyz0123456789euEUABCDFGHJKLMNPQRSTVWXYZ",
49+
"OEUoi OIOI#%?-.ABCDFGHJKLMNPQRSTVWXYZ0123456789EUEUABCDFGHJ",
50+
"OEUoi OIoi#%?abcdfghjklmnpqrstvwxyz0123456789euEUABCDFGHJKLMNPQRSTVWXYZ",
51+
"OEUoi OIOI#%?ABCDFGHJKLMNPQRSTVWXYZ0123456789EUEUABCDFGHJKL",
52+
" Oio 12.AU ", "Oio 12.AU",
53+
"OMN 112.3EU", "OMN 112.3EU",
54+
"49.4V", "49.4V",
55+
"NLD 49.4V-xx123", "NLD 49.4V-XX123",
56+
"xx.xx", "XX.XX",
57+
"xx.xxx", "XX.XXX",
58+
"xxx.xx", "XXX.XX",
59+
"xx.xxxx", "XX.XXXX",
60+
"xxx.xxx", "XXX.XXX",
61+
"xxxx.xx", "XXXX.XX",
62+
"xxx.xxxx", "XXX.XXXX",
63+
"xxxx.xxx", "XXXX.XXX",
64+
"xxxx.xxxx", "XXXX.XXXX",
65+
"xxxxx.xxxx", "XXXXX.XXXX",
66+
"pq.rs", "PQ.RS",
67+
"bc.123", "BC.123",
68+
"123.xy", "123.XY",
69+
" nld 12.34E0", "nld 12.34E0",
70+
"VVX.xxx", "VVX.XXX",
71+
"x123.xx", "X123.XX",
72+
"xxx.xxxx", "XXX.XXXX",
73+
"12xx.xxx", "12XX.XXX",
74+
"xxxx.xx12", "XXXX.XX12",
75+
"99zxx.xxxx", "99ZXX.XXXX",
76+
"xx.xx-P", "XX.XX-P",
77+
"xx.xxx-pq", "XX.XXX-PQ",
78+
"xxx.xx-123", "XXX.XX-123",
79+
"xx.xxxx-pqRS", "XX.XXXX-PQRS",
80+
"xxx.xxx-PQRSTUVW", "XXX.XXX-PQRSTUVW",
81+
"xxxx.xx-pqrstuvw", "XXXX.XX-PQRSTUVW",
82+
"xxx.xxxx-PQrsTU", "XXX.XXXX-PQRSTU",
83+
"xxxx.xxx-09876543", "XXXX.XXX-09876543",
84+
"xxxx.xxxx-PQRSTUVW", "XXXX.XXXX-PQRSTUVW",
85+
"xxxxx.xxxx-PQRSTUVW", "XXXXX.XXXX-PQRSTUVW",
86+
"pq.rs-PQRSTUVW", "PQ.RS-PQRSTUVW",
87+
"bc.123-PQRSTUVW", "BC.123-PQRSTUVW",
88+
"123.xy-PQRSTUVW", "123.XY-PQRSTUVW",
89+
"12.34E0-PQRSTUVW", "12.34E0-PQRSTUVW",
90+
"VVX.xxx-PQRSTUVW", "VVX.XXX-PQRSTUVW",
91+
"x123.xx-PQRSTUVW", "X123.XX-PQRSTUVW",
92+
"xxx.xxxx-PQRSTUVW", "XXX.XXXX-PQRSTUVW",
93+
"12xx.xxx-PQRSTUVW", "12XX.XXX-PQRSTUVW",
94+
"xxxx.xx12-PQRSTUVW", "XXXX.XX12-PQRSTUVW",
95+
"99zxx.xxxx-PQRSTUVW", "99ZXX.XXXX-PQRSTUVW",
96+
NULL
9597
};
9698

9799
printf("%d alphabets\n", MAPCODE_ALPHABETS_TOTAL);
98100

99-
for(j=0;testpairs[j]!=NULL;j+=2)
100-
{
101+
for (j = 0; testpairs[j] != NULL; j += 2) {
101102
for (i = 0; i < MAPCODE_ALPHABETS_TOTAL; i++) {
102103
UWORD enc[64];
103104
char dec[64];
104105
// see if alphabets (re)convert as expected
105-
str = testpairs[j];
106-
expect = testpairs[j+1];
106+
str = testpairs[j];
107+
expect = testpairs[j + 1];
107108
convertToAlphabet(enc, 64, str, i);
108109
convertToRoman(dec, 60, enc);
109110
nrTests++;
110111
if (strcmp(dec, expect)) {
111112
nrErrors++;
112-
printf("convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\"\n", str, i, dec);
113+
printf("*** ERROR *** convertToRoman(convertToAlphabet(\"%s\",%d))=\"%s\", expect=\"%s\"\n", str, i,
114+
dec, expect);
113115
}
114116
}
115117
}
@@ -249,8 +251,7 @@ static void testEncodeAndDecode(const char *str, double y, double x, int localso
249251
if (err) {
250252
nrErrors++;
251253
printf("*** ERROR *** decode('%s') = no result, expected ~(%0.8f , %0.8f)\n", strResult, y, x);
252-
}
253-
else {
254+
} else {
254255
double dm = distanceInMeters(y, x, lat, lon);
255256
double maxerror = maxErrorInMeters(precision);
256257
// check if decode is sufficiently close to the encoded coordinate
@@ -260,8 +261,7 @@ static void testEncodeAndDecode(const char *str, double y, double x, int localso
260261
printf("*** ERROR *** decode('%s') = (%0.8f , %0.8f), which is %0.4f cm way (>%0.4f cm) from (%0.8f , %0.8f)\n",
261262
strResult, lat, lon,
262263
dm * 100.0, maxerror * 100.0, y, x);
263-
}
264-
else {
264+
} else {
265265
Mapcodes mapcodesTerritory;
266266
Mapcodes mapcodesParent;
267267
int tc2 = -1;
@@ -684,8 +684,7 @@ int main(const int argc, const char **argv) {
684684
printf("Done.\nExecuted %d tests, found %d errors (and %d warnings)\n", nrTests, nrErrors, nrWarnings);
685685
if ((nrWarnings > 0) || (nrErrors > 0)) {
686686
printf("UNIT TESTS FAILED!\n");
687-
}
688-
else {
687+
} else {
689688
printf("Unit tests passed\n");
690689
}
691690
return ((nrErrors + nrWarnings) == 0) ? 0 : -1;

0 commit comments

Comments
 (0)