aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 15:47:26 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:36:00 +0200
commitf7077dc65917f2346006931506f6f09f701b5b33 (patch)
treea486506cb9a0d3cfc7d3ea56ad87f2eb694bb101 /tests
parent8102a3ef09cf1cc174ce232690e1d7ba500c2bf0 (diff)
Use do_run_from_file() for test_sscanf_6
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_sscanf_6.in15
-rw-r--r--tests/core/test_sscanf_6.out2
-rw-r--r--tests/test_core.py22
3 files changed, 21 insertions, 18 deletions
diff --git a/tests/core/test_sscanf_6.in b/tests/core/test_sscanf_6.in
new file mode 100644
index 00000000..2f2f58a3
--- /dev/null
+++ b/tests/core/test_sscanf_6.in
@@ -0,0 +1,15 @@
+
+ #include <stdio.h>
+ #include <string.h>
+ int main()
+ {
+ char *date = "18.07.2013w";
+ char c[10];
+ memset(c, 0, 10);
+ int y, m, d, i;
+ i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %c, %d\n", date, d, m, y, c[0], i);
+ i = sscanf(date, "%d.%d.%3c", &d, &m, c);
+ printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m, y, c, i);
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_sscanf_6.out b/tests/core/test_sscanf_6.out
new file mode 100644
index 00000000..4aee073e
--- /dev/null
+++ b/tests/core/test_sscanf_6.out
@@ -0,0 +1,2 @@
+date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
+date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
diff --git a/tests/test_core.py b/tests/test_core.py
index 07979758..2b4d7e52 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -3739,24 +3739,10 @@ Pass: 0.000012 0.000012''')
self.do_run_from_file(src, output)
def test_sscanf_6(self):
- src = r'''
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char *date = "18.07.2013w";
- char c[10];
- memset(c, 0, 10);
- int y, m, d, i;
- i = sscanf(date, "%d.%d.%4d%c", &d, &m, &y, c);
- printf("date: %s; day %2d, month %2d, year %4d, extra: %c, %d\n", date, d, m, y, c[0], i);
- i = sscanf(date, "%d.%d.%3c", &d, &m, c);
- printf("date: %s; day %2d, month %2d, year %4d, extra: %s, %d\n", date, d, m, y, c, i);
- }
- '''
- self.do_run(src, '''date: 18.07.2013w; day 18, month 7, year 2013, extra: w, 4
-date: 18.07.2013w; day 18, month 7, year 2013, extra: 201, 3
-''');
+ test_path = path_from_root('tests', 'core', 'test_sscanf_6')
+ src, output = (test_path + s for s in ('.in', '.out'))
+
+ self.do_run_from_file(src, output)
def test_sscanf_skip(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip("need ta2 for full i64")