diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 13:52:42 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:57 +0200 |
commit | e9a04792bfc7b808ea94b1b7694fc1dd38258f67 (patch) | |
tree | d399847f9785311b7a881eddec7ae39ecbf7be44 | |
parent | f742cc19931cb3debb2dfa81b80245765eeb01dd (diff) |
Use do_run_from_file() for test_strtol_dec
-rw-r--r-- | tests/core/test_strtol_dec.in | 22 | ||||
-rw-r--r-- | tests/core/test_strtol_dec.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 25 |
3 files changed, 26 insertions, 22 deletions
diff --git a/tests/core/test_strtol_dec.in b/tests/core/test_strtol_dec.in new file mode 100644 index 00000000..496e5dc8 --- /dev/null +++ b/tests/core/test_strtol_dec.in @@ -0,0 +1,22 @@ + + #include <stdio.h> + #include <stdlib.h> + + int main() { + const char *STRING = "4 -38 +4711"; + char *end_char; + + // undefined base + long l1 = strtol(STRING, &end_char, 0); + long l2 = strtol(end_char, &end_char, 0); + long l3 = strtol(end_char, NULL, 0); + + // defined base + long l4 = strtol(STRING, &end_char, 10); + long l5 = strtol(end_char, &end_char, 10); + long l6 = strtol(end_char, NULL, 10); + + printf("%d%d%d%d%d%d\n", l1==4, l2==-38, l3==4711, l4==4, l5==-38, l6==4711); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_strtol_dec.out b/tests/core/test_strtol_dec.out new file mode 100644 index 00000000..b23c1c51 --- /dev/null +++ b/tests/core/test_strtol_dec.out @@ -0,0 +1 @@ +111111
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 610896be..6791e568 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2397,29 +2397,10 @@ The current type of b is: 9 def test_strtol_dec(self): # tests strtoll for decimal strings (0x...) - src = r''' - #include <stdio.h> - #include <stdlib.h> - - int main() { - const char *STRING = "4 -38 +4711"; - char *end_char; - - // undefined base - long l1 = strtol(STRING, &end_char, 0); - long l2 = strtol(end_char, &end_char, 0); - long l3 = strtol(end_char, NULL, 0); - - // defined base - long l4 = strtol(STRING, &end_char, 10); - long l5 = strtol(end_char, &end_char, 10); - long l6 = strtol(end_char, NULL, 10); + test_path = path_from_root('tests', 'core', 'test_strtol_dec') + src, output = (test_path + s for s in ('.in', '.out')) - printf("%d%d%d%d%d%d\n", l1==4, l2==-38, l3==4711, l4==4, l5==-38, l6==4711); - return 0; - } - ''' - self.do_run(src, '111111') + self.do_run_from_file(src, output) def test_strtol_bin(self): # tests strtoll for binary strings (0x...) |