diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 20:00:50 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:49 +0200 |
commit | 3164ebe49cbe94151c82054e1060cfbc17770ffb (patch) | |
tree | f49322c5c6a8e631305908cba7fbc81f18ad7b96 /tests | |
parent | 0453ade06eec5d1e39c4efdbfe9f000c7510bd4e (diff) |
Use do_run_from_file() for test_sintvars
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_sintvars.in | 25 | ||||
-rw-r--r-- | tests/core/test_sintvars.out | 4 | ||||
-rw-r--r-- | tests/test_core.py | 30 |
3 files changed, 33 insertions, 26 deletions
diff --git a/tests/core/test_sintvars.in b/tests/core/test_sintvars.in new file mode 100644 index 00000000..1b377c7c --- /dev/null +++ b/tests/core/test_sintvars.in @@ -0,0 +1,25 @@ + + #include <stdio.h> + struct S { + char *match_start; + char *strstart; + }; + int main() + { + struct S _s; + struct S *s = &_s; + unsigned short int sh; + + s->match_start = (char*)32522; + s->strstart = (char*)(32780); + printf("*%d,%d,%d*\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start)); + sh = s->strstart - s->match_start; + printf("*%d,%d*\n", sh, sh>>7); + + s->match_start = (char*)32999; + s->strstart = (char*)(32780); + printf("*%d,%d,%d*\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start)); + sh = s->strstart - s->match_start; + printf("*%d,%d*\n", sh, sh>>7); + } +
\ No newline at end of file diff --git a/tests/core/test_sintvars.out b/tests/core/test_sintvars.out new file mode 100644 index 00000000..aea5592e --- /dev/null +++ b/tests/core/test_sintvars.out @@ -0,0 +1,4 @@ +*32780,32522,258* +*258,2* +*32780,32999,-219* +*65317,510*
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 9f5f5a4c..5f65e623 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -27,34 +27,12 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co def test_sintvars(self): Settings.CORRECT_SIGNS = 1 # Relevant to this test - src = ''' - #include <stdio.h> - struct S { - char *match_start; - char *strstart; - }; - int main() - { - struct S _s; - struct S *s = &_s; - unsigned short int sh; + Settings.CORRECT_OVERFLOWS = 0 # We should not need overflow correction to get this right - s->match_start = (char*)32522; - s->strstart = (char*)(32780); - printf("*%d,%d,%d*\\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start)); - sh = s->strstart - s->match_start; - printf("*%d,%d*\\n", sh, sh>>7); + test_path = path_from_root('tests', 'core', 'test_sintvars') + src, output = (test_path + s for s in ('.in', '.out')) - s->match_start = (char*)32999; - s->strstart = (char*)(32780); - printf("*%d,%d,%d*\\n", (int)s->strstart, (int)s->match_start, (int)(s->strstart - s->match_start)); - sh = s->strstart - s->match_start; - printf("*%d,%d*\\n", sh, sh>>7); - } - ''' - output = '*32780,32522,258*\n*258,2*\n*32780,32999,-219*\n*65317,510*' - Settings.CORRECT_OVERFLOWS = 0 # We should not need overflow correction to get this right - self.do_run(src, output, force_c=True) + self.do_run_from_file(src, output, force_c=True) def test_i64(self): if Settings.USE_TYPED_ARRAYS != 2: return self.skip('i64 mode 1 requires ta2') |