summaryrefslogtreecommitdiff
path: root/src/test/test_dir.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-11-05 13:28:29 -0500
committerNick Mathewson <nickm@torproject.org>2014-11-05 13:29:28 -0500
commitfc62721b06e3ac231b570741e21dba03b5cadaca (patch)
treedbbf16c1abd61a15e13db1fd7cebd680fba584db /src/test/test_dir.c
parent9e2608b0d35e7e890e53f83e40675851caff4a14 (diff)
downloadtor-fc62721b06e3ac231b570741e21dba03b5cadaca.tar.gz
tor-fc62721b06e3ac231b570741e21dba03b5cadaca.zip
Fix version number parsing to allow 2- and 3-part versions.
Fixes bug 13661; bugfix on 0.0.8pre1.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r--src/test/test_dir.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index c03b63be27..61484f5fe1 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -337,6 +337,42 @@ test_dir_versions(void)
test_eq(VER_RELEASE, ver1.status);
test_streq("", ver1.status_tag);
+ test_eq(0, tor_version_parse("10.1", &ver1));
+ test_eq(10, ver1.major);
+ test_eq(1, ver1.minor);
+ test_eq(0, ver1.micro);
+ test_eq(0, ver1.patchlevel);
+ test_eq(VER_RELEASE, ver1.status);
+ test_streq("", ver1.status_tag);
+ test_eq(0, tor_version_parse("5.99.999", &ver1));
+ test_eq(5, ver1.major);
+ test_eq(99, ver1.minor);
+ test_eq(999, ver1.micro);
+ test_eq(0, ver1.patchlevel);
+ test_eq(VER_RELEASE, ver1.status);
+ test_streq("", ver1.status_tag);
+ test_eq(0, tor_version_parse("10.1-alpha", &ver1));
+ test_eq(10, ver1.major);
+ test_eq(1, ver1.minor);
+ test_eq(0, ver1.micro);
+ test_eq(0, ver1.patchlevel);
+ test_eq(VER_RELEASE, ver1.status);
+ test_streq("alpha", ver1.status_tag);
+ test_eq(0, tor_version_parse("2.1.700-alpha", &ver1));
+ test_eq(2, ver1.major);
+ test_eq(1, ver1.minor);
+ test_eq(700, ver1.micro);
+ test_eq(0, ver1.patchlevel);
+ test_eq(VER_RELEASE, ver1.status);
+ test_streq("alpha", ver1.status_tag);
+ test_eq(0, tor_version_parse("1.6.8-alpha-dev", &ver1));
+ test_eq(1, ver1.major);
+ test_eq(6, ver1.minor);
+ test_eq(8, ver1.micro);
+ test_eq(0, ver1.patchlevel);
+ test_eq(VER_RELEASE, ver1.status);
+ test_streq("alpha-dev", ver1.status_tag);
+
#define tt_versionstatus_op(vs1, op, vs2) \
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
(val1_ op val2_),"%d",TT_EXIT_TEST_FUNCTION)