[Lldb-commits] [lldb] e8d955f - [FormatManager] Add a unittest for GetCandidateLanguages()

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 10 13:43:07 PST 2019


Author: Davide Italiano
Date: 2019-12-10T13:42:59-08:00
New Revision: e8d955f29de7ee4b50d889c418b4efb18add0653

URL: https://github.com/llvm/llvm-project/commit/e8d955f29de7ee4b50d889c418b4efb18add0653
DIFF: https://github.com/llvm/llvm-project/commit/e8d955f29de7ee4b50d889c418b4efb18add0653.diff

LOG: [FormatManager] Add a unittest for GetCandidateLanguages()

Reviewers: teemperor, JDevlieghere, aprantl, jingham

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71299

Added: 
    lldb/unittests/DataFormatter/CMakeLists.txt
    lldb/unittests/DataFormatter/FormatManagerTests.cpp

Modified: 
    lldb/unittests/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt
index 22c684f4fce3..bf117030dd4b 100644
--- a/lldb/unittests/CMakeLists.txt
+++ b/lldb/unittests/CMakeLists.txt
@@ -61,6 +61,7 @@ endfunction()
 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
index 000000000000..fc60bff05879
--- /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
index 000000000000..d57454b3f9d1
--- /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<LanguageType> 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);
+}


        


More information about the lldb-commits mailing list