[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Platform / PlatformDarwinTest.cpp
blob285dc2ee3db783105ce73f2aa4b5902e11218c23
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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "Plugins/Platform/MacOSX/PlatformDarwin.h"
13 #include "llvm/ADT/StringRef.h"
15 #include <tuple>
17 using namespace lldb;
18 using namespace lldb_private;
20 struct PlatformDarwinTester : public PlatformDarwin {
21 public:
22 using PlatformDarwin::FindComponentInPath;
25 TEST(PlatformDarwinTest, TestParseVersionBuildDir) {
26 llvm::VersionTuple V;
27 llvm::StringRef D;
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);
43 EXPECT_EQ("test", D);
45 std::tie(V, D) = PlatformDarwin::ParseVersionBuildDir("2.3.4 test");
46 EXPECT_EQ(llvm::VersionTuple(2, 3, 4), V);
47 EXPECT_EQ("", D);
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"));
66 EXPECT_EQ("",
67 PlatformDarwinTester::FindComponentInPath("/path/to/foo", "bar"));