diff options
Diffstat (limited to 'tests/runner.py')
-rw-r--r-- | tests/runner.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 428a54d6..59db23e2 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -3004,6 +3004,47 @@ at function.:blag ''' self.do_run(src) + # Part 2: doubles (issue 148) + return # TODO: Make the second part here work + src = r''' + #include <stdio.h> + + int main(){ + char strval1[] = "1.2345678901"; + char strval2[] = "1.23456789e5"; + char strval3[] = "1.23456789E5"; + char strval4[] = "1.2345678e-5"; + char strval5[] = "1.2345678E-5"; + double dblval = 1.2345678901; + double tstval; + + sscanf(strval1, "%lf", &tstval); + if(dblval != tstval) printf("FAIL: Values are not equal: %lf %lf\n", dblval, tstval); + else printf("Pass: %lf %lf\n", tstval, dblval); + + sscanf(strval2, "%lf", &tstval); + dblval = 123456.789; + if(dblval != tstval) printf("FAIL: Values are not equal: %lf %lf\n", dblval, tstval); + else printf("Pass: %lf %lf\n", tstval, dblval); + + sscanf(strval3, "%lf", &tstval); + dblval = 123456.789; + if(dblval != tstval) printf("FAIL: Values are not equal: %lf %lf\n", dblval, tstval); + else printf("Pass: %lf %lf\n", tstval, dblval); + + sscanf(strval4, "%lf", &tstval); + dblval = 0.000012345678; + if(dblval != tstval) printf("FAIL: Values are not equal: %lf %lf\n", dblval, tstval); + else printf("Pass: %lf %lf\n", tstval, dblval); + + sscanf(strval5, "%lf", &tstval); + dblval = 0.000012345678; + if(dblval != tstval) printf("FAIL: Values are not equal: %lf %lf\n", dblval, tstval); + else printf("Pass: %lf %lf\n", tstval, dblval); + } + ''' + self.do_run(src) + def test_langinfo(self): src = open(path_from_root('tests', 'langinfo', 'test.c'), 'r').read() expected = open(path_from_root('tests', 'langinfo', 'output.txt'), 'r').read() |