/*
- * 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.
#include <folly/dynamic.h>
#include <boost/next_prior.hpp>
-#include <gflags/gflags.h>
#include <gtest/gtest.h>
using folly::dynamic;
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;
}
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());
}