1 //===-- PlatformDarwinTest.cpp --------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "Plugins/Platform/MacOSX/PlatformDarwin.h"
13 #include "llvm/ADT/StringRef.h"
18 using namespace lldb_private
;
20 struct PlatformDarwinTester
: public PlatformDarwin
{
22 using PlatformDarwin::FindComponentInPath
;
25 TEST(PlatformDarwinTest
, TestParseVersionBuildDir
) {
29 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)");
30 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V
);
31 EXPECT_EQ("test1", D
);
33 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)");
34 EXPECT_EQ(llvm::VersionTuple(2, 3), V
);
35 EXPECT_EQ("test2", D
);
37 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("3 (test3)");
38 EXPECT_EQ(llvm::VersionTuple(3), V
);
39 EXPECT_EQ("test3", D
);
41 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test");
42 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V
);
45 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test");
46 EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V
);
49 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("3.4.5");
50 EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V
);
53 TEST(PlatformDarwinTest
, FindComponentInPath
) {
54 EXPECT_EQ("/path/to/foo",
55 PlatformDarwinTester::FindComponentInPath("/path/to/foo/", "foo"));
57 EXPECT_EQ("/path/to/foo",
58 PlatformDarwinTester::FindComponentInPath("/path/to/foo", "foo"));
60 EXPECT_EQ("/path/to/foobar", PlatformDarwinTester::FindComponentInPath(
61 "/path/to/foobar", "foo"));
63 EXPECT_EQ("/path/to/foobar", PlatformDarwinTester::FindComponentInPath(
64 "/path/to/foobar", "bar"));
67 PlatformDarwinTester::FindComponentInPath("/path/to/foo", "bar"));