From cc6043603f427d24a00b567a01908cd220890ecd Mon Sep 17 00:00:00 2001 From: Vasilis Kalintiris Date: Sat, 7 Dec 2013 15:40:55 +0200 Subject: [PATCH] Use do_run_from_file() for test_sscanf_n --- tests/core/test_sscanf_n.in | 21 +++++++++++++++++++++ tests/core/test_sscanf_n.out | 3 +++ tests/test_core.py | 24 +++--------------------- 3 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 tests/core/test_sscanf_n.in create mode 100644 tests/core/test_sscanf_n.out diff --git a/tests/core/test_sscanf_n.in b/tests/core/test_sscanf_n.in new file mode 100644 index 000000000..78142b3a0 --- /dev/null +++ b/tests/core/test_sscanf_n.in @@ -0,0 +1,21 @@ + + #include + int main() { + char *line = "version 1.0"; + int i, l, lineno; + char word[80]; + if (sscanf(line, "%s%n", word, &l) != 1) { + printf("Header format error, line %d\n", lineno); + } + printf("[DEBUG] word 1: %s, l: %d\n", word, l); + + int x = sscanf("one %n two", "%s %n", word, &l); + printf("%d,%s,%d\n", x, word, l); + { + int a, b, c, count; + count = sscanf("12345 6789", "%d %n%d", &a, &b, &c); + printf("%i %i %i %i\n", count, a, b, c); + } + return 0; + } + \ No newline at end of file diff --git a/tests/core/test_sscanf_n.out b/tests/core/test_sscanf_n.out new file mode 100644 index 000000000..c3ce6f046 --- /dev/null +++ b/tests/core/test_sscanf_n.out @@ -0,0 +1,3 @@ +[DEBUG] word 1: version, l: 7 +1,one,4 +2 12345 6 6789 diff --git a/tests/test_core.py b/tests/test_core.py index d4e7a5b4d..6f1f9b315 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3698,28 +3698,10 @@ Pass: 0.000012 0.000012 Pass: 0.000012 0.000012''') def test_sscanf_n(self): - src = r''' - #include - int main() { - char *line = "version 1.0"; - int i, l, lineno; - char word[80]; - if (sscanf(line, "%s%n", word, &l) != 1) { - printf("Header format error, line %d\n", lineno); - } - printf("[DEBUG] word 1: %s, l: %d\n", word, l); + test_path = path_from_root('tests', 'core', 'test_sscanf_n') + src, output = (test_path + s for s in ('.in', '.out')) - int x = sscanf("one %n two", "%s %n", word, &l); - printf("%d,%s,%d\n", x, word, l); - { - int a, b, c, count; - count = sscanf("12345 6789", "%d %n%d", &a, &b, &c); - printf("%i %i %i %i\n", count, a, b, c); - } - return 0; - } - ''' - self.do_run(src, '''[DEBUG] word 1: version, l: 7\n1,one,4\n2 12345 6 6789\n''') + self.do_run_from_file(src, output) def test_sscanf_whitespace(self): src = r'''