|
|
|
@ -80,7 +80,7 @@ static char failed[1000]; |
|
|
|
|
static char failmsg[100]; |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
run_test(Test_Entry *test) |
|
|
|
|
run_output_test(Test_Entry *test) |
|
|
|
|
{ |
|
|
|
|
char *valstr = yasm__xstrdup(test->input); |
|
|
|
|
yasm_intnum *intn = yasm_intnum_create_hex(valstr, 0); |
|
|
|
@ -129,6 +129,44 @@ run_test(Test_Entry *test) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
run_input_test(Test_Entry *test) |
|
|
|
|
{ |
|
|
|
|
char *valstr = yasm__xstrdup(test->input); |
|
|
|
|
yasm_intnum *intn = yasm_intnum_create_hex(valstr, 0); |
|
|
|
|
yasm_intnum *testn; |
|
|
|
|
unsigned long size, i; |
|
|
|
|
unsigned char out[100]; |
|
|
|
|
|
|
|
|
|
yasm_xfree(valstr); |
|
|
|
|
|
|
|
|
|
if (test->negate) |
|
|
|
|
yasm_intnum_calc(intn, YASM_EXPR_NEG, NULL, 0); |
|
|
|
|
|
|
|
|
|
testn = yasm_intnum_create_leb128(test->result, test->sign, &size, 0); |
|
|
|
|
if (size != test->outsize) { |
|
|
|
|
yasm_intnum_destroy(testn); |
|
|
|
|
yasm_intnum_destroy(intn); |
|
|
|
|
sprintf(failmsg, "%ssigned %s%s create() bad size: expected %lu, got %lu!", |
|
|
|
|
test->sign?"":"un", test->negate?"-":"", test->input, |
|
|
|
|
test->outsize, size); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
yasm_intnum_calc(intn, YASM_EXPR_EQ, testn, 0); |
|
|
|
|
if (!yasm_intnum_is_pos1(intn)) { |
|
|
|
|
yasm_intnum_destroy(testn); |
|
|
|
|
yasm_intnum_destroy(intn); |
|
|
|
|
sprintf(failmsg, "%ssigned %s%s create() bad output!", |
|
|
|
|
test->sign?"":"un", test->negate?"-":"", test->input); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
yasm_intnum_destroy(testn); |
|
|
|
|
yasm_intnum_destroy(intn); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
main(void) |
|
|
|
|
{ |
|
|
|
@ -143,7 +181,16 @@ main(void) |
|
|
|
|
failed[0] = '\0'; |
|
|
|
|
printf("Test leb128_test: "); |
|
|
|
|
for (i=0; i<numtests; i++) { |
|
|
|
|
int fail = run_test(&tests[i]); |
|
|
|
|
int fail; |
|
|
|
|
|
|
|
|
|
fail = run_output_test(&tests[i]); |
|
|
|
|
printf("%c", fail>0 ? 'F':'.'); |
|
|
|
|
fflush(stdout); |
|
|
|
|
if (fail) |
|
|
|
|
sprintf(failed, "%s ** F: %s\n", failed, failmsg); |
|
|
|
|
nf += fail; |
|
|
|
|
|
|
|
|
|
fail = run_input_test(&tests[i]); |
|
|
|
|
printf("%c", fail>0 ? 'F':'.'); |
|
|
|
|
fflush(stdout); |
|
|
|
|
if (fail) |
|
|
|
@ -154,6 +201,7 @@ main(void) |
|
|
|
|
yasm_intnum_cleanup(); |
|
|
|
|
|
|
|
|
|
printf(" +%d-%d/%d %d%%\n%s", |
|
|
|
|
numtests-nf, nf, numtests, 100*(numtests-nf)/numtests, failed); |
|
|
|
|
numtests*2-nf, nf, numtests*2, 100*(numtests*2-nf)/(numtests*2), |
|
|
|
|
failed); |
|
|
|
|
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
|
|
|
|
} |
|
|
|
|