[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Platform / PlatformMacOSXTest.cpp
blob123fdbc39d672acd3273227d7c0d6a22ece59cb5
1 //===-- PlatformMacOSXTest.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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
12 #include "TestingSupport/SubsystemRAII.h"
13 #include "lldb/Host/FileSystem.h"
14 #include "lldb/Host/HostInfo.h"
15 #include "lldb/Target/Platform.h"
17 using namespace lldb;
18 using namespace lldb_private;
20 class PlatformMacOSXTest : public ::testing::Test {
21 SubsystemRAII<FileSystem, HostInfo, PlatformMacOSX> subsystems;
24 #ifdef __APPLE__
25 static bool containsArch(const std::vector<ArchSpec> &archs,
26 const ArchSpec &arch) {
27 return std::find_if(archs.begin(), archs.end(), [&](const ArchSpec &other) {
28 return arch.IsExactMatch(other);
29 }) != archs.end();
32 TEST_F(PlatformMacOSXTest, TestGetSupportedArchitectures) {
33 PlatformMacOSX platform;
35 const ArchSpec x86_macosx_arch("x86_64-apple-macosx");
37 EXPECT_TRUE(containsArch(platform.GetSupportedArchitectures(x86_macosx_arch),
38 x86_macosx_arch));
39 EXPECT_TRUE(
40 containsArch(platform.GetSupportedArchitectures({}), x86_macosx_arch));
42 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
43 const ArchSpec arm64_macosx_arch("arm64-apple-macosx");
44 const ArchSpec arm64_ios_arch("arm64-apple-ios");
46 EXPECT_TRUE(containsArch(
47 platform.GetSupportedArchitectures(arm64_macosx_arch), arm64_ios_arch));
48 EXPECT_TRUE(
49 containsArch(platform.GetSupportedArchitectures({}), arm64_ios_arch));
50 EXPECT_FALSE(containsArch(platform.GetSupportedArchitectures(arm64_ios_arch),
51 arm64_ios_arch));
52 #endif
54 #endif