[Lldb-commits] [lldb] 91f863b - [lldb/Reproducers] Add unittest for char** (de)serializer

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 29 17:16:44 PST 2020


Author: Jonas Devlieghere
Date: 2020-01-29T17:16:31-08:00
New Revision: 91f863be4f04337da19c26c4fbda4ce10bfc0668

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

LOG: [lldb/Reproducers] Add unittest for char** (de)serializer

Added: 
    

Modified: 
    lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
index 4baf9a79330b..e87c49f7bc00 100644
--- a/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
+++ b/lldb/unittests/Utility/ReproducerInstrumentationTest.cpp
@@ -393,6 +393,57 @@ TEST(SerializationRountripTest, SerializeDeserializeCString) {
   EXPECT_STREQ(cstr, deserializer.Deserialize<const char *>());
 }
 
+TEST(SerializationRountripTest, SerializeDeserializeCStringArray) {
+  const char *foo = "foo";
+  const char *bar = "bar";
+  const char *baz = "baz";
+  const char *arr[4] = {foo, bar, baz, nullptr};
+
+  std::string str;
+  llvm::raw_string_ostream os(str);
+
+  Serializer serializer(os);
+  serializer.SerializeAll(static_cast<const char **>(arr));
+
+  llvm::StringRef buffer(os.str());
+  Deserializer deserializer(buffer);
+
+  const char **deserialized = deserializer.Deserialize<const char **>();
+  EXPECT_STREQ("foo", deserialized[0]);
+  EXPECT_STREQ("bar", deserialized[1]);
+  EXPECT_STREQ("baz", deserialized[2]);
+}
+
+TEST(SerializationRountripTest, SerializeDeserializeCStringArrayNullptrElem) {
+  const char *arr[1] = {nullptr};
+
+  std::string str;
+  llvm::raw_string_ostream os(str);
+
+  Serializer serializer(os);
+  serializer.SerializeAll(static_cast<const char **>(arr));
+
+  llvm::StringRef buffer(os.str());
+  Deserializer deserializer(buffer);
+
+  const char **deserialized = deserializer.Deserialize<const char **>();
+  EXPECT_EQ(nullptr, deserialized);
+}
+
+TEST(SerializationRountripTest, SerializeDeserializeCStringArrayNullptr) {
+  std::string str;
+  llvm::raw_string_ostream os(str);
+
+  Serializer serializer(os);
+  serializer.SerializeAll(static_cast<const char **>(nullptr));
+
+  llvm::StringRef buffer(os.str());
+  Deserializer deserializer(buffer);
+
+  const char **deserialized = deserializer.Deserialize<const char **>();
+  EXPECT_EQ(nullptr, deserialized);
+}
+
 TEST(SerializationRountripTest, SerializeDeserializeObjectPointer) {
   Foo foo;
   Bar bar;


        


More information about the lldb-commits mailing list