Stop using ScopeGuardImpl in DynamicParser
[folly.git] / folly / experimental / test / DynamicParserTest.cpp
index e7301c93fdc89cf8a8693cbdf303098ea1be8730..0979ad8b86f40086afcbf6889eb977e049b6bca5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -97,9 +96,9 @@ TEST(TestDynamicParser, OnErrorThrowError) {
     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
@@ -192,15 +191,15 @@ TEST(TestDynamicParser, AllParserFeaturesSuccess) {
   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);
       });
     });
   });
@@ -282,7 +281,7 @@ TEST(TestDynamicParser, TestRequiredOptionalParseErrors) {
   };
   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);
 }
 
@@ -317,7 +316,7 @@ TEST(TestDynamicParser, TestItemParseErrors) {
     dynamic::array("this is not a bool"),
     [&](DynamicParser& p) { p.arrayItems([&](int64_t, bool) {}); },
     0, "0",
-    ".* Non-whitespace: .*"
+    ".*Non-whitespace.*"
   );
 }