diff options
author | max99x <max99x@gmail.com> | 2011-06-27 10:39:31 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-06-27 10:39:31 +0300 |
commit | 24f83c080f90dc440bd4981fc9ba5661b7bc28db (patch) | |
tree | cb960f60c261c4aea75a79fffcc1828042b5b51e /tests/runner.py | |
parent | 4c2ba0ca7dbfe4225359df4baad273350a68cf16 (diff) |
Fixed a few boneheaded mistakes; added test for strtod().
Diffstat (limited to 'tests/runner.py')
-rw-r--r-- | tests/runner.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 7c6d45ec..302078a6 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -1976,6 +1976,57 @@ if 'benchmark' not in sys.argv: self.do_test(src, 'In func: 13*First calling main_fptr from lib.*Second calling lib_fptr from main.*Var: 42*', output_nicerizer=lambda x: x.replace('\n', '*')) + def test_strtod(self): + src = r''' + #include <stdio.h> + #include <stdlib.h> + + int main() { + char* endptr; + + printf("\n"); + printf("%g\n", strtod("0", &endptr)); + printf("%g\n", strtod("0.", &endptr)); + printf("%g\n", strtod("0.0", &endptr)); + printf("%g\n", strtod("1", &endptr)); + printf("%g\n", strtod("1.", &endptr)); + printf("%g\n", strtod("1.0", &endptr)); + printf("%g\n", strtod("123", &endptr)); + printf("%g\n", strtod("123.456", &endptr)); + printf("%g\n", strtod("1234567891234567890", &endptr)); + printf("%g\n", strtod("1234567891234567890e+50", &endptr)); + printf("%g\n", strtod("84e+220", &endptr)); + printf("%g\n", strtod("84e+420", &endptr)); + printf("%g\n", strtod("123e-50", &endptr)); + printf("%g\n", strtod("123e-250", &endptr)); + printf("%g\n", strtod("123e-450", &endptr)); + + char str[] = "12.34e56end"; + strtod(str, &endptr); + printf("%d\n", endptr - str); + return 0; + } + ''' + expected = ''' + 0 + 0 + 0 + 1 + 1 + 1 + 123 + 123.456 + 1.23457e+18 + 1.23457e+68 + 8.4e+221 + inf + 1.23e-48 + 1.23e-248 + 0 + 8 + ''' + self.do_test(src, re.sub(r'\n\s+', '\n', expected)) + def test_printf(self): src = open(path_from_root('tests', 'printf', 'test.c'), 'r').read() expected = open(path_from_root('tests', 'printf', 'output.txt'), 'r').read() |