From f725491687e1bcb31a544d9f279ad560e49490a2 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sun, 14 Mar 2010 20:29:28 +0100 Subject: [PATCH] asmb: 'bessere' testfaelle --- asmb/asmbtest.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/asmb/asmbtest.c b/asmb/asmbtest.c index 1e536fa..63b2ca6 100644 --- a/asmb/asmbtest.c +++ b/asmb/asmbtest.c @@ -64,7 +64,7 @@ static void fillregisters(void) } -#define NUM_TESTCASES 18 +#define NUM_TESTCASES 19 int main() { char *input[NUM_TESTCASES]={ @@ -86,8 +86,9 @@ int main() "ASas\0ASas", "asdfABCDEFGHKL54", "asdffvdfgerrggre\0", + "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ1234567890allyourbasearebelongtousALLYOURBASEAREBELONGTOUS1337423133711111!!!!elfeinscos(0)sin(M_PI/2)MASTEROFDESTRUCTIONlordoftheuniverseFA!LblogICANhascheezburgericanHASCHEEZBURGERRickROLLrollRICK O RLY? you got 288 IMiss Teen South Carolina" }; - int len[NUM_TESTCASES] = { + int len[NUM_TESTCASES+1] = { 16, 8, 8, @@ -106,8 +107,10 @@ int main() 9, 16, 17, + 296, + 31337 }; - int off[NUM_TESTCASES] = { + int off[NUM_TESTCASES+1] = { 0, 0, 0, @@ -126,17 +129,27 @@ int main() 0, 0, 0, + 5, + 10, }; char *output_our, *output_ref; char *input_our, *input_ref; int right=0, wrong=0, neither=0, i; - for(i = 0; i < NUM_TESTCASES; i++) { - input_our = (char *) malloc (len[i]); - input_ref = (char *) malloc (len[i]); + for(i = 0; i < NUM_TESTCASES+1; i++) { + input_our = (char *) calloc (len[i], 16); + input_ref = (char *) calloc (len[i], 16); - (void) memcpy(input_our, input[i], len[i]+1); - (void) memcpy(input_ref, input[i], len[i]+1); + if(i == NUM_TESTCASES) { + long u; + for(u=0; u < len[i]; u++) { + input_our[u] = input_ref[u] = 'S'; + } + input_our[len[i]] = input_ref[len[i]] = '\0'; + } else { + (void) memcpy(input_our, input[i], len[i]+1); + (void) memcpy(input_ref, input[i], len[i]+1); + } fillregisters(); output_our = (char *) asmb((unsigned char *) input_our+off[i]); @@ -152,8 +165,11 @@ int main() printf("Testfall%02i falsch!\n", i); } - printf("Input(\"%s\"):\n", input[i]); - hexdump(input[i], len[i]); + if (i < NUM_TESTCASES) { + /* beim "spezialfall" wuerde das boese enden */ + printf("Input(\"%s\"):\n", input[i]); + hexdump(input[i], len[i]); + } printf("\nerwartet:\n"); hexdump(output_ref, len[i]); -- 2.25.1