diff options
author | Pavel Labath <labath@google.com> | 2018-06-18 15:02:23 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2018-06-18 15:02:23 +0000 |
commit | 5368ebc87be3548597daca304164ef0c7fe38f98 (patch) | |
tree | 14e635c282a51cda894e14c7b2eff9a9ce7fa152 /lldb/unittests/Platform | |
parent | 20137c2ed060758a0e85fdfd1cba7154228090ee (diff) |
Use llvm::VersionTuple instead of manual version marshalling
Summary:
This has multiple advantages:
- we need only one function argument/instance variable instead of three
- no need to default initialize variables
- no custom parsing code
- VersionTuple has comparison operators, which makes version comparisons much
simpler
Reviewers: zturner, friss, clayborg, jingham
Subscribers: emaste, lldb-commits
Differential Revision: https://reviews.llvm.org/D47889
Diffstat (limited to 'lldb/unittests/Platform')
-rw-r--r-- | lldb/unittests/Platform/PlatformDarwinTest.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/lldb/unittests/Platform/PlatformDarwinTest.cpp b/lldb/unittests/Platform/PlatformDarwinTest.cpp index a16e2d99ede..18cd1b76997 100644 --- a/lldb/unittests/Platform/PlatformDarwinTest.cpp +++ b/lldb/unittests/Platform/PlatformDarwinTest.cpp @@ -19,38 +19,29 @@ using namespace lldb; using namespace lldb_private; TEST(PlatformDarwinTest, TestParseVersionBuildDir) { - uint32_t A, B, C; + llvm::VersionTuple V; llvm::StringRef D; - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)"); - EXPECT_EQ(1u, A); - EXPECT_EQ(2u, B); - EXPECT_EQ(3u, C); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)"); + EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); EXPECT_EQ("test1", D); - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)"); - EXPECT_EQ(2u, A); - EXPECT_EQ(3u, B); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)"); + EXPECT_EQ(llvm::VersionTuple(2, 3), V); EXPECT_EQ("test2", D); - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("3 (test3)"); - EXPECT_EQ(3u, A); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3 (test3)"); + EXPECT_EQ(llvm::VersionTuple(3), V); EXPECT_EQ("test3", D); - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test"); - EXPECT_EQ(1u, A); - EXPECT_EQ(2u, B); - EXPECT_EQ(3u, C); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test"); + EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); EXPECT_EQ("test", D); - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test"); - EXPECT_EQ(2u, A); - EXPECT_EQ(3u, B); - EXPECT_EQ(4u, C); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test"); + EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V); EXPECT_EQ("", D); - std::tie(A, B, C, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5"); - EXPECT_EQ(3u, A); - EXPECT_EQ(4u, B); - EXPECT_EQ(5u, C); + std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("3.4.5"); + EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V); } |