1//===-- CLanguagesTest.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//===----------------------------------------------------------------------===//
8
9#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
10#include "Plugins/Language/ObjC/ObjCLanguage.h"
11#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h"
12#include "TestingSupport/SubsystemRAII.h"
13#include "lldb/lldb-enumerations.h"
14
15#include "gmock/gmock.h"
16#include "gtest/gtest.h"
17
18using namespace lldb_private;
19
20/// Returns the name of the LLDB plugin for the given language or an empty
21/// string if there is no fitting plugin.
22static llvm::StringRef GetPluginName(lldb::LanguageType language) {
23 Language *language_plugin = Language::FindPlugin(language);
24 if (language_plugin)
25 return language_plugin->GetPluginName();
26 return "";
27}
28
29TEST(CLanguages, LookupCLanguagesByLanguageType) {
30 SubsystemRAII<CPlusPlusLanguage, ObjCPlusPlusLanguage, ObjCLanguage> langs;
31
32 // There is no plugin to find for C.
33 EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC), nullptr);
34 EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC89), nullptr);
35 EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC99), nullptr);
36 EXPECT_EQ(Language::FindPlugin(lldb::eLanguageTypeC11), nullptr);
37
38 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus), "cplusplus");
39 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_03), "cplusplus");
40 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_11), "cplusplus");
41 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeC_plus_plus_14), "cplusplus");
42
43 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC), "objc");
44
45 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC_plus_plus), "objcplusplus");
46}
47

source code of lldb/unittests/Language/CLanguages/CLanguagesTest.cpp