-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern unsigned char *asmb(unsigned char *a);
-
-unsigned char *asmb_ref(unsigned char *s)
-{
- unsigned long i;
- for (i=0; s[i]; i++) {
- unsigned char c=s[i];
- c += (c>='A' && c<='Z') ? 'a'-'A' : 0;
- s[i] = c;
- }
- return s;
-}
-
-#define NUM_TESTCASES 12
-int main()
-{
- char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54",
- "foofuuMUHkk",
- "AbC",
- "BLA|MUHMKUH|KA",
- "ASDFNERABHDFKHDFKLGJAHGLKAHGLKASHGEARNAKLVNLVAANLSADJVHASDLGH",
- "asdfABCDEFGHKL544",
- "asdfA\0BCDEFGHKL5",
- "foofuuMUHkk\0AAAA",
- "AbC\0AAAAAAAAAAAA",
- "BLA|MUHMKUH|KAA\0",
- "ASDFASDFasdfasdfaBC\0AAAABBBBCCCC",
- "ASDFASDFasdfasdfaBC0AAAABBBBCCCCmuhKA\0asASDFasdf"
- };
- int len[NUM_TESTCASES] = {16,
- 11,
- 3,
- 14,
- 60,
- 17,
- 16,
- 16,
- 16,
- 16,
- 32,
- 48
- };
- char *output_our, *output_ref;
- char *input_our, *input_ref;
-
- int i,j;
- for(i = 0; i < NUM_TESTCASES; i++) {
- input_our = strndup(input[i], len[i]);
- input_ref = strndup(input[i], len[i]);
-
- 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!\nInput:\n\t");
- for(j = 0; j <= len[i]; j++) {
- printf("%02X ", input[i][j]);
- }
- printf("\nerwartet:\n\t");
- for(j = 0; j <= len[i]; j++) {
- printf("%02X ", output_ref[j]);
- }
- printf("\ntatsaechliches Ergebnis:\n\t");
- for(j = 0; j <= len[i]; j++) {
- printf("%02X ", output_our[j]);
- }
- printf("\n");
- }
- else {
- printf("Testfall korrekt\n");
- }
- free(input_our);
- free(input_ref);
- }
- return 0;
-}
-