aboutsummaryrefslogtreecommitdiff
path: root/tests/test_core.py
diff options
context:
space:
mode:
authorSoeren Balko <Soeren.Balko@gmail.com>2013-09-13 21:47:57 +1000
committerSoeren Balko <Soeren.Balko@gmail.com>2013-09-13 21:48:39 +1000
commite13cf3e53604cf956e0d1e5bc9ffd657a70be944 (patch)
tree084dcf1193f28a51c6cefdc84584d482d3d1d62b /tests/test_core.py
parent27d496610e0ef93c9805a6a1a77de3f053405c6b (diff)
Enable %[] pattern in scanf
Diffstat (limited to 'tests/test_core.py')
-rw-r--r--tests/test_core.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index d02e6778..d499b6a9 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -6907,6 +6907,29 @@ at function.:blag
printf("%i\n", a);
}
+ char buf1[100], buf2[100], buf3[100], buf4[100];
+
+ int numItems = sscanf("level=4:ref=3", "%255[^:=]=%255[^:]:%255[^=]=%255c", buf1, buf2, buf3, buf4);
+ printf("%d, %s, %s, %s, %s\n", numItems, buf1, buf2, buf3, buf4);
+
+ numItems = sscanf("def|456", "%[a-z]|%[0-9]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("3-4,-ab", "%[-0-9],%[ab-z-]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("Hello,World", "%[A-Za-z],%[^0-9]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
+ numItems = sscanf("Hello4711", "%[^0-9],%[^0-9]", buf1, buf2);
+ printf("%d, %s\n", numItems, buf1);
+
+ numItems = sscanf("JavaScript", "%4[A-Za-z]", buf1);
+ printf("%d, %s\n", numItems, buf1);
+
+ numItems = sscanf("[]", "%1[[]%1[]]", buf1, buf2);
+ printf("%d, %s, %s\n", numItems, buf1, buf2);
+
return 0;
}
'''
@@ -6914,7 +6937,14 @@ at function.:blag
'1\n1499\n' +
'5\n87,0.481565,0.059481,0,1\n' +
'3\n-123,4294966531,-34\n' +
- '1\n')
+ '1\n' +
+ '4, level, 4, ref, 3\n' +
+ '2, def, 456\n' +
+ '2, 3-4, -ab\n' +
+ '2, Hello, World\n' +
+ '1, Hello\n' +
+ '1, Java\n' +
+ '2, [, ]')
def test_sscanf_2(self):
# doubles