[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Language / CLanguages / CLanguagesTest.cpp
blobacabb8386cd96f52db8b722cea2c3393e62a6a87
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 //===----------------------------------------------------------------------===//
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"
15 #include "gmock/gmock.h"
16 #include "gtest/gtest.h"
18 using namespace lldb_private;
20 /// Returns the name of the LLDB plugin for the given language or an empty
21 /// string if there is no fitting plugin.
22 static llvm::StringRef GetPluginName(lldb::LanguageType language) {
23 Language *language_plugin = Language::FindPlugin(language);
24 if (language_plugin)
25 return language_plugin->GetPluginName();
26 return "";
29 TEST(CLanguages, LookupCLanguagesByLanguageType) {
30 SubsystemRAII<CPlusPlusLanguage, ObjCPlusPlusLanguage, ObjCLanguage> langs;
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);
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");
43 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC), "objc");
45 EXPECT_EQ(GetPluginName(lldb::eLanguageTypeObjC_plus_plus), "objcplusplus");