projects
/
uebersetzerbau-ss10.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe87bd4
)
asmb: testen und zwar richtig
author
Bernhard Urban
<lewurm@gmail.com>
Thu, 4 Mar 2010 18:46:30 +0000
(19:46 +0100)
committer
Bernhard Urban
<lewurm@gmail.com>
Thu, 4 Mar 2010 18:46:30 +0000
(19:46 +0100)
asmb/asmbtest.c
patch
|
blob
|
history
diff --git
a/asmb/asmbtest.c
b/asmb/asmbtest.c
index b8932f7594b879b7c70814dc62b5def01817e37d..ed928c5fb8750a6d2ab97adb73c66bd66c2f3b82 100644
(file)
--- a/
asmb/asmbtest.c
+++ b/
asmb/asmbtest.c
@@
-16,7
+16,8
@@
unsigned char *asmb_ref(unsigned char *s)
}
#define NUM_TESTCASES 13
}
#define NUM_TESTCASES 13
-int main() {
+int main()
+{
char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54",
"foofuuMUHkk",
"AbC",
char *input[NUM_TESTCASES]={"asdfABCDEFGHKL54",
"foofuuMUHkk",
"AbC",
@@
-50,13
+51,22
@@
int main() {
int i,j;
for(i = 0; i < NUM_TESTCASES; i++) {
int i,j;
for(i = 0; i < NUM_TESTCASES; i++) {
- input_our = strndup(input[i], len[i]);
- input_ref = strndup(input[i], len[i]);
+ input_our = (char *) malloc (len[i]);
+ input_ref = (char *) malloc (len[i]);
+
+ (void) memcpy(input_our, input[i], len[i]+1);
+ (void) memcpy(input_ref, input[i], len[i]+1);
output_our = (char *) asmb((unsigned char *) input_our);
output_ref = (char *) asmb_ref((unsigned char *) 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) {
if(memcmp(output_our,output_ref, len[i]) != 0) {
- printf("Testfall%02i falsch!\n Input(\"%s\"):\n\t", i, input[i]);
+ if(strncmp(output_our, output_ref, len[i]) == 0)
+ printf("Testfall%02i nach Nullbyte ungleich\n", i);
+ else
+ printf("Testfall%02i falsch!\n", i);
+
+ printf("Input(\"%s\"):\n\t", input[i]);
for(j = 0; j <= len[i]; j++) {
printf("%02X ", input[i][j]);
}
for(j = 0; j <= len[i]; j++) {
printf("%02X ", input[i][j]);
}