MCPcopy Create free account
hub / github.com/apache/impala / TEST

Function TEST

be/src/kudu/util/version_util-test.cc:38–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace kudu {
37
38TEST(VersionUtilTest, TestVersion) {
39 const vector<pair<Version, string>> good_test_cases = {
40 { { "0.0.0", 0, 0, 0, nullopt, "" }, "0.0.0" },
41 { { "1.0.0", 1, 0, 0, nullopt, "" }, "1.0.0" },
42 { { "1.1.0", 1, 1, 0, nullopt, "" }, "1.1.0" },
43 { { "1.1.1", 1, 1, 1, nullopt, "" }, "1.1.1" },
44 { { "1.1.1-", 1, 1, 1, nullopt, "" }, "1.1.1" },
45 { { "1.1.1-0-1-2", 1, 1, 1, '-', "0-1-2" }, "1.1.1-0-1-2" },
46 { { "1.10.100-1000.0", 1, 10, 100, '-', "1000.0" }, "1.10.100-1000.0" },
47 { { "1.2.3-SNAPSHOT", 1, 2, 3, '-', "SNAPSHOT" }, "1.2.3-SNAPSHOT" },
48 { { "1.8.0-x-SNAPSHOT", 1, 8, 0, '-', "x-SNAPSHOT" }, "1.8.0-x-SNAPSHOT" },
49 { { "0.1.2-a-b-c-d", 0, 1, 2, '-', "a-b-c-d" }, "0.1.2-a-b-c-d" },
50 // no octals: leading zeros are just chopped off
51 { { "00.01.010", 0, 1, 10, nullopt, "" }, "0.1.10" },
52 { { " 0.1.2----suffix ", 0, 1, 2, '-', "---suffix" }, "0.1.2----suffix" },
53 { { "0.1.2- - -x- -y- ", 0, 1, 2, '-', " - -x- -y-" }, "0.1.2- - -x- -y-" },
54 { { "1.11.0.7.0.0.0-SNAPSHOT", 1, 11, 0, '.', "7.0.0.0-SNAPSHOT" }, "1.11.0.7.0.0.0-SNAPSHOT" },
55 };
56
57 for (const auto& test_case : good_test_cases) {
58 const auto& version = test_case.first;
59 const auto& canonical_str = test_case.second;
60 Version v;
61 ASSERT_OK(ParseVersion(version.raw_version, &v));
62 EXPECT_EQ(version, v);
63 EXPECT_EQ(canonical_str, v.ToString());
64 }
65
66 const vector<string> bad_test_cases = {
67 "",
68 " ",
69 "-",
70 " -",
71 "--",
72 " - - ",
73 "..",
74 "0.1",
75 "0.1.",
76 "0.1.+",
77 "+ 0.+ 1.+ 2",
78 "0.1.+-woops",
79 "0.1.2+",
80 "1..1",
81 ".0.1",
82 " . . ",
83 "-0.1.2-013",
84 "0.-1.2-013",
85 "0.1.-2-013",
86 "1000,000.2999,999.999",
87 "1e10.0.1",
88 "1e+10.0.1",
89 "1e-1.0.1",
90 "1E+1.2.3",
91 "1E-5.0.1",
92 "foo",
93 "foo.1.0",
94 "a.b.c",
95 "0.x1.x2",

Callers

nothing calls this directly

Calls 3

ParseVersionFunction · 0.85
ToStringMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected