Remove extra `int main`s from unit tests.
[folly.git] / folly / test / DynamicTest.cpp
index e043d9142a1842aa7b428ad8d3d299ef5f482d73..93034db8339b3b3a954f840b39f13746c5faf890 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
 #include <folly/dynamic.h>
 
 #include <boost/next_prior.hpp>
-#include <gflags/gflags.h>
 #include <gtest/gtest.h>
 
 using folly::dynamic;
@@ -229,12 +228,27 @@ TEST(Dynamic, DeepCopy) {
   EXPECT_EQ(obj2.at("a"), expected);
 }
 
+TEST(Dynamic, ArrayReassignment) {
+  dynamic o = 1;
+
+  // After DR95 the single braces dispatch to the copy constructor.
+  // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1467
+  dynamic d1 = {{o}};
+  EXPECT_EQ(dynamic::ARRAY, d1.type());
+
+  d1 = {o};
+  EXPECT_EQ(dynamic::ARRAY, d1.type());
+}
+
 TEST(Dynamic, Operator) {
   bool caught = false;
   try {
     dynamic d1 = dynamic::object;
     dynamic d2 = dynamic::object;
     auto foo = d1 < d2;
+    LOG(ERROR) << "operator < returned "
+               << static_cast<int>(foo)
+               << " instead of throwing";
   } catch (std::exception const& e) {
     caught = true;
   }
@@ -460,8 +474,8 @@ TEST(Dynamic, Brackets) {
   EXPECT_NE(ds, md["key1"]);
 }
 
-int main(int argc, char** argv) {
-  testing::InitGoogleTest(&argc, argv);
-  gflags::ParseCommandLineFlags(&argc, &argv, true);
-  return RUN_ALL_TESTS();
+TEST(Dynamic, PrintNull) {
+  std::stringstream ss;
+  ss << folly::dynamic(nullptr);
+  EXPECT_EQ("null", ss.str());
 }