1 //===-- PlatformDarwinTest.cpp ----------------------------------*- C++ -*-===//
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
{
21 static bool SDKSupportsModules(SDKType desired_type
,
22 const lldb_private::FileSpec
&sdk_path
) {
23 return PlatformDarwin::SDKSupportsModules(desired_type
, sdk_path
);
27 TEST(PlatformDarwinTest
, TestParseVersionBuildDir
) {
31 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test1)");
32 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V
);
33 EXPECT_EQ("test1", D
);
35 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("2.3 (test2)");
36 EXPECT_EQ(llvm::VersionTuple(2, 3), V
);
37 EXPECT_EQ("test2", D
);
39 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("3 (test3)");
40 EXPECT_EQ(llvm::VersionTuple(3), V
);
41 EXPECT_EQ("test3", D
);
43 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("1.2.3 (test");
44 EXPECT_EQ(llvm::VersionTuple(1, 2, 3), V
);
47 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test");
48 EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V
);
51 std::tie(V
, D
) = PlatformDarwin::ParseVersionBuildDir("3.4.5");
52 EXPECT_EQ(llvm::VersionTuple(3, 4, 5), V
);
54 std::string base
= "/Applications/Xcode.app/Contents/Developer/Platforms/";
55 EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
56 PlatformDarwin::SDKType::iPhoneSimulator
,
59 "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk")));
60 EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
61 PlatformDarwin::SDKType::iPhoneSimulator
,
64 "iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.2.sdk")));
65 EXPECT_TRUE(PlatformDarwinTester::SDKSupportsModules(
66 PlatformDarwin::SDKType::MacOSX
,
67 FileSpec(base
+ "MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk")));
68 EXPECT_FALSE(PlatformDarwinTester::SDKSupportsModules(
69 PlatformDarwin::SDKType::MacOSX
,
70 FileSpec(base
+ "MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk")));