1 | //===-- PlatformDarwinTest.cpp --------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "gtest/gtest.h" |
10 | |
11 | #include "Plugins/Platform/MacOSX/PlatformDarwin.h" |
12 | |
13 | #include "llvm/ADT/StringRef.h" |
14 | |
15 | #include <tuple> |
16 | |
17 | using namespace lldb; |
18 | using namespace lldb_private; |
19 | |
20 | TEST(PlatformDarwinTest, TestParseVersionBuildDir) { |
21 | llvm::VersionTuple V; |
22 | llvm::StringRef D; |
23 | |
24 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "1.2.3 (test1)" ); |
25 | EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); |
26 | EXPECT_EQ("test1" , D); |
27 | |
28 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "2.3 (test2)" ); |
29 | EXPECT_EQ(llvm::VersionTuple(2, 3), V); |
30 | EXPECT_EQ("test2" , D); |
31 | |
32 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "3 (test3)" ); |
33 | EXPECT_EQ(llvm::VersionTuple(3), V); |
34 | EXPECT_EQ("test3" , D); |
35 | |
36 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "1.2.3 (test" ); |
37 | EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V); |
38 | EXPECT_EQ("test" , D); |
39 | |
40 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "2.3.4 test" ); |
41 | EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V); |
42 | EXPECT_EQ("" , D); |
43 | |
44 | std::tie(args&: V, args&: D) = PlatformDarwin::ParseVersionBuildDir(str: "3.4.5" ); |
45 | EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V); |
46 | } |
47 | |