From fc62721b06e3ac231b570741e21dba03b5cadaca Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 5 Nov 2014 13:28:29 -0500 Subject: Fix version number parsing to allow 2- and 3-part versions. Fixes bug 13661; bugfix on 0.0.8pre1. --- src/test/test_dir.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/test') 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) -- cgit v1.2.3-54-g00ecf