asmb: struktuelle aenderungen
[uebersetzerbau-ss10.git] / asmb / asmbtest.c
old mode 100755 (executable)
new mode 100644 (file)
index 89e585b..b8932f7
@@ -15,7 +15,7 @@ unsigned char *asmb_ref(unsigned char *s)
        return s;
 }
 
-#define NUM_TESTCASES 12
+#define NUM_TESTCASES 13
 int main() {
        char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54", 
                "foofuuMUHkk", 
@@ -28,20 +28,22 @@ int main() {
                "AbC\0AAAAAAAAAAAA", 
                "BLA|MUHMKUH|KAA\0", 
                "ASDFASDFasdfasdfaBC\0AAAABBBBCCCC", 
-               "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf" 
+               "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf" ,
+               "ASas\0ASas"
        };
        int len[NUM_TESTCASES] = {16,
                11,
                3,
                14,
-               60,
+               61,
                17,
                16,
                16,
                16,
                16,
                32,
-               48
+               48,
+               9
        };
        char *output_our, *output_ref;
        char *input_our,  *input_ref;
@@ -51,25 +53,25 @@ int main() {
                input_our = strndup(input[i], len[i]);
                input_ref = strndup(input[i], len[i]);
 
-               output_our = asmb(input_our);
-               output_ref = asmb_ref(input_ref);
+               output_our = (char *) asmb((unsigned char *) input_our);
+               output_ref = (char *) asmb_ref((unsigned char *) input_ref);
                if(memcmp(output_our,output_ref, len[i]) != 0) {
-                       printf("Testfall falsch! \n Input: \n");
+                       printf("Testfall%02i falsch!\n Input(\"%s\"):\n\t", i, input[i]);
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",input[j]);
+                               printf("%02X ", input[i][j]);
                        }
-                       printf("\nerwartet: \n");
+                       printf("\nerwartet:\n\t");
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",output_ref[j]);
+                               printf("%02X ", output_ref[j]);
                        }
-                       printf("\ntatsaechliches Ergebnis: \n");
+                       printf("\ntatsaechliches Ergebnis:\n\t");
                        for(j = 0; j <= len[i]; j++) {
-                               printf("%02X ",output_our[j]);
+                               printf("%02X ", output_our[j]);
                        }
                        printf("\n");
                }
                else {
-                       printf("Testfall korrekt\n");
+                       printf("Testfall%02i korrekt\n", i);
                }
                free(input_our);
                free(input_ref);
@@ -77,4 +79,3 @@ int main() {
        return 0;
 }
 
-