diff --git a/tests/core/test_sscanf_whitespace.in b/tests/core/test_sscanf_whitespace.in new file mode 100644 index 000000000..6947203f9 --- /dev/null +++ b/tests/core/test_sscanf_whitespace.in @@ -0,0 +1,23 @@ + + #include + + int main() { + short int x; + short int y; + + const char* buffer[] = { + "173,16", + " 16,173", + "183, 173", + " 17, 287", + " 98, 123, " + }; + + for (int i=0; i<5; ++i) { + sscanf(buffer[i], "%hd,%hd", &x, &y); + printf("%d:%d,%d ", i, x, y); + } + + return 0; + } + \ No newline at end of file diff --git a/tests/core/test_sscanf_whitespace.out b/tests/core/test_sscanf_whitespace.out new file mode 100644 index 000000000..9a26dd1d4 --- /dev/null +++ b/tests/core/test_sscanf_whitespace.out @@ -0,0 +1 @@ +0:173,16 1:16,173 2:183,173 3:17,287 4:98,123 \ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index 6f1f9b315..ae891355e 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3704,30 +3704,10 @@ Pass: 0.000012 0.000012''') self.do_run_from_file(src, output) def test_sscanf_whitespace(self): - src = r''' - #include + test_path = path_from_root('tests', 'core', 'test_sscanf_whitespace') + src, output = (test_path + s for s in ('.in', '.out')) - int main() { - short int x; - short int y; - - const char* buffer[] = { - "173,16", - " 16,173", - "183, 173", - " 17, 287", - " 98, 123, " - }; - - for (int i=0; i<5; ++i) { - sscanf(buffer[i], "%hd,%hd", &x, &y); - printf("%d:%d,%d ", i, x, y); - } - - return 0; - } - ''' - self.do_run(src, '''0:173,16 1:16,173 2:183,173 3:17,287 4:98,123''') + self.do_run_from_file(src, output) def test_sscanf_other_whitespace(self): Settings.SAFE_HEAP = 0 # use i16s in printf