[RISCV] Make EmitRISCVCpuSupports accept multiple features (#104917)
[llvm-project.git] / lldb / unittests / Symbol / TestTypeSystem.cpp
blob59297a7475d275d026facfc01f78afe029ed82e4
1 //===-- TestTypeSystem.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 "TestingSupport/SubsystemRAII.h"
10 #include "lldb/Core/Module.h"
11 #include "lldb/Host/FileSystem.h"
12 #include "lldb/Host/HostInfo.h"
13 #include "lldb/Symbol/TypeSystem.h"
14 #include "gtest/gtest.h"
16 using namespace lldb;
17 using namespace lldb_private;
19 class TestTypeSystemMap : public testing::Test {
20 public:
21 SubsystemRAII<FileSystem, HostInfo> subsystems;
24 TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithInvalidModule) {
25 // GetTypeSystemForLanguage called with an invalid Module.
26 TypeSystemMap map;
27 Module module{ModuleSpec()};
28 EXPECT_THAT_EXPECTED(
29 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, &module,
30 /*can_create=*/true),
31 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
33 EXPECT_THAT_EXPECTED(
34 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, &module,
35 /*can_create=*/false),
36 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
38 EXPECT_THAT_EXPECTED(
39 map.GetTypeSystemForLanguage(eLanguageTypeC, &module,
40 /*can_create=*/true),
41 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
42 EXPECT_THAT_EXPECTED(
43 map.GetTypeSystemForLanguage(eLanguageTypeC, &module,
44 /*can_create=*/false),
45 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
48 TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithNoModule) {
49 // GetTypeSystemForLanguage called with no Module.
50 TypeSystemMap map;
51 Module *module = nullptr;
52 EXPECT_THAT_EXPECTED(
53 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, module,
54 /*can_create=*/true),
55 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
57 EXPECT_THAT_EXPECTED(
58 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, module,
59 /*can_create=*/false),
60 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
62 EXPECT_THAT_EXPECTED(
63 map.GetTypeSystemForLanguage(eLanguageTypeC, module, /*can_create=*/true),
64 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
65 EXPECT_THAT_EXPECTED(
66 map.GetTypeSystemForLanguage(eLanguageTypeC, module,
67 /*can_create=*/false),
68 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
71 TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithNoTarget) {
72 // GetTypeSystemForLanguage called with no Target.
73 TypeSystemMap map;
74 Target *target = nullptr;
75 EXPECT_THAT_EXPECTED(
76 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, target,
77 /*can_create=*/true),
78 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
80 EXPECT_THAT_EXPECTED(
81 map.GetTypeSystemForLanguage(eLanguageTypeUnknown, target,
82 /*can_create=*/false),
83 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
85 EXPECT_THAT_EXPECTED(
86 map.GetTypeSystemForLanguage(eLanguageTypeC, target, /*can_create=*/true),
87 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
88 EXPECT_THAT_EXPECTED(
89 map.GetTypeSystemForLanguage(eLanguageTypeC, target,
90 /*can_create=*/false),
91 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));