OSDN Git Service

[lldb/test] Move "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h"
authorVedant Kumar <vsk@apple.com>
Tue, 19 May 2020 23:06:38 +0000 (16:06 -0700)
committerVedant Kumar <vsk@apple.com>
Tue, 19 May 2020 23:09:42 +0000 (16:09 -0700)
This addresses some post-commit review feedback from
https://reviews.llvm.org/D80150 by renaming "Mock.h" to something less
misleading, and keeping logic related to the ObjC plugin separate from
the generic DataFormatters library.

lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/source/Plugins/Language/ObjC/Utilities.h [moved from lldb/include/lldb/DataFormatters/Mock.h with 73% similarity]
lldb/unittests/DataFormatter/CMakeLists.txt
lldb/unittests/Language/CMakeLists.txt
lldb/unittests/Language/ObjC/CMakeLists.txt [new file with mode: 0644]
lldb/unittests/Language/ObjC/UtilitiesTests.cpp [moved from lldb/unittests/DataFormatter/MockTests.cpp with 84% similarity]

index 37b3522..5128f28 100644 (file)
@@ -8,12 +8,12 @@
 
 #include "Cocoa.h"
 
+#include "Plugins/Language/ObjC/Utilities.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/DataFormatters/Mock.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeSummary.h"
 #include "lldb/Host/Time.h"
similarity index 73%
rename from lldb/include/lldb/DataFormatters/Mock.h
rename to lldb/source/Plugins/Language/ObjC/Utilities.h
index b3fc10c..4cfeb2b 100644 (file)
@@ -1,4 +1,4 @@
-//===-- Mock.h --------------------------------------------------*- C++ -*-===//
+//===-- Utilities.h ---------------------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLDB_DATAFORMATTERS_MOCK_H
-#define LLDB_DATAFORMATTERS_MOCK_H
+#ifndef LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
+#define LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
 
 namespace lldb_private {
 
@@ -23,4 +23,4 @@ bool FormatDateValue(double date_value, Stream &stream);
 } // namespace formatters
 } // namespace lldb_private
 
-#endif // LLDB_DATAFORMATTERS_MOCK_H
+#endif // LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
index 716c8e7..45011c5 100644 (file)
@@ -1,6 +1,5 @@
 add_lldb_unittest(LLDBFormatterTests
   FormatManagerTests.cpp
-  MockTests.cpp
   StringPrinterTests.cpp
 
   LINK_LIBS
index 3a6e5de..51421bd 100644 (file)
@@ -1,2 +1,3 @@
 add_subdirectory(CPlusPlus)
 add_subdirectory(Highlighting)
+add_subdirectory(ObjC)
diff --git a/lldb/unittests/Language/ObjC/CMakeLists.txt b/lldb/unittests/Language/ObjC/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e61ced1
--- /dev/null
@@ -0,0 +1,6 @@
+add_lldb_unittest(LanguageObjCTests
+  UtilitiesTests.cpp
+
+  LINK_LIBS
+    lldbPluginObjCLanguage
+  )
similarity index 84%
rename from lldb/unittests/DataFormatter/MockTests.cpp
rename to lldb/unittests/Language/ObjC/UtilitiesTests.cpp
index f7daaf2..b280609 100644 (file)
@@ -1,4 +1,4 @@
-//===-- MockTests.cpp -----------------------------------------------------===//
+//===-- UtilitiesTests.cpp ------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/DataFormatters/Mock.h"
+#include "Plugins/Language/ObjC/Utilities.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
@@ -25,7 +25,8 @@ static llvm::Optional<std::string> formatDateValue(double date_value) {
 }
 
 TEST(DataFormatterMockTest, NSDate) {
-  EXPECT_EQ(*formatDateValue(-63114076800), "0001-12-30 00:00:00 +0000");
+  EXPECT_EQ(formatDateValue(-63114076800),
+            std::string("0001-12-30 00:00:00 +0000"));
 
   // Can't convert the date_value to a time_t.
   EXPECT_EQ(formatDateValue((double)(std::numeric_limits<time_t>::max()) + 1),
@@ -34,8 +35,10 @@ TEST(DataFormatterMockTest, NSDate) {
             llvm::None);
 
   // Can't add the macOS epoch to the converted date_value (the add overflows).
-  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::max()), llvm::None);
-  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::min()), llvm::None);
+  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::max()),
+            llvm::None);
+  EXPECT_EQ(formatDateValue((double)std::numeric_limits<time_t>::min()),
+            llvm::None);
 
   // FIXME: The formatting result is wrong on Windows because we adjust the
   // epoch when _WIN32 is defined (see GetOSXEpoch).