diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 13:43:38 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:57 +0200 |
commit | b36947626b822900f070b0592bb1f3dc24c18774 (patch) | |
tree | a5adffdd1f16a40e2398305424260fc9d1aa3424 | |
parent | c7f686aeec5b789d3bd0d17bb8893852117febc0 (diff) |
Use do_run_from_file() for test_strtoll_hex
-rw-r--r-- | tests/core/test_strtoll_hex.in | 22 | ||||
-rw-r--r-- | tests/core/test_strtoll_hex.out | 1 | ||||
-rw-r--r-- | tests/test_core.py | 25 |
3 files changed, 26 insertions, 22 deletions
diff --git a/tests/core/test_strtoll_hex.in b/tests/core/test_strtoll_hex.in new file mode 100644 index 00000000..333fe512 --- /dev/null +++ b/tests/core/test_strtoll_hex.in @@ -0,0 +1,22 @@ + + #include <stdio.h> + #include <stdlib.h> + + int main() { + const char *STRING = "0x4 -0x3A +0xDEADBEEF"; + char *end_char; + + // undefined base + long long int l1 = strtoll(STRING, &end_char, 0); + long long int l2 = strtoll(end_char, &end_char, 0); + long long int l3 = strtoll(end_char, NULL, 0); + + // defined base + long long int l4 = strtoll(STRING, &end_char, 16); + long long int l5 = strtoll(end_char, &end_char, 16); + long long int l6 = strtoll(end_char, NULL, 16); + + printf("%d%d%d%d%d%d\n", l1==0x4, l2==-0x3a, l3==0xdeadbeef, l4==0x4, l5==-0x3a, l6==0xdeadbeef); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_strtoll_hex.out b/tests/core/test_strtoll_hex.out new file mode 100644 index 00000000..b23c1c51 --- /dev/null +++ b/tests/core/test_strtoll_hex.out @@ -0,0 +1 @@ +111111
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index d34313f7..35e91fac 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2356,29 +2356,10 @@ The current type of b is: 9 if self.emcc_args is None: return self.skip('requires emcc') # tests strtoll for hex strings (0x...) - src = r''' - #include <stdio.h> - #include <stdlib.h> - - int main() { - const char *STRING = "0x4 -0x3A +0xDEADBEEF"; - char *end_char; - - // undefined base - long long int l1 = strtoll(STRING, &end_char, 0); - long long int l2 = strtoll(end_char, &end_char, 0); - long long int l3 = strtoll(end_char, NULL, 0); - - // defined base - long long int l4 = strtoll(STRING, &end_char, 16); - long long int l5 = strtoll(end_char, &end_char, 16); - long long int l6 = strtoll(end_char, NULL, 16); + test_path = path_from_root('tests', 'core', 'test_strtoll_hex') + src, output = (test_path + s for s in ('.in', '.out')) - printf("%d%d%d%d%d%d\n", l1==0x4, l2==-0x3a, l3==0xdeadbeef, l4==0x4, l5==-0x3a, l6==0xdeadbeef); - return 0; - } - ''' - self.do_run(src, '111111') + self.do_run_from_file(src, output) def test_strtoll_dec(self): if self.emcc_args is None: return self.skip('requires emcc') |