diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-10-29 11:28:28 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-10-29 11:47:08 -0700 |
commit | 2db1ec46f5a259e03c7866374086f11af30ff7da (patch) | |
tree | 0ab105897a4e52091da7d4d407cb7f522818b584 /tests/test_core.py | |
parent | 7c354898f5ba3db8f5eec12115a929db16ed0ac8 (diff) |
optimize scanString to not run the regex more than once
Diffstat (limited to 'tests/test_core.py')
-rw-r--r-- | tests/test_core.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index b766ac74..189da2bc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7285,6 +7285,18 @@ date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3 ''' self.do_run(src, '4779 4779') + def test_sscanf_float(self): + src = r''' + #include "stdio.h" + + int main(){ + float f1, f2, f3, f4, f5, f6, f7, f8, f9; + sscanf("0.512 0.250x5.129_-9.98 1.12*+54.32E3 +54.32E3^87.5E-3 87.5E-3$", "%f %fx%f_%f %f*%f %f^%f %f$", &f1, &f2, &f3, &f4, &f5, &f6, &f7, &f8, &f9); + printf("\n%f, %f, %f, %f, %f, %f, %f, %f, %f\n", f1, f2, f3, f4, f5, f6, f7, f8, f9); + } + ''' + self.do_run(src, '\n0.512000, 0.250000, 5.129000, -9.980000, 1.120000, 54320.000000, 54320.000000, 0.087500, 0.087500\n') + 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() |