1 //===-- TestTypeSystem.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 "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"
17 using namespace lldb_private
;
19 class TestTypeSystemMap
: public testing::Test
{
21 SubsystemRAII
<FileSystem
, HostInfo
> subsystems
;
24 TEST_F(TestTypeSystemMap
, GetTypeSystemForLanguageWithInvalidModule
) {
25 // GetTypeSystemForLanguage called with an invalid Module.
27 Module module
{ModuleSpec()};
29 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, &module
,
31 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
34 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, &module
,
35 /*can_create=*/false),
36 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
39 map
.GetTypeSystemForLanguage(eLanguageTypeC
, &module
,
41 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
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.
51 Module
*module
= nullptr;
53 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, module
,
55 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
58 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, module
,
59 /*can_create=*/false),
60 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
63 map
.GetTypeSystemForLanguage(eLanguageTypeC
, module
, /*can_create=*/true),
64 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
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.
74 Target
*target
= nullptr;
76 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, target
,
78 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
81 map
.GetTypeSystemForLanguage(eLanguageTypeUnknown
, target
,
82 /*can_create=*/false),
83 llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
86 map
.GetTypeSystemForLanguage(eLanguageTypeC
, target
, /*can_create=*/true),
87 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
89 map
.GetTypeSystemForLanguage(eLanguageTypeC
, target
,
90 /*can_create=*/false),
91 llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));