Catch a null schema more gracefully
We were dereferencing the null pointer. It gives a rather cryptic
error. We can do a lot better.
Change-Id: I1aae2109cee6aa9f972d4e149a5779df42ab7d36
diff --git a/aos/json_to_flatbuffer_test.cc b/aos/json_to_flatbuffer_test.cc
index a9112f4..6dbb7ea 100644
--- a/aos/json_to_flatbuffer_test.cc
+++ b/aos/json_to_flatbuffer_test.cc
@@ -231,5 +231,11 @@
EXPECT_EQ("{ \"vector_foo_int\": [ ... 101 elements ... ] }", back_json_long);
}
+// Tests that a nullptr buffer prints nullptr.
+TEST_F(JsonToFlatbufferTest, NullptrData) {
+ EXPECT_EQ("null", TableFlatbufferToJson((const flatbuffers::Table *)(nullptr),
+ ConfigurationTypeTable(), false));
+}
+
} // namespace testing
} // namespace aos