test/hotspot/gtest/utilities/test_json.cpp
author manc
Mon, 14 Oct 2019 18:48:10 -0700
changeset 58652 9b67dd88a931
parent 47765 b7c7428eaab9
permissions -rw-r--r--
8232232: G1RemSetSummary::_rs_threads_vtimes is not initialized to zero Summary: Fix error in "Concurrent refinement threads times" in GC log and cleanup. Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     1
/*
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     4
 *
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     8
 *
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    14
 *
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    18
 *
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    21
 * questions.
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    22
 */
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    23
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    24
#include "precompiled.hpp"
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    25
#include "jvm.h"
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    26
#include "memory/resourceArea.hpp"
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    27
#include "utilities/json.hpp"
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    28
#include "unittest.hpp"
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    29
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    30
class JSON_GTest : public JSON {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    31
 public:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    32
  static void test(const char* json, bool valid);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    33
  char* get_output();
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    34
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    35
 private:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    36
  JSON_GTest(const char* text);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    37
  stringStream output;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    38
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    39
  void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    40
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    41
  bool callback(JSON_TYPE t, JSON_VAL* v, uint level);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    42
  JSON_TYPE prev;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    43
};
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    44
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    45
char* JSON_GTest::get_output() {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    46
  return output.as_string();
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    47
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    48
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    49
void JSON_GTest::test(const char* text, bool should_pass) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    50
  ResourceMark rm;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    51
  JSON_GTest json(text);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    52
  if (should_pass) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    53
    ASSERT_TRUE(json.valid()) << "failed on a valid json string"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    54
            << std::endl << "debug output:" << std::endl << json.get_output();
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    55
  } else {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    56
    ASSERT_FALSE(json.valid()) << "succeeded on an invalid json string"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    57
            << std::endl << "debug output:" << std::endl << json.get_output();
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    58
  }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    59
}
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    60
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    61
JSON_GTest::JSON_GTest(const char* text) : JSON(text, false, &output) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    62
  prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    63
  parse();
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    64
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    65
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    66
TEST_VM(utilities, json_curly_braces) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    67
  JSON_GTest::test("{}", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    68
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    69
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    70
TEST_VM(utilities, json_brackets) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    71
  JSON_GTest::test("[]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    72
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    73
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    74
TEST_VM(utilities, json_space_braces) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    75
  JSON_GTest::test("  {  }  ", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    76
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    77
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    78
TEST_VM(utilities, json_space_bracketes) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    79
  JSON_GTest::test("  [  ]  ", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    80
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    81
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    82
TEST_VM(utilities, json_quoted_error) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    83
  JSON_GTest::test("\"error\"", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    84
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    85
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    86
TEST_VM(utilities, json_error_string) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    87
  JSON_GTest::test("error", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    88
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    89
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    90
TEST_VM(utilities, json_simple_integer) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    91
  JSON_GTest::test("1", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    92
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    93
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    94
TEST_VM(utilities, json_siple_float) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    95
  JSON_GTest::test("1.2", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    96
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
    97
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
    98
TEST_VM(utilities, json_simple_boolean_true) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
    99
  JSON_GTest::test("true", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   100
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   101
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   102
TEST_VM(utilities, json_simple_boolean_false) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   103
  JSON_GTest::test("false", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   104
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   105
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   106
TEST_VM(utilities, json_simple_null) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   107
  JSON_GTest::test("null", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   108
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   109
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   110
TEST_VM(utilities, json_one_element_int_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   111
  JSON_GTest::test("[ 1 ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   112
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   113
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   114
TEST_VM(utilities, json_int_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   115
  JSON_GTest::test("[ 1, ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   116
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   117
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   118
TEST_VM(utilities, json_one_element_bool_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   119
  JSON_GTest::test("[ true ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   120
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   121
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   122
TEST_VM(utilities, json_bool_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   123
  JSON_GTest::test("[ true, ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   124
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   125
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   126
TEST_VM(utilities, json_one_element_false_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   127
  JSON_GTest::test("[ false ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   128
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   129
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   130
TEST_VM(utilities, json_false_bool_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   131
  JSON_GTest::test("[ false, ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   132
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   133
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   134
TEST_VM(utilities, json_one_null_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   135
  JSON_GTest::test("[ null ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   136
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   137
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   138
TEST_VM(utilities, json_null_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   139
  JSON_GTest::test("[ null, ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   140
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   141
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   142
TEST_VM(utilities, json_one_empty_string_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   143
  JSON_GTest::test("[ \"\" ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   144
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   145
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   146
TEST_VM(utilities, json_empty_string_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   147
  JSON_GTest::test("[ \"\", ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   148
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   149
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   150
TEST_VM(utilities, json_single_string_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   151
  JSON_GTest::test("[ \"elem1\" ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   152
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   153
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   154
TEST_VM(utilities, json_string_comma_arrray) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   155
  JSON_GTest::test("[ \"elem1\", ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   156
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   157
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   158
TEST_VM(utilities, json_two_strings_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   159
  JSON_GTest::test("[ \"elem1\", \"elem2\" ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   160
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   161
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   162
TEST_VM(utilities, json_two_strings_comma_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   163
  JSON_GTest::test("[ \"elem1\", \"elem2\", ]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   164
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   165
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   166
TEST_VM(utilities, json_curly_braces_outside) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   167
  JSON_GTest::test("[ \"elem1\" ] { }", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   168
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   169
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   170
TEST_VM(utilities, json_element_in_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   171
  JSON_GTest::test("[ elem1, \"elem2\" ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   172
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   173
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   174
TEST_VM(utilities, json_incorrect_end_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   175
  JSON_GTest::test("[ \"elem1\"", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   176
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   177
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   178
TEST_VM(utilities, json_incorrect_string_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   179
  JSON_GTest::test("[ \"elem1 ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   180
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   181
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   182
TEST_VM(utilities, json_incorrect_end_of_two_elements_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   183
  JSON_GTest::test("[ \"elem1\", \"elem2\"", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   184
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   185
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   186
TEST_VM(utilities, json_incorrect_bool_true_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   187
  JSON_GTest::test("[ truefoo ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   188
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   189
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   190
TEST_VM(utilities, json_incorrect_bool_false_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   191
  JSON_GTest::test("[ falsefoo ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   192
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   193
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   194
TEST_VM(utilities, json_incorrect_null_array) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   195
  JSON_GTest::test("[ nullfoo ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   196
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   197
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   198
TEST_VM(utilities, json_key_pair) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   199
  JSON_GTest::test("{ key : 1 }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   200
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   201
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   202
TEST_VM(utilities, json_key_pair_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   203
  JSON_GTest::test("{ key : 1, }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   204
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   205
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   206
TEST_VM(utilities, json_bool_true_key) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   207
  JSON_GTest::test("{ key : true }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   208
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   209
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   210
TEST_VM(utilities, json_bool_true_key_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   211
  JSON_GTest::test("{ key : true, }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   212
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   213
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   214
TEST_VM(utilities, json_bool_false_key) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   215
  JSON_GTest::test("{ key : false }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   216
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   217
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   218
TEST_VM(utilities, json_bool_false_key_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   219
  JSON_GTest::test("{ key : false, }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   220
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   221
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   222
TEST_VM(utilities, json_null_key) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   223
  JSON_GTest::test("{ key : null }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   224
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   225
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   226
TEST_VM(utilities, json_null_key_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   227
  JSON_GTest::test("{ key : null, }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   228
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   229
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   230
TEST_VM(utilities, json_pair_of_empty_strings) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   231
  JSON_GTest::test("{ \"\" : \"\" }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   232
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   233
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   234
TEST_VM(utilities, json_pair_of_empty_strings_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   235
  JSON_GTest::test("{ \"\" : \"\", }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   236
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   237
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   238
TEST_VM(utilities, json_pair_of_strings) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   239
  JSON_GTest::test("{ \"key1\" : \"val1\" }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   240
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   241
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   242
TEST_VM(utilities, json_pair_of_strings_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   243
  JSON_GTest::test("{ \"key1\" : \"val1\", }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   244
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   245
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   246
TEST_VM(utilities, json_two_pairs_of_strings) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   247
  JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\" }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   248
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   249
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   250
TEST_VM(utilities, json_two_pairs_of_strings_comma) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   251
  JSON_GTest::test("{ \"key1\" : \"val1\", \"key2\" : \"val2\", }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   252
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   253
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   254
TEST_VM(utilities, json_array_outside) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   255
  JSON_GTest::test("{ \"key\" : \"val\" } [ \"error\" ]", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   256
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   257
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   258
TEST_VM(utilities, json_incorrect_object_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   259
  JSON_GTest::test("{ \"key\" : \"val\" ", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   260
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   261
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   262
TEST_VM(utilities, json_empty_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   263
  JSON_GTest::test("/**/ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   264
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   265
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   266
TEST_VM(utilities, json_space_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   267
  JSON_GTest::test("/* */ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   268
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   269
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   270
TEST_VM(utilities, json_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   271
  JSON_GTest::test("/*foo*/ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   272
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   273
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   274
TEST_VM(utilities, json_star_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   275
  JSON_GTest::test("/* *foo */ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   276
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   277
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   278
TEST_VM(utilities, json_stars_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   279
  JSON_GTest::test("/* *foo* */ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   280
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   281
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   282
TEST_VM(utilities, json_special_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   283
  JSON_GTest::test("/* /*foo */ { }", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   284
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   285
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   286
TEST_VM(utilities, json_comment_after) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   287
  JSON_GTest::test("{ } /* foo */", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   288
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   289
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   290
TEST_VM(utilities, json_comment_after_and_space) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   291
  JSON_GTest::test("{ } /* foo */ ", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   292
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   293
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   294
TEST_VM(utilities, json_one_line_empty_comment_after) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   295
  JSON_GTest::test("{ } //", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   296
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   297
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   298
TEST_VM(utilities, json_one_line_space_comment_after) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   299
  JSON_GTest::test("{ } // ", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   300
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   301
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   302
TEST_VM(utilities, json_one_line_comment_after) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   303
  JSON_GTest::test("{ } // foo", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   304
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   305
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   306
TEST_VM(utilities, json_incorrect_multiline_comment) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   307
  JSON_GTest::test("/* * / { }", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   308
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   309
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   310
TEST_VM(utilities, json_incorrect_multiline_comment_begin) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   311
  JSON_GTest::test("/ * */ { }", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   312
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   313
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   314
TEST_VM(utilities, json_oneline_comment_only) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   315
  JSON_GTest::test("// { }", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   316
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   317
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   318
TEST_VM(utilities, json_multiline_comment_only) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   319
  JSON_GTest::test("/* { } */", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   320
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   321
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   322
TEST_VM(utilities, json_multiline_comment_2) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   323
  JSON_GTest::test("/* { } */ ", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   324
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   325
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   326
TEST_VM(utilities, json_incorrectly_commented_object) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   327
  JSON_GTest::test("/* { } ", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   328
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   329
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   330
TEST_VM(utilities, json_missing_multiline_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   331
  JSON_GTest::test("{ } /* ", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   332
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   333
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   334
TEST_VM(utilities, json_missing_multiline_slash) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   335
  JSON_GTest::test("/* { } *", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   336
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   337
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   338
TEST_VM(utilities, json_commented_object_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   339
  JSON_GTest::test("{ /* } */", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   340
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   341
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   342
TEST_VM(utilities, json_commented_array_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   343
  JSON_GTest::test("[ /* ] */", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   344
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   345
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   346
TEST_VM(utilities, json_missing_object_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   347
  JSON_GTest::test("{ key : \"val\", /* } */", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   348
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   349
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   350
TEST_VM(utilities, json_missing_array_end) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   351
  JSON_GTest::test("[ \"val\", /* ] */", false);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   352
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   353
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   354
TEST_VM(utilities, json_key_values_1) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   355
  JSON_GTest::test("/* comment */{ key1 : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   356
          "{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   357
          " : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   358
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   359
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   360
TEST_VM(utilities, json_key_values_2) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   361
  JSON_GTest::test("/* comment */ { \"key1\" : { \"key2\" : { \"key3\" : [ \"elem1\", \"elem2\","
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   362
          "{ \"key4\" : null }, 3 , 2 , 1 , 0 , -1 , -2 , -3 , true, false, null, ] }, \"key5\""
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   363
          " : true }, \"key6\" : [ \"☃\" ], key7 : \"val\",}", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   364
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   365
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   366
TEST_VM(utilities, json_quoted_symbols) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   367
  JSON_GTest::test("/*comment*/{\"ff1 fsd\":{\"☃\":{\"☃\":[\"☃\",\"☃\"]},"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   368
          "\"☃\":true},\"☃\":[\"☃\"],\"foo\":\"☃\",}", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   369
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   370
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   371
TEST_VM(utilities, json_incorrect_key) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   372
  JSON_GTest::test("/* comment */ { key1 error : { \"☃\" : { \"☃\" : [ \"☃\","
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   373
          " \"☃\" ] }, \"☃\" : true }, \"baz\" : [ \"☃\" ], foo : \"☃\",}",
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   374
          false); // first key needs to be quoted since it contains a space
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   375
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   376
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   377
TEST_VM(utilities, json_array_with_newline) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   378
  JSON_GTest::test("[\n]", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   379
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   380
41671
9e0c6db4918a 8166925: several native TESTs should be changed to TEST_VM
iignatyev
parents: 41335
diff changeset
   381
TEST_VM(utilities, json_directives_file) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   382
  JSON_GTest::test(
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   383
          "[" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   384
          "   {"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   385
          "         // pattern to match against class+method+signature" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   386
          "         // leading and trailing wildcard (*) allowed" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   387
          "         match: \"foo.bar.*\"," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   388
          " " "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   389
          "         // override defaults for specified compiler" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   390
          "         // we may differentiate between levels too. TBD." "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   391
          "         c1:  {" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   392
          "           //override c1 presets " "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   393
          "           array_bounds_check_removal: false" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   394
          "         }," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   395
          "" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   396
          "         c2: {" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   397
          "           // control inlining of method" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   398
          "           // + force inline, - dont inline" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   399
          "           inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   400
          "         }," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   401
          "" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   402
          "         // directives outside a specific preset applies to all compilers" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   403
          "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   404
          "         print_assembly: true," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   405
          "         verify_oopmaps: true," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   406
          "         max_loop_unrolling: 5" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   407
          "   }," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   408
          "   {" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   409
          "         // matching several patterns require an array" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   410
          "         match: [\"baz.*\",\"frob*\"]," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   411
          "" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   412
          "         // only enable c1 for this directive" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   413
          "         // all enabled by default. Command disables all not listed" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   414
          "         enable: \"c1\"," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   415
          "" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   416
          "         // applies to all compilers" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   417
          "         // + force inline, - dont inline" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   418
          "         inline : [ \"+java.util.*\", \"-com.sun.*\"]," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   419
          "         print_inlining: true," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   420
          "" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   421
          "         // force matching compiles to be blocking/syncronous" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   422
          "         blocking_compile: true" "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   423
          "   }," "\n"
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   424
          "]" "\n", true);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   425
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   426
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   427
void JSON_GTest::log(uint indent, const char* format, ...) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   428
  if (prev != JSON_KEY) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   429
    for (uint i = 0; i < indent; i++) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   430
      _st->print("  ");
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   431
    }
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   432
  }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   433
  va_list args;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   434
  va_start(args, format);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   435
  _st->vprint(format, args);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   436
  va_end(args);
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   437
}
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   438
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   439
bool JSON_GTest::callback(JSON_TYPE t, JSON_VAL* v, uint rlevel) {
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   440
  switch (t) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   441
    case JSON_OBJECT_BEGIN:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   442
      log(rlevel, "{\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   443
      prev = JSON_NONE; // Only care about JSON_KEY, to indent correctly
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   444
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   445
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   446
    case JSON_OBJECT_END:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   447
      log(rlevel, "},\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   448
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   449
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   450
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   451
    case JSON_ARRAY_BEGIN:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   452
      log(rlevel, "[\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   453
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   454
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   455
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   456
    case JSON_ARRAY_END:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   457
      log(rlevel, "],\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   458
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   459
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   460
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   461
    case JSON_KEY:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   462
      for (uint i = 0; i < rlevel; i++) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   463
        _st->print("  ");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   464
      }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   465
      _st->print("<key>");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   466
      for (size_t i = 0; i < v->str.length; i++) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   467
        u_char c = v->str.start[i];
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   468
        if (c == 0) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   469
          return false;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   470
        }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   471
        _st->print("%c", c);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   472
      }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   473
      _st->print(" : ");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   474
      prev = JSON_KEY;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   475
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   476
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   477
    case JSON_STRING:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   478
      if (prev != JSON_KEY) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   479
        for (uint i = 0; i < rlevel; i++) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   480
          _st->print("  ");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   481
        }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   482
      }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   483
      _st->print("<str>");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   484
      for (size_t i = 0; i < v->str.length; i++) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   485
        u_char c = v->str.start[i];
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   486
        if (c == 0) {
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   487
          return false;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   488
        }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   489
        _st->print("%c", c);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   490
      }
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   491
      _st->print(",\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   492
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   493
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   494
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   495
    case JSON_NUMBER_INT:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   496
      log(rlevel, "<int>%" PRId64 ",\n", v->int_value);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   497
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   498
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   499
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   500
    case JSON_NUMBER_FLOAT:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   501
      log(rlevel, "<double>%lf,\n", v->double_value);
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   502
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   503
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   504
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   505
    case JSON_TRUE:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   506
      log(rlevel, "<true>,\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   507
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   508
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   509
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   510
    case JSON_FALSE:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   511
      log(rlevel, "<false>,\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   512
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   513
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   514
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   515
    case JSON_NULL:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   516
      log(rlevel, "<null>,\n");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   517
      prev = JSON_NONE;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   518
      return true;
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   519
42624
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   520
    default:
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   521
      error(INTERNAL_ERROR, "unknown JSON type");
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   522
      return false;
91e01fe9f1e3 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout
kzhaldyb
parents: 41671
diff changeset
   523
  }
41335
27115e2e42cc 8156852: Convert JSON_test to Gtest
ppunegov
parents:
diff changeset
   524
}