asma: hmm.. passt nu ned ganz?
[uebersetzerbau-ss10.git] / asma / main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 extern unsigned char *asma(unsigned char *s);
6
7 unsigned char *asma_ref(unsigned char *s)
8 {
9         int i;
10         for (i=0; i<16; i++) {
11                 unsigned char c = s[i];
12                 c += (c >= 'A' && c <= 'Z') ? 'a'-'A' : 0;
13                 s[i] = c;
14         }
15         return s;
16 }
17
18 int main(int argc, char **argv) {
19         char *input1[]={"asdfABCDEFGHKL54", "foofuuMUHkk", "AbC"};
20         char *output1;
21         char *output2;
22         char *input2;
23         char *input3;
24         int i, j;
25
26         for(i = 0; i < 3; i++) {
27                 input2 = strdup(input1[i]);
28                 input3 = strdup(input1[i]);
29                 output1 = (char *)asma_ref((unsigned char *)(input2));
30                 output2 = (char *)asma((unsigned char *)(input3));
31
32                 output1[16]='\0';
33                 output2[16]='\0';
34
35                 printf("\n");
36                 if(memcmp(output1,output2, 16)) {
37                         j = 0;
38                         printf("Testfall falsch; Input war: \"%s\"\n", input1[i]);
39                         printf("erwartet:\n\t\"%s\"\ntatsaechliches Ergebnis:\n\t\"%s\"\n", output1, output2);
40 #if 0
41                         printf("0x");
42                         for(j = 0; j < 16; j++)
43                                 printf("%02X", output2[j]);
44                         printf("\n");
45 #endif
46                 } else {
47                         printf("Testfall \"%s\" passt.\n", output1);
48                 }
49
50                 free(input2);
51                 free(input3);
52         }
53
54         return 0;
55 }
56