/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2016-present 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/Optional.h>
#include <folly/experimental/DynamicParser.h>
#include <folly/experimental/TestUtil.h>
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
using namespace folly;
-using dynamic = folly::dynamic;
// NB Auto-conversions are exercised by all the tests, there's not a great
// reason to test all of them explicitly, since any uncaught bugs will fail
auto error = ex.error();
const auto& message =
error.at("nested").at("0").at("nested").at("int").at("error");
- EXPECT_PCRE_MATCH(".* conversion to integral.*", message.getString());
+ EXPECT_PCRE_MATCH(".*Invalid leading.*", message.getString());
EXPECT_PCRE_MATCH(
- "DynamicParserParseError: .* conversion to integral.*", ex.what()
+ "DynamicParserParseError: .*Invalid leading.*", ex.what()
);
EXPECT_EQ(dynamic(dynamic::object
("nested", dynamic::object
p.required(4, [&](const dynamic& v) {
EXPECT_EQ(4, p.key().getInt());
EXPECT_EQ(v, p.value());
- p.optional("bools", [&](const std::string& k, const dynamic& v) {
+ p.optional("bools", [&](const std::string& k, const dynamic& v2) {
EXPECT_EQ(std::string("bools"), k);
EXPECT_EQ(k, p.key().getString());
- EXPECT_EQ(v, p.value());
- p.arrayItems([&](int64_t k, bool v) {
+ EXPECT_EQ(v2, p.value());
+ p.arrayItems([&](int64_t k, bool v3) {
EXPECT_EQ(bools.size(), k);
EXPECT_EQ(k, p.key().getInt());
- EXPECT_EQ(v, p.value().asBool());
- bools.push_back(v);
+ EXPECT_EQ(v3, p.value().asBool());
+ bools.push_back(v3);
});
});
});
};
EXPECT_EQ(dynamic(dynamic::object("nested", dynamic::object
("x", get_expected_error_fn("x", "TypeError: .* but had type `array'"))
- ("y", get_expected_error_fn("y", ".* Invalid leading character .*"))
+ ("y", get_expected_error_fn("y", ".*Invalid leading character.*"))
("z", get_expected_error_fn("z", "CUSTOM")))), errors);
}
dynamic::array("this is not a bool"),
[&](DynamicParser& p) { p.arrayItems([&](int64_t, bool) {}); },
0, "0",
- ".* Non-whitespace: .*"
+ ".*Non-whitespace.*"
);
}