aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-10-11 10:50:47 -0400
committerNick Mathewson <nickm@torproject.org>2010-10-11 10:50:47 -0400
commit8f76f31761f051d5b6a3280462db6adf95b19233 (patch)
treeb9a4daadf14df6db79a5ecb978a3bedd20e3730a /src/test
parent45ce1f678fa3de4634d29415d850eb2723440bca (diff)
downloadtor-8f76f31761f051d5b6a3280462db6adf95b19233.tar.gz
tor-8f76f31761f051d5b6a3280462db6adf95b19233.zip
Make tor_sscanf handle %x
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 68a0ca2984..5701f12857 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -833,6 +833,18 @@ test_util_sscanf(void)
test_eq(u2, 3u);
test_eq(u3, 99u);
+ /* %x should work. */
+ r = tor_sscanf("1234 02aBcdEf", "%x %x", &u1, &u2);
+ test_eq(r, 2);
+ test_eq(u1, 0x1234);
+ test_eq(u2, 0x2ABCDEF);
+ /* Width works on %x */
+ r = tor_sscanf("f00dcafe444", "%4x%4x%u", &u1, &u2, &u3);
+ test_eq(r, 3);
+ test_eq(u1, 0xf00d);
+ test_eq(u2, 0xcafe);
+ test_eq(u3, 444);
+
r = tor_sscanf("99% fresh", "%3u%% fresh", &u1); /* percents are scannable.*/
test_eq(r, 1);
test_eq(u1, 99);