31 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 32 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 33 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 34 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 35 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 36 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 37 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 38 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 39 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 40 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk" 41 "akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk";
44 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 45 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 46 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 47 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 48 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 49 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 50 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 51 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 52 "qwerty \xc2\x80 \xef\xbf\xbf poiuy" 53 "qwerty \xc2\x80 \xef\xbf\xbf poiuy";
56 "<script>foo%@bar.com</script>" 57 "<script>foo%@bar.com</script>" 58 "<script>foo%@bar.com</script>" 59 "<script>foo%@bar.com</script>" 60 "<script>foo%@bar.com</script>" 61 "<script>foo%@bar.com</script>" 62 "<script>foo%@bar.com</script>";
64 TEST(Json, StripComments) {
66 const std::string kTestFile =
"json_test_data/commented.json";
67 const std::string kTestExpected =
"json_test_data/commented.json.exp";
73 FAIL() <<
"can not read test file " << kTestFile;
77 FAIL() <<
"can not read test file " << kTestExpected;
86 for (
size_t i = 0;
i < iters; ++
i) {
91 BENCHMARK(jsonSerializeWithNonAsciiEncoding, iters) {
97 for (
size_t i = 0;
i < iters; ++
i) {
108 for (
size_t i = 0;
i < iters; ++
i) {
113 BENCHMARK(jsonSerializeAsciiWithUtf8Validation, iters) {
119 for (
size_t i = 0;
i < iters; ++
i) {
124 BENCHMARK(jsonSerializeWithExtraUnicodeEscapes, iters) {
131 for (
size_t i = 0;
i < iters; ++
i) {
137 for (
size_t i = 0;
i < iters << 4; ++
i) {
138 parseJson(
"\"I \\u2665 UTF-8 thjasdhkjh blah blah blah\"");
143 for (
size_t i = 0;
i < iters << 4; ++
i) {
144 parseJson(
"\"akjhfk jhkjlakjhfk jhkjlakjhfk jhkjl akjhfk\"");
151 for (
size_t i = 0;
i < iters; ++
i) {
158 "{\"old_value\":40,\"changed\":true,\"opened\":false,\"foo\":[1,2,3,4,5,6]}");
160 for (
size_t i = 0;
i < iters;
i++) {
167 gflags::ParseCommandLineFlags(&argc, &argv,
true);
168 if (FLAGS_benchmark) {
BENCHMARK(jsonSerialize, iters)
bool readFile(int fd, Container &out, size_t num_bytes=std::numeric_limits< size_t >::max())
constexpr folly::StringPiece kLargeAsciiStringWithSpecialChars
dynamic parseJson(StringPiece range)
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
#define EXPECT_EQ(val1, val2)
std::string stripComments(StringPiece jsonC)
int main(int argc, char **argv)
constexpr folly::StringPiece kLargeNonAsciiString
std::array< uint64_t, 2 > buildExtraAsciiToEscapeBitmap(StringPiece chars)
TEST(Json, StripComments)
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
std::array< uint64_t, 2 > extra_ascii_to_escape_bitmap
std::string serialize(dynamic const &dyn, serialization_opts const &opts)
std::string toJson(dynamic const &dyn)
constexpr folly::StringPiece kLargeAsciiString