diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt --- a/lldb/unittests/CMakeLists.txt +++ b/lldb/unittests/CMakeLists.txt @@ -61,6 +61,7 @@ add_subdirectory(TestingSupport) add_subdirectory(Breakpoint) add_subdirectory(Core) +add_subdirectory(DataFormatter) add_subdirectory(Disassembler) add_subdirectory(Editline) add_subdirectory(Expression) diff --git a/lldb/unittests/DataFormatter/CMakeLists.txt b/lldb/unittests/DataFormatter/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/lldb/unittests/DataFormatter/CMakeLists.txt @@ -0,0 +1,13 @@ +add_lldb_unittest(LLDBFormatterTests + FormatManagerTests.cpp + + LINK_LIBS + lldbCore + lldbInterpreter + lldbSymbol + lldbTarget + lldbUtility + + LINK_COMPONENTS + Support + ) diff --git a/lldb/unittests/DataFormatter/FormatManagerTests.cpp b/lldb/unittests/DataFormatter/FormatManagerTests.cpp new file mode 100644 --- /dev/null +++ b/lldb/unittests/DataFormatter/FormatManagerTests.cpp @@ -0,0 +1,49 @@ +//===-- FormatManagerTests.cpp ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "TestingSupport/TestUtilities.h" + +#include "lldb/Core/Mangled.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/DataFormatters/FormatManager.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/SymbolContext.h" + +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Testing/Support/Error.h" + +#include "gtest/gtest.h" + +using namespace lldb; +using namespace lldb_private; + +TEST(FormatManagerTests, CompatibleLangs) { + std::vector candidates = {eLanguageTypeC_plus_plus, + eLanguageTypeObjC}; + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC), candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC89), candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC99), candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC11), candidates); + + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus), + candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_03), + candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_11), + candidates); + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeC_plus_plus_14), + candidates); + + candidates = {eLanguageTypeObjC}; + EXPECT_EQ(FormatManager::GetCandidateLanguages(eLanguageTypeObjC), + candidates); +}