rj_schema 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rj_schema/rapidjson/CMakeLists.txt +9 -4
  3. data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +10 -0
  4. data/ext/rj_schema/rapidjson/appveyor.yml +22 -9
  5. data/ext/rj_schema/rapidjson/bin/data/abcde.txt +1 -0
  6. data/ext/rj_schema/rapidjson/bin/unittestschema/address.json +139 -0
  7. data/ext/rj_schema/rapidjson/bin/unittestschema/allOf_address.json +7 -0
  8. data/ext/rj_schema/rapidjson/bin/unittestschema/anyOf_address.json +7 -0
  9. data/ext/rj_schema/rapidjson/bin/unittestschema/oneOf_address.json +7 -0
  10. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +2 -2
  11. data/ext/rj_schema/rapidjson/doc/dom.md +1 -0
  12. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +1 -0
  13. data/ext/rj_schema/rapidjson/doc/faq.md +3 -3
  14. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +8 -8
  15. data/ext/rj_schema/rapidjson/doc/internals.md +1 -1
  16. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +2 -2
  17. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +1 -1
  18. data/ext/rj_schema/rapidjson/doc/sax.md +1 -1
  19. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +2 -2
  20. data/ext/rj_schema/rapidjson/doc/stream.md +1 -1
  21. data/ext/rj_schema/rapidjson/doc/tutorial.md +1 -1
  22. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +7 -6
  23. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +1 -0
  24. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +118 -0
  25. data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
  26. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +1 -1
  27. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +6 -6
  28. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +1 -1
  29. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +124 -35
  30. data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +1 -1
  31. data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +1 -1
  32. data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +49 -1
  33. data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +56 -1
  34. data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +2 -2
  35. data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +1 -1
  36. data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +2 -2
  37. data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +2 -2
  38. data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
  39. data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +3 -17
  40. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +1 -1
  41. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +1 -1
  42. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +1 -1
  43. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +1 -1
  44. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +1 -1
  45. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +20 -13
  46. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +4 -3
  47. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +1 -1
  48. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +1 -1
  49. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +1 -1
  50. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +50 -35
  51. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +1 -1
  52. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +1 -1
  53. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +1 -1
  54. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +63 -5
  55. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +2 -2
  56. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +63 -1
  57. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +67 -53
  58. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +318 -164
  59. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +1 -1
  60. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +1 -1
  61. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +10 -10
  62. data/ext/rj_schema/rapidjson/readme.md +51 -1
  63. data/ext/rj_schema/rapidjson/readme.zh-cn.md +2 -2
  64. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +1 -1
  65. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +1 -1
  66. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +1 -1
  67. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +2 -2
  68. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +75 -1
  69. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +1 -0
  70. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +1 -1
  71. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +1 -1
  72. data/ext/rj_schema/rapidjson/test/unittest/clzlltest.cpp +34 -0
  73. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +19 -19
  74. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +1 -1
  75. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +1 -1
  76. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +1 -1
  77. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +1 -1
  78. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +45 -2
  79. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +1 -1
  80. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +10 -10
  81. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +8 -8
  82. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +1 -1
  83. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +1 -1
  84. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +1 -1
  85. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +157 -16
  86. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +1 -1
  87. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +113 -75
  88. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +2 -1
  89. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +593 -78
  90. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +1 -1
  91. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +1 -1
  92. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +5 -5
  93. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +1 -1
  94. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +1 -1
  95. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +4 -1
  96. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +12 -12
  97. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +1 -1
  98. data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
  99. data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +18 -1
  100. data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
  101. data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
  102. data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
  103. data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +16 -35
  104. data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
  105. data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
  106. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
  107. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
  108. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
  109. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
  110. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
  111. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
  112. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
  113. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
  114. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
  115. data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
  116. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +1 -1
  117. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +72 -32
  118. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +53 -42
  119. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
  120. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
  121. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +4 -4
  122. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +6 -4
  123. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +117 -132
  124. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +7 -4
  125. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +20 -12
  126. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +1 -2
  127. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +83 -26
  128. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +262 -68
  129. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +45 -6
  130. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +650 -366
  131. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +76 -20
  132. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +308 -229
  133. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +18 -15
  134. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +87 -26
  135. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +33 -16
  136. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +1209 -353
  137. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +33 -0
  138. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +159 -88
  139. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +2 -1
  140. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +1 -1
  141. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +3 -4
  142. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +16 -9
  143. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +71 -8
  144. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +7 -11
  145. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +14 -0
  146. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +69 -6
  147. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +2 -2
  148. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +69 -6
  149. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +83 -8
  150. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +14 -0
  151. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +63 -2
  152. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +63 -2
  153. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +76 -3
  154. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +1 -1
  155. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +4 -5
  156. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +3 -3
  157. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +1 -1
  158. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +36 -6
  159. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +210 -135
  160. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +108 -48
  161. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +23 -1
  162. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
  163. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +166 -2
  164. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +1 -1
  165. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +64 -62
  166. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +43 -18
  167. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +11 -9
  168. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +91 -36
  169. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +33 -14
  170. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +1286 -167
  171. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +85 -83
  172. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +102 -15
  173. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +136 -9
  174. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +1 -1
  175. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +1 -1
  176. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +24 -2
  177. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +8 -5
  178. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +20 -1
  179. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +8 -1
  180. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +3 -2
  181. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +44 -2
  182. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +5 -7
  183. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +40 -14
  184. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +60 -31
  185. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +232 -171
  186. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
  187. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
  188. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +54 -16
  189. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +1 -1
  190. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
  191. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +2 -2
  192. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +6 -6
  193. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{AdvancedGuide.md → advanced.md} +260 -26
  194. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{FAQ.md → faq.md} +62 -57
  195. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Primer.md → primer.md} +43 -9
  196. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Samples.md → samples.md} +0 -0
  197. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +53 -5
  198. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +1 -2
  199. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +30 -36
  200. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +8 -17
  201. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +140 -51
  202. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +2 -3
  203. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +4 -3
  204. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +126 -30
  205. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +6 -7
  206. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +8 -5
  207. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +6 -5
  208. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +4 -0
  209. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +13 -57
  210. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +1 -2
  211. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +98 -59
  212. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +34 -41
  213. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +3 -10
  214. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +9 -17
  215. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +8 -1
  216. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +232 -99
  217. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +3 -3
  218. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +17 -1
  219. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +17 -1
  220. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
  221. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
  222. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
  223. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
  224. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
  225. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
  226. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
  227. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
  228. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
  229. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
  230. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
  231. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
  232. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
  233. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
  234. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
  235. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
  236. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
  237. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
  238. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +6 -2
  239. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +1 -1
  240. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +0 -4
  241. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +2 -1
  242. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +2 -1
  243. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +7 -6
  244. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +5 -1
  245. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +3 -3
  246. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +2 -1
  247. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +10 -22
  248. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +2 -1
  249. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +0 -3
  250. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +1 -1
  251. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +10 -10
  252. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1 -1
  253. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +1 -1
  254. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +226 -32
  255. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +5 -7
  256. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +21 -29
  257. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +85 -67
  258. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +93 -8
  259. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +1 -9
  260. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +1 -0
  261. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +622 -164
  262. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +1 -1
  263. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
  264. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +12 -15
  265. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +2 -12
  266. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +1 -1
  267. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +6 -8
  268. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +1 -5
  269. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +84 -29
  270. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +1 -5
  271. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +11 -12
  272. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +165 -63
  273. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +1 -1
  274. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +1 -1
  275. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +1 -1
  276. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +13 -13
  277. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
  278. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +1 -3
  279. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +1 -2
  280. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +0 -2
  281. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +1 -1
  282. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +1 -2
  283. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +0 -8
  284. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +6 -4
  285. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +0 -2
  286. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +0 -3
  287. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +20 -18
  288. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +0 -2
  289. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +1 -1
  290. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
  291. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
  292. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
  293. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +4 -4
  294. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +2 -2
  295. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +11 -7
  296. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +17 -12
  297. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +104 -66
  298. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +1 -1
  299. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +2 -2
  300. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +2 -19
  301. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +0 -6
  302. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +12 -14
  303. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
  304. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
  305. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +1 -1
  306. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +4 -5
  307. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +2 -2
  308. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +240 -149
  309. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +0 -1
  310. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +0 -1
  311. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +15 -7
  312. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +100 -30
  313. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +0 -2
  314. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +25 -23
  315. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +1 -1
  316. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +1 -1
  317. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +4 -4
  318. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +47 -0
  319. data/ext/rj_schema/rapidjson/travis-doxygen.sh +13 -6
  320. data/ext/rj_schema/rj_schema.cpp +161 -17
  321. data/lib/rj_schema.rb +1 -1
  322. metadata +63 -58
  323. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DevGuide.md +0 -132
  324. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CheatSheet.md +0 -525
  325. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CookBook.md +0 -3250
  326. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/Documentation.md +0 -11
  327. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/ForDummies.md +0 -439
  328. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/FrequentlyAskedQuestions.md +0 -624
  329. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CheatSheet.md +0 -534
  330. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CookBook.md +0 -3342
  331. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/Documentation.md +0 -12
  332. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/ForDummies.md +0 -439
  333. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/FrequentlyAskedQuestions.md +0 -628
  334. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CheatSheet.md +0 -556
  335. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CookBook.md +0 -3432
  336. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/Documentation.md +0 -12
  337. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/ForDummies.md +0 -439
  338. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/FrequentlyAskedQuestions.md +0 -628
  339. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/DevGuide.md +0 -126
  340. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Documentation.md +0 -14
  341. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_AdvancedGuide.md +0 -2096
  342. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Documentation.md +0 -12
  343. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_FAQ.md +0 -886
  344. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Primer.md +0 -497
  345. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_PumpManual.md +0 -177
  346. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_XcodeGuide.md +0 -93
  347. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_AdvancedGuide.md +0 -2178
  348. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Documentation.md +0 -14
  349. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_FAQ.md +0 -1038
  350. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Primer.md +0 -501
  351. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_PumpManual.md +0 -177
  352. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Samples.md +0 -14
  353. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_XcodeGuide.md +0 -93
  354. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_AdvancedGuide.md +0 -2181
  355. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Documentation.md +0 -14
  356. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_FAQ.md +0 -1082
  357. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Primer.md +0 -501
  358. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_PumpManual.md +0 -177
  359. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Samples.md +0 -14
  360. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_XcodeGuide.md +0 -93
  361. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.sln +0 -45
  362. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.vcproj +0 -126
  363. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.sln +0 -45
  364. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.vcproj +0 -126
  365. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main-md.vcproj +0 -129
  366. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main.vcproj +0 -129
  367. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test-md.vcproj +0 -164
  368. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test.vcproj +0 -164
  369. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest-md.vcproj +0 -147
  370. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest.vcproj +0 -147
  371. data/ext/rj_schema/rapidjson/thirdparty/gtest/travis.sh +0 -15
@@ -1,6 +1,6 @@
1
1
  // Tencent is pleased to support the open source community by making RapidJSON available.
2
2
  //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
4
  //
5
5
  // Licensed under the MIT License (the "License"); you may not use this file except
6
6
  // in compliance with the License. You may obtain a copy of the License at
@@ -1,6 +1,6 @@
1
1
  // Tencent is pleased to support the open source community by making RapidJSON available.
2
2
  //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
4
  //
5
5
  // Licensed under the MIT License (the "License"); you may not use this file except
6
6
  // in compliance with the License. You may obtain a copy of the License at
@@ -422,7 +422,7 @@ static void TestParseDouble() {
422
422
  "67546703537516986049910576551282076245490090389328944075868508455133942"
423
423
  "30458323690322294816580855933212334827479782620414472316873817718091929"
424
424
  "9881250404026184124858368",
425
- std::numeric_limits<double>::max());
425
+ (std::numeric_limits<double>::max)());
426
426
 
427
427
  TEST_DOUBLE(fullPrecision,
428
428
  "243546080556034731077856379609316893158278902575447060151047"
@@ -649,43 +649,43 @@ static void TestParseNumberError() {
649
649
  for (int i = 1; i < 310; i++)
650
650
  n1e309[i] = '0';
651
651
  n1e309[310] = '\0';
652
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309, 0, 310);
652
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309, 0u, 310u);
653
653
  }
654
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0, 5);
654
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0u, 5u);
655
655
 
656
656
  // Miss fraction part in number.
657
- TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, "1.", 2, 2);
658
- TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, "1.a", 2, 2);
657
+ TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, "1.", 2u, 2u);
658
+ TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, "1.a", 2u, 2u);
659
659
 
660
660
  // Miss exponent in number.
661
- TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e", 2, 2);
662
- TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e_", 2, 2);
661
+ TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e", 2u, 2u);
662
+ TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, "1e_", 2u, 2u);
663
663
 
664
664
  // Issue 849
665
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.8e308", 0, 7);
666
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "5e308", 0, 5);
667
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0, 5);
668
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.0e310", 0, 7);
669
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.00e310", 0, 8);
670
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1.8e308", 0, 8);
671
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1e309", 0, 6);
665
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.8e308", 0u, 7u);
666
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "5e308", 0u, 5u);
667
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e309", 0u, 5u);
668
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.0e310", 0u, 7u);
669
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1.00e310", 0u, 8u);
670
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1.8e308", 0u, 8u);
671
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "-1e309", 0u, 6u);
672
672
 
673
673
  // Issue 1253
674
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "2e308", 0, 5);
674
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "2e308", 0u, 5u);
675
675
 
676
676
  // Issue 1259
677
677
  TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
678
678
  "88474320368547737236837236775298547354737253685475547552933720368546854775297525"
679
679
  "29337203685468547770151233720097201372368547312337203687203685423685123372036872"
680
680
  "03685473724737236837236775297525854775297525472975254737236873720170151235473783"
681
- "7236737247372368772473723683723456789012E66", 0, 283);
681
+ "7236737247372368772473723683723456789012E66", 0u, 283u);
682
682
 
683
683
  #if 0
684
684
  // Test (length + exponent) overflow
685
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+2147483647", 0, 13);
686
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+9223372036854775807", 0, 22);
687
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+10000", 0, 8);
688
- TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+50000", 0, 8);
685
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+2147483647", 0u, 13u);
686
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+9223372036854775807", 0u, 22u);
687
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+10000", 0u, 8u);
688
+ TEST_NUMBER_ERROR(kParseErrorNumberTooBig, "1e+50000", 0u, 8u);
689
689
  #endif
690
690
 
691
691
  // 9007199254740992 * 2^971 ("infinity")
@@ -693,7 +693,7 @@ static void TestParseNumberError() {
693
693
  "1.797693134862315907729305190789024733617976978942306572734300811577326758055009"
694
694
  "63132708477322407536021120113879871393357658789768814416622492847430639474124377"
695
695
  "76789342486548527630221960124609411945308295208500576883815068234246288147391311"
696
- "0540827237163350510684586298239947245938479716304835356329624224137216e+308", 0, 315);
696
+ "0540827237163350510684586298239947245938479716304835356329624224137216e+308", 0u, 315u);
697
697
 
698
698
  // TODO:
699
699
  // These tests (currently) fail in normal-precision mode
@@ -715,7 +715,7 @@ static void TestParseNumberError() {
715
715
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
716
716
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
717
717
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
718
- "00000000000000000000000000000000000000000000000000000000000000000000000000000000e+308", 0, 1125);
718
+ "00000000000000000000000000000000000000000000000000000000000000000000000000000000e+308", 0u, 1125u);
719
719
  // ...round up
720
720
  TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
721
721
  "1.797693134862315807937289714053034150799341327100378269361737789804449682927647"
@@ -732,14 +732,14 @@ static void TestParseNumberError() {
732
732
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
733
733
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
734
734
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
735
- "00000000000000000000000000000000000000000000000000000000000000000000000000000001e+308", 0, 1205);
735
+ "00000000000000000000000000000000000000000000000000000000000000000000000000000001e+308", 0u, 1205u);
736
736
  }
737
737
 
738
738
  TEST_NUMBER_ERROR(kParseErrorNumberTooBig,
739
739
  "10000000000000000000000000000000000000000000000000000000000000000000000000000000"
740
740
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
741
741
  "00000000000000000000000000000000000000000000000000000000000000000000000000000000"
742
- "0000000000000000000000000000000000000000000000000000000000000000000001", 0, 310);
742
+ "0000000000000000000000000000000000000000000000000000000000000000000001", 0u, 310u);
743
743
 
744
744
  #undef TEST_NUMBER_ERROR
745
745
  }
@@ -931,21 +931,24 @@ TEST(Reader, ParseString_Error) {
931
931
  }
932
932
 
933
933
  // Invalid escape character in string.
934
- TEST_STRING_ERROR(kParseErrorStringEscapeInvalid, "[\"\\a\"]", 2, 3);
934
+ TEST_STRING_ERROR(kParseErrorStringEscapeInvalid, "[\"\\a\"]", 2u, 3u);
935
935
 
936
936
  // Incorrect hex digit after \\u escape in string.
937
- TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uABCG\"]", 2, 7);
937
+ TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uABCG\"]", 2u, 7u);
938
938
 
939
939
  // Quotation in \\u escape in string (Issue #288)
940
- TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uaaa\"]", 2, 7);
941
- TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uD800\\uFFF\"]", 2, 13);
940
+ TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uaaa\"]", 2u, 7u);
941
+ TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, "[\"\\uD800\\uFFF\"]", 2u, 13u);
942
942
 
943
943
  // The surrogate pair in string is invalid.
944
- TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, "[\"\\uD800X\"]", 2, 8);
945
- TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, "[\"\\uD800\\uFFFF\"]", 2, 14);
944
+ TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, "[\"\\uD800X\"]", 2u, 8u);
945
+ TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, "[\"\\uD800\\uFFFF\"]", 2u, 14u);
946
+
947
+ // Single low surrogate pair in string is invalid.
948
+ TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, "[\"\\udc4d\"]", 2u, 8u);
946
949
 
947
950
  // Missing a closing quotation mark in string.
948
- TEST_STRING_ERROR(kParseErrorStringMissQuotationMark, "[\"Test]", 7, 7);
951
+ TEST_STRING_ERROR(kParseErrorStringMissQuotationMark, "[\"Test]", 7u, 7u);
949
952
 
950
953
  // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
951
954
 
@@ -968,7 +971,7 @@ TEST(Reader, ParseString_Error) {
968
971
  char e[] = { '[', '\"', 0, ' ', '\"', ']', '\0' };
969
972
  for (unsigned c = 0xC0u; c <= 0xFFu; c++) {
970
973
  e[2] = static_cast<char>(c);
971
- int streamPos;
974
+ unsigned streamPos;
972
975
  if (c <= 0xC1u)
973
976
  streamPos = 3; // 0xC0 - 0xC1
974
977
  else if (c <= 0xDFu)
@@ -979,7 +982,7 @@ TEST(Reader, ParseString_Error) {
979
982
  streamPos = 6; // 0xF0 - 0xF4
980
983
  else
981
984
  streamPos = 3; // 0xF5 - 0xFF
982
- TEST_STRING_ERROR(kParseErrorStringInvalidEncoding, e, 2, streamPos);
985
+ TEST_STRING_ERROR(kParseErrorStringInvalidEncoding, e, 2u, streamPos);
983
986
  }
984
987
  }
985
988
 
@@ -1062,7 +1065,7 @@ TEST(Reader, ParseArray) {
1062
1065
  TEST(Reader, ParseArray_Error) {
1063
1066
  #define TEST_ARRAY_ERROR(errorCode, str, errorOffset) \
1064
1067
  { \
1065
- int streamPos = errorOffset; \
1068
+ unsigned streamPos = errorOffset; \
1066
1069
  char buffer[1001]; \
1067
1070
  strncpy(buffer, str, 1000); \
1068
1071
  InsituStringStream s(buffer); \
@@ -1075,13 +1078,13 @@ TEST(Reader, ParseArray_Error) {
1075
1078
  }
1076
1079
 
1077
1080
  // Missing a comma or ']' after an array element.
1078
- TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1", 2);
1079
- TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1}", 2);
1080
- TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1 2]", 3);
1081
+ TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1", 2u);
1082
+ TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1}", 2u);
1083
+ TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, "[1 2]", 3u);
1081
1084
 
1082
1085
  // Array cannot have a trailing comma (without kParseTrailingCommasFlag);
1083
1086
  // a value must follow a comma
1084
- TEST_ARRAY_ERROR(kParseErrorValueInvalid, "[1,]", 3);
1087
+ TEST_ARRAY_ERROR(kParseErrorValueInvalid, "[1,]", 3u);
1085
1088
 
1086
1089
  #undef TEST_ARRAY_ERROR
1087
1090
  }
@@ -1230,7 +1233,7 @@ TEST(Reader, ParseInsituIterative_MultipleRoot) {
1230
1233
 
1231
1234
  #define TEST_ERROR(errorCode, str, errorOffset) \
1232
1235
  { \
1233
- int streamPos = errorOffset; \
1236
+ unsigned streamPos = errorOffset; \
1234
1237
  char buffer[1001]; \
1235
1238
  strncpy(buffer, str, 1000); \
1236
1239
  InsituStringStream s(buffer); \
@@ -1244,48 +1247,48 @@ TEST(Reader, ParseInsituIterative_MultipleRoot) {
1244
1247
 
1245
1248
  TEST(Reader, ParseDocument_Error) {
1246
1249
  // The document is empty.
1247
- TEST_ERROR(kParseErrorDocumentEmpty, "", 0);
1248
- TEST_ERROR(kParseErrorDocumentEmpty, " ", 1);
1249
- TEST_ERROR(kParseErrorDocumentEmpty, " \n", 2);
1250
+ TEST_ERROR(kParseErrorDocumentEmpty, "", 0u);
1251
+ TEST_ERROR(kParseErrorDocumentEmpty, " ", 1u);
1252
+ TEST_ERROR(kParseErrorDocumentEmpty, " \n", 2u);
1250
1253
 
1251
1254
  // The document root must not follow by other values.
1252
- TEST_ERROR(kParseErrorDocumentRootNotSingular, "[] 0", 3);
1253
- TEST_ERROR(kParseErrorDocumentRootNotSingular, "{} 0", 3);
1254
- TEST_ERROR(kParseErrorDocumentRootNotSingular, "null []", 5);
1255
- TEST_ERROR(kParseErrorDocumentRootNotSingular, "0 {}", 2);
1255
+ TEST_ERROR(kParseErrorDocumentRootNotSingular, "[] 0", 3u);
1256
+ TEST_ERROR(kParseErrorDocumentRootNotSingular, "{} 0", 3u);
1257
+ TEST_ERROR(kParseErrorDocumentRootNotSingular, "null []", 5u);
1258
+ TEST_ERROR(kParseErrorDocumentRootNotSingular, "0 {}", 2u);
1256
1259
  }
1257
1260
 
1258
1261
  TEST(Reader, ParseValue_Error) {
1259
1262
  // Invalid value.
1260
- TEST_ERROR(kParseErrorValueInvalid, "nulL", 3);
1261
- TEST_ERROR(kParseErrorValueInvalid, "truE", 3);
1262
- TEST_ERROR(kParseErrorValueInvalid, "falsE", 4);
1263
- TEST_ERROR(kParseErrorValueInvalid, "a]", 0);
1264
- TEST_ERROR(kParseErrorValueInvalid, ".1", 0);
1263
+ TEST_ERROR(kParseErrorValueInvalid, "nulL", 3u);
1264
+ TEST_ERROR(kParseErrorValueInvalid, "truE", 3u);
1265
+ TEST_ERROR(kParseErrorValueInvalid, "falsE", 4u);
1266
+ TEST_ERROR(kParseErrorValueInvalid, "a]", 0u);
1267
+ TEST_ERROR(kParseErrorValueInvalid, ".1", 0u);
1265
1268
  }
1266
1269
 
1267
1270
  TEST(Reader, ParseObject_Error) {
1268
1271
  // Missing a name for object member.
1269
- TEST_ERROR(kParseErrorObjectMissName, "{1}", 1);
1270
- TEST_ERROR(kParseErrorObjectMissName, "{:1}", 1);
1271
- TEST_ERROR(kParseErrorObjectMissName, "{null:1}", 1);
1272
- TEST_ERROR(kParseErrorObjectMissName, "{true:1}", 1);
1273
- TEST_ERROR(kParseErrorObjectMissName, "{false:1}", 1);
1274
- TEST_ERROR(kParseErrorObjectMissName, "{1:1}", 1);
1275
- TEST_ERROR(kParseErrorObjectMissName, "{[]:1}", 1);
1276
- TEST_ERROR(kParseErrorObjectMissName, "{{}:1}", 1);
1277
- TEST_ERROR(kParseErrorObjectMissName, "{xyz:1}", 1);
1272
+ TEST_ERROR(kParseErrorObjectMissName, "{1}", 1u);
1273
+ TEST_ERROR(kParseErrorObjectMissName, "{:1}", 1u);
1274
+ TEST_ERROR(kParseErrorObjectMissName, "{null:1}", 1u);
1275
+ TEST_ERROR(kParseErrorObjectMissName, "{true:1}", 1u);
1276
+ TEST_ERROR(kParseErrorObjectMissName, "{false:1}", 1u);
1277
+ TEST_ERROR(kParseErrorObjectMissName, "{1:1}", 1u);
1278
+ TEST_ERROR(kParseErrorObjectMissName, "{[]:1}", 1u);
1279
+ TEST_ERROR(kParseErrorObjectMissName, "{{}:1}", 1u);
1280
+ TEST_ERROR(kParseErrorObjectMissName, "{xyz:1}", 1u);
1278
1281
 
1279
1282
  // Missing a colon after a name of object member.
1280
- TEST_ERROR(kParseErrorObjectMissColon, "{\"a\" 1}", 5);
1281
- TEST_ERROR(kParseErrorObjectMissColon, "{\"a\",1}", 4);
1283
+ TEST_ERROR(kParseErrorObjectMissColon, "{\"a\" 1}", 5u);
1284
+ TEST_ERROR(kParseErrorObjectMissColon, "{\"a\",1}", 4u);
1282
1285
 
1283
1286
  // Must be a comma or '}' after an object member
1284
- TEST_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, "{\"a\":1]", 6);
1287
+ TEST_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, "{\"a\":1]", 6u);
1285
1288
 
1286
1289
  // Object cannot have a trailing comma (without kParseTrailingCommasFlag);
1287
1290
  // an object member name must follow a comma
1288
- TEST_ERROR(kParseErrorObjectMissName, "{\"a\":1,}", 7);
1291
+ TEST_ERROR(kParseErrorObjectMissName, "{\"a\":1,}", 7u);
1289
1292
 
1290
1293
  // This tests that MemoryStream is checking the length in Peek().
1291
1294
  {
@@ -1405,7 +1408,7 @@ TEST(Reader, Parse_IStreamWrapper_StringStream) {
1405
1408
 
1406
1409
  #define TESTERRORHANDLING(text, errorCode, offset)\
1407
1410
  {\
1408
- int streamPos = offset; \
1411
+ unsigned streamPos = offset; \
1409
1412
  StringStream json(text); \
1410
1413
  BaseReaderHandler<> handler; \
1411
1414
  Reader reader; \
@@ -1975,6 +1978,17 @@ TEST(Reader, NumbersAsStrings) {
1975
1978
  Reader reader;
1976
1979
  EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));
1977
1980
  }
1981
+ {
1982
+ char n1e319[321]; // '1' followed by 319 '0'
1983
+ n1e319[0] = '1';
1984
+ for (int i = 1; i < 320; i++)
1985
+ n1e319[i] = '0';
1986
+ n1e319[320] = '\0';
1987
+ StringStream s(n1e319);
1988
+ NumbersAsStringsHandler h(n1e319);
1989
+ Reader reader;
1990
+ EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));
1991
+ }
1978
1992
  }
1979
1993
 
1980
1994
  template <unsigned extraFlags>
@@ -2153,7 +2167,7 @@ TEST(Reader, ParseNanAndInfinity) {
2153
2167
  }
2154
2168
  #define TEST_NAN_INF_ERROR(errorCode, str, errorOffset) \
2155
2169
  { \
2156
- int streamPos = errorOffset; \
2170
+ unsigned streamPos = errorOffset; \
2157
2171
  char buffer[1001]; \
2158
2172
  strncpy(buffer, str, 1000); \
2159
2173
  InsituStringStream s(buffer); \
@@ -2174,17 +2188,41 @@ TEST(Reader, ParseNanAndInfinity) {
2174
2188
  TEST_NAN_INF("Infinity", inf);
2175
2189
  TEST_NAN_INF("-Inf", -inf);
2176
2190
  TEST_NAN_INF("-Infinity", -inf);
2177
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NInf", 1);
2178
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NaInf", 2);
2179
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "INan", 1);
2180
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "InNan", 2);
2181
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "nan", 1);
2182
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "-nan", 1);
2183
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NAN", 1);
2184
- TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "-Infinty", 6);
2191
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NInf", 1u);
2192
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NaInf", 2u);
2193
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "INan", 1u);
2194
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "InNan", 2u);
2195
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "nan", 1u);
2196
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "-nan", 1u);
2197
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "NAN", 1u);
2198
+ TEST_NAN_INF_ERROR(kParseErrorValueInvalid, "-Infinty", 6u);
2185
2199
 
2186
2200
  #undef TEST_NAN_INF_ERROR
2187
2201
  #undef TEST_NAN_INF
2188
2202
  }
2189
2203
 
2204
+ TEST(Reader, EscapedApostrophe) {
2205
+ const char json[] = " { \"foo\": \"bar\\'buzz\" } ";
2206
+
2207
+ BaseReaderHandler<> h;
2208
+
2209
+ {
2210
+ StringStream s(json);
2211
+ Reader reader;
2212
+ ParseResult r = reader.Parse<kParseNoFlags>(s, h);
2213
+ EXPECT_TRUE(reader.HasParseError());
2214
+ EXPECT_EQ(kParseErrorStringEscapeInvalid, r.Code());
2215
+ EXPECT_EQ(14u, r.Offset());
2216
+ }
2217
+
2218
+ {
2219
+ StringStream s(json);
2220
+ Reader reader;
2221
+ ParseResult r = reader.Parse<kParseEscapedApostropheFlag>(s, h);
2222
+ EXPECT_FALSE(reader.HasParseError());
2223
+ EXPECT_EQ(kParseErrorNone, r.Code());
2224
+ EXPECT_EQ(0u, r.Offset());
2225
+ }
2226
+ }
2227
+
2190
2228
  RAPIDJSON_DIAG_POP
@@ -1,6 +1,6 @@
1
1
  // Tencent is pleased to support the open source community by making RapidJSON available.
2
2
  //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
4
  //
5
5
  // Licensed under the MIT License (the "License"); you may not use this file except
6
6
  // in compliance with the License. You may obtain a copy of the License at
@@ -595,6 +595,7 @@ TEST(Regex, Invalid) {
595
595
  TEST_INVALID("");
596
596
  TEST_INVALID("a|");
597
597
  TEST_INVALID("()");
598
+ TEST_INVALID("(");
598
599
  TEST_INVALID(")");
599
600
  TEST_INVALID("(a))");
600
601
  TEST_INVALID("(a|)");
@@ -1,6 +1,6 @@
1
1
  // Tencent is pleased to support the open source community by making RapidJSON available.
2
2
  //
3
- // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
4
  //
5
5
  // Licensed under the MIT License (the "License"); you may not use this file except
6
6
  // in compliance with the License. You may obtain a copy of the License at
@@ -12,10 +12,14 @@
12
12
  // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
13
  // specific language governing permissions and limitations under the License.
14
14
 
15
+ #define RAPIDJSON_SCHEMA_VERBOSE 0
16
+
15
17
  #include "unittest.h"
16
18
  #include "rapidjson/schema.h"
17
19
  #include "rapidjson/stringbuffer.h"
18
20
  #include "rapidjson/writer.h"
21
+ #include "rapidjson/error/error.h"
22
+ #include "rapidjson/error/en.h"
19
23
 
20
24
  #ifdef __clang__
21
25
  RAPIDJSON_DIAG_PUSH
@@ -114,11 +118,18 @@ TEST(SchemaValidator, Hasher) {
114
118
  EXPECT_FALSE(d.HasParseError());\
115
119
  EXPECT_TRUE(expected == d.Accept(validator));\
116
120
  EXPECT_TRUE(expected == validator.IsValid());\
121
+ ValidateErrorCode code = validator.GetInvalidSchemaCode();\
122
+ if (expected) {\
123
+ EXPECT_TRUE(code == kValidateErrorNone);\
124
+ EXPECT_TRUE(validator.GetInvalidSchemaKeyword() == 0);\
125
+ }\
117
126
  if ((expected) && !validator.IsValid()) {\
118
127
  StringBuffer sb;\
119
128
  validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\
120
129
  printf("Invalid schema: %s\n", sb.GetString());\
121
130
  printf("Invalid keyword: %s\n", validator.GetInvalidSchemaKeyword());\
131
+ printf("Invalid code: %d\n", code);\
132
+ printf("Invalid message: %s\n", GetValidateError_En(code));\
122
133
  sb.Clear();\
123
134
  validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\
124
135
  printf("Invalid document: %s\n", sb.GetString());\
@@ -131,19 +142,23 @@ TEST(SchemaValidator, Hasher) {
131
142
 
132
143
  #define INVALIDATE(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer, error) \
133
144
  {\
134
- INVALIDATE_(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer, error, SchemaValidator, Pointer) \
145
+ INVALIDATE_(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer, error, kValidateDefaultFlags, SchemaValidator, Pointer) \
135
146
  }
136
147
 
137
148
  #define INVALIDATE_(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer, error, \
138
- SchemaValidatorType, PointerType) \
149
+ flags, SchemaValidatorType, PointerType) \
139
150
  {\
140
151
  SchemaValidatorType validator(schema);\
152
+ validator.SetValidateFlags(flags);\
141
153
  Document d;\
142
154
  /*printf("\n%s\n", json);*/\
143
155
  d.Parse(json);\
144
156
  EXPECT_FALSE(d.HasParseError());\
145
- EXPECT_FALSE(d.Accept(validator));\
157
+ d.Accept(validator);\
146
158
  EXPECT_FALSE(validator.IsValid());\
159
+ ValidateErrorCode code = validator.GetInvalidSchemaCode();\
160
+ ASSERT_TRUE(code != kValidateErrorNone);\
161
+ ASSERT_TRUE(strcmp(GetValidateError_En(code), "Unknown error.") != 0);\
147
162
  if (validator.GetInvalidSchemaPointer() != PointerType(invalidSchemaPointer)) {\
148
163
  StringBuffer sb;\
149
164
  validator.GetInvalidSchemaPointer().Stringify(sb);\
@@ -191,6 +206,7 @@ TEST(SchemaValidator, MultiType) {
191
206
  VALIDATE(s, "\"Life, the universe, and everything\"", true);
192
207
  INVALIDATE(s, "[\"Life\", \"the universe\", \"and everything\"]", "", "type", "",
193
208
  "{ \"type\": {"
209
+ " \"errorCode\": 20,"
194
210
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
195
211
  " \"expected\": [\"string\", \"number\"], \"actual\": \"array\""
196
212
  "}}");
@@ -203,7 +219,7 @@ TEST(SchemaValidator, Enum_Typed) {
203
219
 
204
220
  VALIDATE(s, "\"red\"", true);
205
221
  INVALIDATE(s, "\"blue\"", "", "enum", "",
206
- "{ \"enum\": { \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
222
+ "{ \"enum\": { \"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
207
223
  }
208
224
 
209
225
  TEST(SchemaValidator, Enum_Typless) {
@@ -215,7 +231,7 @@ TEST(SchemaValidator, Enum_Typless) {
215
231
  VALIDATE(s, "null", true);
216
232
  VALIDATE(s, "42", true);
217
233
  INVALIDATE(s, "0", "", "enum", "",
218
- "{ \"enum\": { \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
234
+ "{ \"enum\": { \"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
219
235
  }
220
236
 
221
237
  TEST(SchemaValidator, Enum_InvalidType) {
@@ -226,6 +242,7 @@ TEST(SchemaValidator, Enum_InvalidType) {
226
242
  VALIDATE(s, "\"red\"", true);
227
243
  INVALIDATE(s, "null", "", "type", "",
228
244
  "{ \"type\": {"
245
+ " \"errorCode\": 20,"
229
246
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
230
247
  " \"expected\": [\"string\"], \"actual\": \"null\""
231
248
  "}}");
@@ -239,9 +256,12 @@ TEST(SchemaValidator, AllOf) {
239
256
 
240
257
  VALIDATE(s, "\"ok\"", true);
241
258
  INVALIDATE(s, "\"too long\"", "", "allOf", "",
242
- "{ \"maxLength\": { "
243
- " \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\", "
244
- " \"expected\": 5, \"actual\": \"too long\""
259
+ "{ \"allOf\": {"
260
+ " \"errors\": ["
261
+ " {},"
262
+ " {\"maxLength\": {\"errorCode\": 6, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\", \"expected\": 5, \"actual\": \"too long\"}}"
263
+ " ],"
264
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
245
265
  "}}");
246
266
  }
247
267
  {
@@ -251,8 +271,12 @@ TEST(SchemaValidator, AllOf) {
251
271
 
252
272
  VALIDATE(s, "\"No way\"", false);
253
273
  INVALIDATE(s, "-1", "", "allOf", "",
254
- "{ \"type\": { \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\","
255
- " \"expected\": [\"string\"], \"actual\": \"integer\""
274
+ "{ \"allOf\": {"
275
+ " \"errors\": ["
276
+ " {\"type\": { \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\", \"errorCode\": 20, \"expected\": [\"string\"], \"actual\": \"integer\"}},"
277
+ " {}"
278
+ " ],"
279
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
256
280
  "}}");
257
281
  }
258
282
  }
@@ -266,13 +290,16 @@ TEST(SchemaValidator, AnyOf) {
266
290
  VALIDATE(s, "42", true);
267
291
  INVALIDATE(s, "{ \"Not a\": \"string or number\" }", "", "anyOf", "",
268
292
  "{ \"anyOf\": {"
293
+ " \"errorCode\": 24,"
269
294
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\", "
270
295
  " \"errors\": ["
271
296
  " { \"type\": {"
297
+ " \"errorCode\": 20,"
272
298
  " \"instanceRef\": \"#\", \"schemaRef\": \"#/anyOf/0\","
273
299
  " \"expected\": [\"string\"], \"actual\": \"object\""
274
300
  " }},"
275
301
  " { \"type\": {"
302
+ " \"errorCode\": 20,"
276
303
  " \"instanceRef\": \"#\", \"schemaRef\": \"#/anyOf/1\","
277
304
  " \"expected\": [\"number\"], \"actual\": \"object\""
278
305
  " }}"
@@ -289,20 +316,23 @@ TEST(SchemaValidator, OneOf) {
289
316
  VALIDATE(s, "9", true);
290
317
  INVALIDATE(s, "2", "", "oneOf", "",
291
318
  "{ \"oneOf\": {"
319
+ " \"errorCode\": 21,"
292
320
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
293
321
  " \"errors\": ["
294
322
  " { \"multipleOf\": {"
323
+ " \"errorCode\": 1,"
295
324
  " \"instanceRef\": \"#\", \"schemaRef\": \"#/oneOf/0\","
296
325
  " \"expected\": 5, \"actual\": 2"
297
326
  " }},"
298
327
  " { \"multipleOf\": {"
328
+ " \"errorCode\": 1,"
299
329
  " \"instanceRef\": \"#\", \"schemaRef\": \"#/oneOf/1\","
300
330
  " \"expected\": 3, \"actual\": 2"
301
331
  " }}"
302
332
  " ]"
303
333
  "}}");
304
334
  INVALIDATE(s, "15", "", "oneOf", "",
305
- "{ \"oneOf\": { \"instanceRef\": \"#\", \"schemaRef\": \"#\", \"errors\": [{}, {}]}}");
335
+ "{ \"oneOf\": { \"errorCode\": 22, \"instanceRef\": \"#\", \"schemaRef\": \"#\", \"errors\": [{}, {}]}}");
306
336
  }
307
337
 
308
338
  TEST(SchemaValidator, Not) {
@@ -313,7 +343,7 @@ TEST(SchemaValidator, Not) {
313
343
  VALIDATE(s, "42", true);
314
344
  VALIDATE(s, "{ \"key\": \"value\" }", true);
315
345
  INVALIDATE(s, "\"I am a string\"", "", "not", "",
316
- "{ \"not\": { \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
346
+ "{ \"not\": { \"errorCode\": 25, \"instanceRef\": \"#\", \"schemaRef\": \"#\" }}");
317
347
  }
318
348
 
319
349
  TEST(SchemaValidator, Ref) {
@@ -378,10 +408,12 @@ TEST(SchemaValidator, Ref_AllOf) {
378
408
  SchemaDocument s(sd);
379
409
 
380
410
  INVALIDATE(s, "{\"shipping_address\": {\"street_address\": \"1600 Pennsylvania Avenue NW\", \"city\": \"Washington\", \"state\": \"DC\"} }", "/properties/shipping_address", "allOf", "/shipping_address",
381
- "{ \"required\": {"
382
- " \"instanceRef\": \"#/shipping_address\","
383
- " \"schemaRef\": \"#/properties/shipping_address/allOf/1\","
384
- " \"missing\": [\"type\"]"
411
+ "{ \"allOf\": {"
412
+ " \"errors\": ["
413
+ " {},"
414
+ " {\"required\": {\"errorCode\": 15, \"instanceRef\": \"#/shipping_address\", \"schemaRef\": \"#/properties/shipping_address/allOf/1\", \"missing\": [\"type\"]}}"
415
+ " ],"
416
+ " \"errorCode\":23,\"instanceRef\":\"#/shipping_address\",\"schemaRef\":\"#/properties/shipping_address\""
385
417
  "}}");
386
418
  VALIDATE(s, "{\"shipping_address\": {\"street_address\": \"1600 Pennsylvania Avenue NW\", \"city\": \"Washington\", \"state\": \"DC\", \"type\": \"business\"} }", true);
387
419
  }
@@ -394,26 +426,31 @@ TEST(SchemaValidator, String) {
394
426
  VALIDATE(s, "\"I'm a string\"", true);
395
427
  INVALIDATE(s, "42", "", "type", "",
396
428
  "{ \"type\": {"
429
+ " \"errorCode\": 20,"
397
430
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
398
431
  " \"expected\": [\"string\"], \"actual\": \"integer\""
399
432
  "}}");
400
433
  INVALIDATE(s, "2147483648", "", "type", "",
401
434
  "{ \"type\": {"
435
+ " \"errorCode\": 20,"
402
436
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
403
437
  " \"expected\": [\"string\"], \"actual\": \"integer\""
404
438
  "}}"); // 2^31 can only be fit in unsigned
405
439
  INVALIDATE(s, "-2147483649", "", "type", "",
406
440
  "{ \"type\": {"
441
+ " \"errorCode\": 20,"
407
442
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
408
443
  " \"expected\": [\"string\"], \"actual\": \"integer\""
409
444
  "}}"); // -2^31 - 1 can only be fit in int64_t
410
445
  INVALIDATE(s, "4294967296", "", "type", "",
411
446
  "{ \"type\": {"
447
+ " \"errorCode\": 20,"
412
448
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
413
449
  " \"expected\": [\"string\"], \"actual\": \"integer\""
414
450
  "}}"); // 2^32 can only be fit in int64_t
415
451
  INVALIDATE(s, "3.1415926", "", "type", "",
416
452
  "{ \"type\": {"
453
+ " \"errorCode\": 20,"
417
454
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
418
455
  " \"expected\": [\"string\"], \"actual\": \"number\""
419
456
  "}}");
@@ -426,6 +463,7 @@ TEST(SchemaValidator, String_LengthRange) {
426
463
 
427
464
  INVALIDATE(s, "\"A\"", "", "minLength", "",
428
465
  "{ \"minLength\": {"
466
+ " \"errorCode\": 7,"
429
467
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
430
468
  " \"expected\": 2, \"actual\": \"A\""
431
469
  "}}");
@@ -433,6 +471,7 @@ TEST(SchemaValidator, String_LengthRange) {
433
471
  VALIDATE(s, "\"ABC\"", true);
434
472
  INVALIDATE(s, "\"ABCD\"", "", "maxLength", "",
435
473
  "{ \"maxLength\": {"
474
+ " \"errorCode\": 6,"
436
475
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
437
476
  " \"expected\": 3, \"actual\": \"ABCD\""
438
477
  "}}");
@@ -448,11 +487,13 @@ TEST(SchemaValidator, String_Pattern) {
448
487
  VALIDATE(s, "\"(888)555-1212\"", true);
449
488
  INVALIDATE(s, "\"(888)555-1212 ext. 532\"", "", "pattern", "",
450
489
  "{ \"pattern\": {"
490
+ " \"errorCode\": 8,"
451
491
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
452
492
  " \"actual\": \"(888)555-1212 ext. 532\""
453
493
  "}}");
454
494
  INVALIDATE(s, "\"(800)FLOWERS\"", "", "pattern", "",
455
495
  "{ \"pattern\": {"
496
+ " \"errorCode\": 8,"
456
497
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
457
498
  " \"actual\": \"(800)FLOWERS\""
458
499
  "}}");
@@ -482,11 +523,13 @@ TEST(SchemaValidator, Integer) {
482
523
  VALIDATE(s, "4294967296", true); // 2^32 can only be fit in int64_t
483
524
  INVALIDATE(s, "3.1415926", "", "type", "",
484
525
  "{ \"type\": {"
526
+ " \"errorCode\": 20,"
485
527
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
486
528
  " \"expected\": [\"integer\"], \"actual\": \"number\""
487
529
  "}}");
488
530
  INVALIDATE(s, "\"42\"", "", "type", "",
489
531
  "{ \"type\": {"
532
+ " \"errorCode\": 20,"
490
533
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
491
534
  " \"expected\": [\"integer\"], \"actual\": \"string\""
492
535
  "}}");
@@ -499,6 +542,7 @@ TEST(SchemaValidator, Integer_Range) {
499
542
 
500
543
  INVALIDATE(s, "-1", "", "minimum", "",
501
544
  "{ \"minimum\": {"
545
+ " \"errorCode\": 4,"
502
546
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
503
547
  " \"expected\": 0, \"actual\": -1"
504
548
  "}}");
@@ -507,11 +551,13 @@ TEST(SchemaValidator, Integer_Range) {
507
551
  VALIDATE(s, "99", true);
508
552
  INVALIDATE(s, "100", "", "maximum", "",
509
553
  "{ \"maximum\": {"
554
+ " \"errorCode\": 3,"
510
555
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
511
556
  " \"expected\": 100, \"exclusiveMaximum\": true, \"actual\": 100"
512
557
  "}}");
513
558
  INVALIDATE(s, "101", "", "maximum", "",
514
559
  "{ \"maximum\": {"
560
+ " \"errorCode\": 3,"
515
561
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
516
562
  " \"expected\": 100, \"exclusiveMaximum\": true, \"actual\": 101"
517
563
  "}}");
@@ -524,6 +570,7 @@ TEST(SchemaValidator, Integer_Range64Boundary) {
524
570
 
525
571
  INVALIDATE(s, "-9223372036854775808", "", "minimum", "",
526
572
  "{ \"minimum\": {"
573
+ " \"errorCode\": 4,"
527
574
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
528
575
  " \"expected\": -9223372036854775807, \"actual\": -9223372036854775808"
529
576
  "}}");
@@ -536,11 +583,13 @@ TEST(SchemaValidator, Integer_Range64Boundary) {
536
583
  VALIDATE(s, "9223372036854775806", true);
537
584
  INVALIDATE(s, "9223372036854775807", "", "maximum", "",
538
585
  "{ \"maximum\": {"
586
+ " \"errorCode\": 2,"
539
587
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
540
588
  " \"expected\": 9223372036854775806, \"actual\": 9223372036854775807"
541
589
  "}}");
542
590
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
543
591
  "{ \"maximum\": {"
592
+ " \"errorCode\": 2,"
544
593
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
545
594
  " \"expected\": 9223372036854775806, \"actual\": 18446744073709551615"
546
595
  "}}"); // uint64_t max
@@ -553,36 +602,43 @@ TEST(SchemaValidator, Integer_RangeU64Boundary) {
553
602
 
554
603
  INVALIDATE(s, "-9223372036854775808", "", "minimum", "",
555
604
  "{ \"minimum\": {"
605
+ " \"errorCode\": 4,"
556
606
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
557
607
  " \"expected\": 9223372036854775808, \"actual\": -9223372036854775808"
558
608
  "}}");
559
609
  INVALIDATE(s, "9223372036854775807", "", "minimum", "",
560
610
  "{ \"minimum\": {"
611
+ " \"errorCode\": 4,"
561
612
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
562
613
  " \"expected\": 9223372036854775808, \"actual\": 9223372036854775807"
563
614
  "}}");
564
615
  INVALIDATE(s, "-2147483648", "", "minimum", "",
565
616
  "{ \"minimum\": {"
617
+ " \"errorCode\": 4,"
566
618
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
567
619
  " \"expected\": 9223372036854775808, \"actual\": -2147483648"
568
620
  "}}"); // int min
569
621
  INVALIDATE(s, "0", "", "minimum", "",
570
622
  "{ \"minimum\": {"
623
+ " \"errorCode\": 4,"
571
624
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
572
625
  " \"expected\": 9223372036854775808, \"actual\": 0"
573
626
  "}}");
574
627
  INVALIDATE(s, "2147483647", "", "minimum", "",
575
628
  "{ \"minimum\": {"
629
+ " \"errorCode\": 4,"
576
630
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
577
631
  " \"expected\": 9223372036854775808, \"actual\": 2147483647"
578
632
  "}}"); // int max
579
633
  INVALIDATE(s, "2147483648", "", "minimum", "",
580
634
  "{ \"minimum\": {"
635
+ " \"errorCode\": 4,"
581
636
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
582
637
  " \"expected\": 9223372036854775808, \"actual\": 2147483648"
583
638
  "}}"); // unsigned first
584
639
  INVALIDATE(s, "4294967295", "", "minimum", "",
585
640
  "{ \"minimum\": {"
641
+ " \"errorCode\": 4,"
586
642
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
587
643
  " \"expected\": 9223372036854775808, \"actual\": 4294967295"
588
644
  "}}"); // unsigned max
@@ -590,6 +646,7 @@ TEST(SchemaValidator, Integer_RangeU64Boundary) {
590
646
  VALIDATE(s, "18446744073709551614", true);
591
647
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
592
648
  "{ \"maximum\": {"
649
+ " \"errorCode\": 2,"
593
650
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
594
651
  " \"expected\": 18446744073709551614, \"actual\": 18446744073709551615"
595
652
  "}}");
@@ -602,6 +659,7 @@ TEST(SchemaValidator, Integer_Range64BoundaryExclusive) {
602
659
 
603
660
  INVALIDATE(s, "-9223372036854775808", "", "minimum", "",
604
661
  "{ \"minimum\": {"
662
+ " \"errorCode\": 5,"
605
663
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
606
664
  " \"expected\": -9223372036854775808, \"exclusiveMinimum\": true, "
607
665
  " \"actual\": -9223372036854775808"
@@ -610,6 +668,7 @@ TEST(SchemaValidator, Integer_Range64BoundaryExclusive) {
610
668
  VALIDATE(s, "18446744073709551614", true);
611
669
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
612
670
  "{ \"maximum\": {"
671
+ " \"errorCode\": 3,"
613
672
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
614
673
  " \"expected\": 18446744073709551615, \"exclusiveMaximum\": true, "
615
674
  " \"actual\": 18446744073709551615"
@@ -627,11 +686,13 @@ TEST(SchemaValidator, Integer_MultipleOf) {
627
686
  VALIDATE(s, "20", true);
628
687
  INVALIDATE(s, "23", "", "multipleOf", "",
629
688
  "{ \"multipleOf\": {"
689
+ " \"errorCode\": 1,"
630
690
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
631
691
  " \"expected\": 10, \"actual\": 23"
632
692
  "}}");
633
693
  INVALIDATE(s, "-23", "", "multipleOf", "",
634
694
  "{ \"multipleOf\": {"
695
+ " \"errorCode\": 1,"
635
696
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
636
697
  " \"expected\": 10, \"actual\": -23"
637
698
  "}}");
@@ -646,6 +707,7 @@ TEST(SchemaValidator, Integer_MultipleOf64Boundary) {
646
707
  VALIDATE(s, "18446744073709551615", true);
647
708
  INVALIDATE(s, "18446744073709551614", "", "multipleOf", "",
648
709
  "{ \"multipleOf\": {"
710
+ " \"errorCode\": 1,"
649
711
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
650
712
  " \"expected\": 18446744073709551615, \"actual\": 18446744073709551614"
651
713
  "}}");
@@ -658,6 +720,7 @@ TEST(SchemaValidator, Number_Range) {
658
720
 
659
721
  INVALIDATE(s, "-1", "", "minimum", "",
660
722
  "{ \"minimum\": {"
723
+ " \"errorCode\": 4,"
661
724
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
662
725
  " \"expected\": 0, \"actual\": -1"
663
726
  "}}");
@@ -668,16 +731,19 @@ TEST(SchemaValidator, Number_Range) {
668
731
  VALIDATE(s, "99.9", true);
669
732
  INVALIDATE(s, "100", "", "maximum", "",
670
733
  "{ \"maximum\": {"
734
+ " \"errorCode\": 3,"
671
735
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
672
736
  " \"expected\": 100, \"exclusiveMaximum\": true, \"actual\": 100"
673
737
  "}}");
674
738
  INVALIDATE(s, "100.0", "", "maximum", "",
675
739
  "{ \"maximum\": {"
740
+ " \"errorCode\": 3,"
676
741
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
677
742
  " \"expected\": 100, \"exclusiveMaximum\": true, \"actual\": 100.0"
678
743
  "}}");
679
744
  INVALIDATE(s, "101.5", "", "maximum", "",
680
745
  "{ \"maximum\": {"
746
+ " \"errorCode\": 3,"
681
747
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
682
748
  " \"expected\": 100, \"exclusiveMaximum\": true, \"actual\": 101.5"
683
749
  "}}");
@@ -690,11 +756,13 @@ TEST(SchemaValidator, Number_RangeInt) {
690
756
 
691
757
  INVALIDATE(s, "-101", "", "minimum", "",
692
758
  "{ \"minimum\": {"
759
+ " \"errorCode\": 4,"
693
760
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
694
761
  " \"expected\": -100, \"actual\": -101"
695
762
  "}}");
696
763
  INVALIDATE(s, "-100.1", "", "minimum", "",
697
764
  "{ \"minimum\": {"
765
+ " \"errorCode\": 4,"
698
766
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
699
767
  " \"expected\": -100, \"actual\": -100.1"
700
768
  "}}");
@@ -702,46 +770,55 @@ TEST(SchemaValidator, Number_RangeInt) {
702
770
  VALIDATE(s, "-2", true);
703
771
  INVALIDATE(s, "-1", "", "maximum", "",
704
772
  "{ \"maximum\": {"
773
+ " \"errorCode\": 3,"
705
774
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
706
775
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": -1"
707
776
  "}}");
708
777
  INVALIDATE(s, "-0.9", "", "maximum", "",
709
778
  "{ \"maximum\": {"
779
+ " \"errorCode\": 3,"
710
780
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
711
781
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": -0.9"
712
782
  "}}");
713
783
  INVALIDATE(s, "0", "", "maximum", "",
714
784
  "{ \"maximum\": {"
785
+ " \"errorCode\": 3,"
715
786
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
716
787
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 0"
717
788
  "}}");
718
789
  INVALIDATE(s, "2147483647", "", "maximum", "",
719
790
  "{ \"maximum\": {"
791
+ " \"errorCode\": 3,"
720
792
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
721
793
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 2147483647"
722
794
  "}}"); // int max
723
795
  INVALIDATE(s, "2147483648", "", "maximum", "",
724
796
  "{ \"maximum\": {"
797
+ " \"errorCode\": 3,"
725
798
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
726
799
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 2147483648"
727
800
  "}}"); // unsigned first
728
801
  INVALIDATE(s, "4294967295", "", "maximum", "",
729
802
  "{ \"maximum\": {"
803
+ " \"errorCode\": 3,"
730
804
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
731
805
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 4294967295"
732
806
  "}}"); // unsigned max
733
807
  INVALIDATE(s, "9223372036854775808", "", "maximum", "",
734
808
  "{ \"maximum\": {"
809
+ " \"errorCode\": 3,"
735
810
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
736
811
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 9223372036854775808"
737
812
  "}}");
738
813
  INVALIDATE(s, "18446744073709551614", "", "maximum", "",
739
814
  "{ \"maximum\": {"
815
+ " \"errorCode\": 3,"
740
816
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
741
817
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551614"
742
818
  "}}");
743
819
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
744
820
  "{ \"maximum\": {"
821
+ " \"errorCode\": 3,"
745
822
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
746
823
  " \"expected\": -1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551615"
747
824
  "}}");
@@ -754,16 +831,19 @@ TEST(SchemaValidator, Number_RangeDouble) {
754
831
 
755
832
  INVALIDATE(s, "-9223372036854775808", "", "minimum", "",
756
833
  "{ \"minimum\": {"
834
+ " \"errorCode\": 4,"
757
835
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
758
836
  " \"expected\": 0.1, \"actual\": -9223372036854775808"
759
837
  "}}");
760
838
  INVALIDATE(s, "-2147483648", "", "minimum", "",
761
839
  "{ \"minimum\": {"
840
+ " \"errorCode\": 4,"
762
841
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
763
842
  " \"expected\": 0.1, \"actual\": -2147483648"
764
843
  "}}"); // int min
765
844
  INVALIDATE(s, "-1", "", "minimum", "",
766
845
  "{ \"minimum\": {"
846
+ " \"errorCode\": 4,"
767
847
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
768
848
  " \"expected\": 0.1, \"actual\": -1"
769
849
  "}}");
@@ -773,51 +853,61 @@ TEST(SchemaValidator, Number_RangeDouble) {
773
853
  VALIDATE(s, "100", true);
774
854
  INVALIDATE(s, "101", "", "maximum", "",
775
855
  "{ \"maximum\": {"
856
+ " \"errorCode\": 3,"
776
857
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
777
858
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 101"
778
859
  "}}");
779
860
  INVALIDATE(s, "101.5", "", "maximum", "",
780
861
  "{ \"maximum\": {"
862
+ " \"errorCode\": 3,"
781
863
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
782
864
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 101.5"
783
865
  "}}");
784
866
  INVALIDATE(s, "18446744073709551614", "", "maximum", "",
785
867
  "{ \"maximum\": {"
868
+ " \"errorCode\": 3,"
786
869
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
787
870
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551614"
788
871
  "}}");
789
872
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
790
873
  "{ \"maximum\": {"
874
+ " \"errorCode\": 3,"
791
875
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
792
876
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551615"
793
877
  "}}");
794
878
  INVALIDATE(s, "2147483647", "", "maximum", "",
795
879
  "{ \"maximum\": {"
880
+ " \"errorCode\": 3,"
796
881
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
797
882
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 2147483647"
798
883
  "}}"); // int max
799
884
  INVALIDATE(s, "2147483648", "", "maximum", "",
800
885
  "{ \"maximum\": {"
886
+ " \"errorCode\": 3,"
801
887
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
802
888
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 2147483648"
803
889
  "}}"); // unsigned first
804
890
  INVALIDATE(s, "4294967295", "", "maximum", "",
805
891
  "{ \"maximum\": {"
892
+ " \"errorCode\": 3,"
806
893
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
807
894
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 4294967295"
808
895
  "}}"); // unsigned max
809
896
  INVALIDATE(s, "9223372036854775808", "", "maximum", "",
810
897
  "{ \"maximum\": {"
898
+ " \"errorCode\": 3,"
811
899
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
812
900
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 9223372036854775808"
813
901
  "}}");
814
902
  INVALIDATE(s, "18446744073709551614", "", "maximum", "",
815
903
  "{ \"maximum\": {"
904
+ " \"errorCode\": 3,"
816
905
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
817
906
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551614"
818
907
  "}}");
819
908
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
820
909
  "{ \"maximum\": {"
910
+ " \"errorCode\": 3,"
821
911
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
822
912
  " \"expected\": 100.1, \"exclusiveMaximum\": true, \"actual\": 18446744073709551615"
823
913
  "}}");
@@ -830,31 +920,37 @@ TEST(SchemaValidator, Number_RangeDoubleU64Boundary) {
830
920
 
831
921
  INVALIDATE(s, "-9223372036854775808", "", "minimum", "",
832
922
  "{ \"minimum\": {"
923
+ " \"errorCode\": 4,"
833
924
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
834
925
  " \"expected\": 9223372036854775808.0, \"actual\": -9223372036854775808"
835
926
  "}}");
836
927
  INVALIDATE(s, "-2147483648", "", "minimum", "",
837
928
  "{ \"minimum\": {"
929
+ " \"errorCode\": 4,"
838
930
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
839
931
  " \"expected\": 9223372036854775808.0, \"actual\": -2147483648"
840
932
  "}}"); // int min
841
933
  INVALIDATE(s, "0", "", "minimum", "",
842
934
  "{ \"minimum\": {"
935
+ " \"errorCode\": 4,"
843
936
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
844
937
  " \"expected\": 9223372036854775808.0, \"actual\": 0"
845
938
  "}}");
846
939
  INVALIDATE(s, "2147483647", "", "minimum", "",
847
940
  "{ \"minimum\": {"
941
+ " \"errorCode\": 4,"
848
942
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
849
943
  " \"expected\": 9223372036854775808.0, \"actual\": 2147483647"
850
944
  "}}"); // int max
851
945
  INVALIDATE(s, "2147483648", "", "minimum", "",
852
946
  "{ \"minimum\": {"
947
+ " \"errorCode\": 4,"
853
948
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
854
949
  " \"expected\": 9223372036854775808.0, \"actual\": 2147483648"
855
950
  "}}"); // unsigned first
856
951
  INVALIDATE(s, "4294967295", "", "minimum", "",
857
952
  "{ \"minimum\": {"
953
+ " \"errorCode\": 4,"
858
954
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
859
955
  " \"expected\": 9223372036854775808.0, \"actual\": 4294967295"
860
956
  "}}"); // unsigned max
@@ -862,6 +958,7 @@ TEST(SchemaValidator, Number_RangeDoubleU64Boundary) {
862
958
  VALIDATE(s, "18446744073709540000", true);
863
959
  INVALIDATE(s, "18446744073709551615", "", "maximum", "",
864
960
  "{ \"maximum\": {"
961
+ " \"errorCode\": 2,"
865
962
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
866
963
  " \"expected\": 18446744073709550000.0, \"actual\": 18446744073709551615"
867
964
  "}}");
@@ -878,28 +975,33 @@ TEST(SchemaValidator, Number_MultipleOf) {
878
975
  VALIDATE(s, "20", true);
879
976
  INVALIDATE(s, "23", "", "multipleOf", "",
880
977
  "{ \"multipleOf\": {"
978
+ " \"errorCode\": 1,"
881
979
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
882
980
  " \"expected\": 10.0, \"actual\": 23"
883
981
  "}}");
884
982
  INVALIDATE(s, "-2147483648", "", "multipleOf", "",
885
983
  "{ \"multipleOf\": {"
984
+ " \"errorCode\": 1,"
886
985
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
887
986
  " \"expected\": 10.0, \"actual\": -2147483648"
888
987
  "}}"); // int min
889
988
  VALIDATE(s, "-2147483640", true);
890
989
  INVALIDATE(s, "2147483647", "", "multipleOf", "",
891
990
  "{ \"multipleOf\": {"
991
+ " \"errorCode\": 1,"
892
992
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
893
993
  " \"expected\": 10.0, \"actual\": 2147483647"
894
994
  "}}"); // int max
895
995
  INVALIDATE(s, "2147483648", "", "multipleOf", "",
896
996
  "{ \"multipleOf\": {"
997
+ " \"errorCode\": 1,"
897
998
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
898
999
  " \"expected\": 10.0, \"actual\": 2147483648"
899
1000
  "}}"); // unsigned first
900
1001
  VALIDATE(s, "2147483650", true);
901
1002
  INVALIDATE(s, "4294967295", "", "multipleOf", "",
902
1003
  "{ \"multipleOf\": {"
1004
+ " \"errorCode\": 1,"
903
1005
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
904
1006
  " \"expected\": 10.0, \"actual\": 4294967295"
905
1007
  "}}"); // unsigned max
@@ -915,6 +1017,7 @@ TEST(SchemaValidator, Number_MultipleOfOne) {
915
1017
  VALIDATE(s, "42.0", true);
916
1018
  INVALIDATE(s, "3.1415926", "", "multipleOf", "",
917
1019
  "{ \"multipleOf\": {"
1020
+ " \"errorCode\": 1,"
918
1021
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
919
1022
  " \"expected\": 1, \"actual\": 3.1415926"
920
1023
  "}}");
@@ -929,11 +1032,13 @@ TEST(SchemaValidator, Object) {
929
1032
  VALIDATE(s, "{\"Sun\":1.9891e30,\"Jupiter\":1.8986e27,\"Saturn\":5.6846e26,\"Neptune\":10.243e25,\"Uranus\":8.6810e25,\"Earth\":5.9736e24,\"Venus\":4.8685e24,\"Mars\":6.4185e23,\"Mercury\":3.3022e23,\"Moon\":7.349e22,\"Pluto\":1.25e22}", true);
930
1033
  INVALIDATE(s, "[\"An\", \"array\", \"not\", \"an\", \"object\"]", "", "type", "",
931
1034
  "{ \"type\": {"
1035
+ " \"errorCode\": 20,"
932
1036
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
933
1037
  " \"expected\": [\"object\"], \"actual\": \"array\""
934
1038
  "}}");
935
1039
  INVALIDATE(s, "\"Not an object\"", "", "type", "",
936
1040
  "{ \"type\": {"
1041
+ " \"errorCode\": 20,"
937
1042
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
938
1043
  " \"expected\": [\"object\"], \"actual\": \"string\""
939
1044
  "}}");
@@ -956,12 +1061,14 @@ TEST(SchemaValidator, Object_Properties) {
956
1061
  VALIDATE(s, "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\" }", true);
957
1062
  INVALIDATE(s, "{ \"number\": \"1600\", \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\" }", "/properties/number", "type", "/number",
958
1063
  "{ \"type\": {"
1064
+ " \"errorCode\": 20,"
959
1065
  " \"instanceRef\": \"#/number\", \"schemaRef\": \"#/properties/number\","
960
1066
  " \"expected\": [\"number\"], \"actual\": \"string\""
961
1067
  "}}");
962
1068
  INVALIDATE(s, "{ \"number\": \"One\", \"street_name\": \"Microsoft\", \"street_type\": \"Way\" }",
963
1069
  "/properties/number", "type", "/number",
964
1070
  "{ \"type\": {"
1071
+ " \"errorCode\": 20,"
965
1072
  " \"instanceRef\": \"#/number\", \"schemaRef\": \"#/properties/number\","
966
1073
  " \"expected\": [\"number\"], \"actual\": \"string\""
967
1074
  "}}"); // fail fast
@@ -990,6 +1097,7 @@ TEST(SchemaValidator, Object_AdditionalPropertiesBoolean) {
990
1097
  VALIDATE(s, "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\" }", true);
991
1098
  INVALIDATE(s, "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\", \"direction\": \"NW\" }", "", "additionalProperties", "/direction",
992
1099
  "{ \"additionalProperties\": {"
1100
+ " \"errorCode\": 16,"
993
1101
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
994
1102
  " \"disallowed\": \"direction\""
995
1103
  "}}");
@@ -1015,6 +1123,7 @@ TEST(SchemaValidator, Object_AdditionalPropertiesObject) {
1015
1123
  VALIDATE(s, "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\", \"direction\": \"NW\" }", true);
1016
1124
  INVALIDATE(s, "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\", \"office_number\": 201 }", "/additionalProperties", "type", "/office_number",
1017
1125
  "{ \"type\": {"
1126
+ " \"errorCode\": 20,"
1018
1127
  " \"instanceRef\": \"#/office_number\", \"schemaRef\": \"#/additionalProperties\","
1019
1128
  " \"expected\": [\"string\"], \"actual\": \"integer\""
1020
1129
  "}}");
@@ -1039,11 +1148,13 @@ TEST(SchemaValidator, Object_Required) {
1039
1148
  VALIDATE(s, "{ \"name\": \"William Shakespeare\", \"email\" : \"bill@stratford-upon-avon.co.uk\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\", \"authorship\" : \"in question\"}", true);
1040
1149
  INVALIDATE(s, "{ \"name\": \"William Shakespeare\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\" }", "", "required", "",
1041
1150
  "{ \"required\": {"
1151
+ " \"errorCode\": 15,"
1042
1152
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1043
1153
  " \"missing\": [\"email\"]"
1044
1154
  "}}");
1045
1155
  INVALIDATE(s, "{}", "", "required", "",
1046
1156
  "{ \"required\": {"
1157
+ " \"errorCode\": 15,"
1047
1158
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1048
1159
  " \"missing\": [\"name\", \"email\"]"
1049
1160
  "}}");
@@ -1067,11 +1178,13 @@ TEST(SchemaValidator, Object_Required_PassWithDefault) {
1067
1178
  VALIDATE(s, "{ \"email\" : \"bill@stratford-upon-avon.co.uk\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\", \"authorship\" : \"in question\"}", true);
1068
1179
  INVALIDATE(s, "{ \"name\": \"William Shakespeare\", \"address\" : \"Henley Street, Stratford-upon-Avon, Warwickshire, England\" }", "", "required", "",
1069
1180
  "{ \"required\": {"
1181
+ " \"errorCode\": 15,"
1070
1182
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1071
1183
  " \"missing\": [\"email\"]"
1072
1184
  "}}");
1073
1185
  INVALIDATE(s, "{}", "", "required", "",
1074
1186
  "{ \"required\": {"
1187
+ " \"errorCode\": 15,"
1075
1188
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1076
1189
  " \"missing\": [\"email\"]"
1077
1190
  "}}");
@@ -1084,11 +1197,13 @@ TEST(SchemaValidator, Object_PropertiesRange) {
1084
1197
 
1085
1198
  INVALIDATE(s, "{}", "", "minProperties", "",
1086
1199
  "{ \"minProperties\": {"
1200
+ " \"errorCode\": 14,"
1087
1201
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1088
1202
  " \"expected\": 2, \"actual\": 0"
1089
1203
  "}}");
1090
1204
  INVALIDATE(s, "{\"a\":0}", "", "minProperties", "",
1091
1205
  "{ \"minProperties\": {"
1206
+ " \"errorCode\": 14,"
1092
1207
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1093
1208
  " \"expected\": 2, \"actual\": 1"
1094
1209
  "}}");
@@ -1096,6 +1211,7 @@ TEST(SchemaValidator, Object_PropertiesRange) {
1096
1211
  VALIDATE(s, "{\"a\":0,\"b\":1,\"c\":2}", true);
1097
1212
  INVALIDATE(s, "{\"a\":0,\"b\":1,\"c\":2,\"d\":3}", "", "maxProperties", "",
1098
1213
  "{ \"maxProperties\": {"
1214
+ " \"errorCode\": 13,"
1099
1215
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\", "
1100
1216
  " \"expected\": 3, \"actual\": 4"
1101
1217
  "}}");
@@ -1123,8 +1239,15 @@ TEST(SchemaValidator, Object_PropertyDependencies) {
1123
1239
  "\"billing_address\": \"555 Debtor's Lane\" }", true);
1124
1240
  INVALIDATE(s, "{ \"name\": \"John Doe\", \"credit_card\": 5555555555555555 }", "", "dependencies", "",
1125
1241
  "{ \"dependencies\": {"
1242
+ " \"errorCode\": 18,"
1126
1243
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1127
- " \"errors\": {\"credit_card\": [\"cvv_code\", \"billing_address\"]}"
1244
+ " \"errors\": {"
1245
+ " \"credit_card\": {"
1246
+ " \"required\": {"
1247
+ " \"errorCode\": 15,"
1248
+ " \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/credit_card\","
1249
+ " \"missing\": [\"cvv_code\", \"billing_address\"]"
1250
+ " } } }"
1128
1251
  "}}");
1129
1252
  VALIDATE(s, "{ \"name\": \"John Doe\"}", true);
1130
1253
  VALIDATE(s, "{ \"name\": \"John Doe\", \"cvv_code\": 777, \"billing_address\": \"555 Debtor's Lane\" }", true);
@@ -1154,10 +1277,12 @@ TEST(SchemaValidator, Object_SchemaDependencies) {
1154
1277
  VALIDATE(s, "{\"name\": \"John Doe\", \"credit_card\" : 5555555555555555,\"billing_address\" : \"555 Debtor's Lane\"}", true);
1155
1278
  INVALIDATE(s, "{\"name\": \"John Doe\", \"credit_card\" : 5555555555555555 }", "", "dependencies", "",
1156
1279
  "{ \"dependencies\": {"
1280
+ " \"errorCode\": 18,"
1157
1281
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1158
1282
  " \"errors\": {"
1159
1283
  " \"credit_card\": {"
1160
1284
  " \"required\": {"
1285
+ " \"errorCode\": 15,"
1161
1286
  " \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/credit_card\","
1162
1287
  " \"missing\": [\"billing_address\"]"
1163
1288
  " } } }"
@@ -1182,18 +1307,20 @@ TEST(SchemaValidator, Object_PatternProperties) {
1182
1307
  VALIDATE(s, "{ \"I_0\": 42 }", true);
1183
1308
  INVALIDATE(s, "{ \"S_0\": 42 }", "", "patternProperties", "/S_0",
1184
1309
  "{ \"type\": {"
1310
+ " \"errorCode\": 20,"
1185
1311
  " \"instanceRef\": \"#/S_0\", \"schemaRef\": \"#/patternProperties/%5ES_\","
1186
1312
  " \"expected\": [\"string\"], \"actual\": \"integer\""
1187
1313
  "}}");
1188
1314
  INVALIDATE(s, "{ \"I_42\": \"This is a string\" }", "", "patternProperties", "/I_42",
1189
1315
  "{ \"type\": {"
1316
+ " \"errorCode\": 20,"
1190
1317
  " \"instanceRef\": \"#/I_42\", \"schemaRef\": \"#/patternProperties/%5EI_\","
1191
1318
  " \"expected\": [\"integer\"], \"actual\": \"string\""
1192
1319
  "}}");
1193
1320
  VALIDATE(s, "{ \"keyword\": \"value\" }", true);
1194
1321
  }
1195
1322
 
1196
- TEST(SchemaValidator, Object_PattternProperties_ErrorConflict) {
1323
+ TEST(SchemaValidator, Object_PatternProperties_ErrorConflict) {
1197
1324
  Document sd;
1198
1325
  sd.Parse(
1199
1326
  "{"
@@ -1209,9 +1336,11 @@ TEST(SchemaValidator, Object_PattternProperties_ErrorConflict) {
1209
1336
  INVALIDATE(s, "{ \"I_30\": 7 }", "", "patternProperties", "/I_30",
1210
1337
  "{ \"multipleOf\": ["
1211
1338
  " {"
1339
+ " \"errorCode\": 1,"
1212
1340
  " \"instanceRef\": \"#/I_30\", \"schemaRef\": \"#/patternProperties/%5EI_\","
1213
1341
  " \"expected\": 5, \"actual\": 7"
1214
1342
  " }, {"
1343
+ " \"errorCode\": 1,"
1215
1344
  " \"instanceRef\": \"#/I_30\", \"schemaRef\": \"#/patternProperties/30%24\","
1216
1345
  " \"expected\": 6, \"actual\": 7"
1217
1346
  " }"
@@ -1236,22 +1365,25 @@ TEST(SchemaValidator, Object_Properties_PatternProperties) {
1236
1365
  VALIDATE(s, "{ \"I_42\": 78 }", true);
1237
1366
  INVALIDATE(s, "{ \"I_42\": 42 }", "", "patternProperties", "/I_42",
1238
1367
  "{ \"minimum\": {"
1368
+ " \"errorCode\": 4,"
1239
1369
  " \"instanceRef\": \"#/I_42\", \"schemaRef\": \"#/properties/I_42\","
1240
1370
  " \"expected\": 73, \"actual\": 42"
1241
1371
  "}}");
1242
1372
  INVALIDATE(s, "{ \"I_42\": 7 }", "", "patternProperties", "/I_42",
1243
1373
  "{ \"minimum\": {"
1374
+ " \"errorCode\": 4,"
1244
1375
  " \"instanceRef\": \"#/I_42\", \"schemaRef\": \"#/properties/I_42\","
1245
1376
  " \"expected\": 73, \"actual\": 7"
1246
1377
  " },"
1247
1378
  " \"multipleOf\": {"
1379
+ " \"errorCode\": 1,"
1248
1380
  " \"instanceRef\": \"#/I_42\", \"schemaRef\": \"#/patternProperties/%5EI_\","
1249
1381
  " \"expected\": 6, \"actual\": 7"
1250
1382
  " }"
1251
1383
  "}");
1252
1384
  }
1253
1385
 
1254
- TEST(SchemaValidator, Object_PatternProperties_AdditionalProperties) {
1386
+ TEST(SchemaValidator, Object_PatternProperties_AdditionalPropertiesObject) {
1255
1387
  Document sd;
1256
1388
  sd.Parse(
1257
1389
  "{"
@@ -1271,10 +1403,35 @@ TEST(SchemaValidator, Object_PatternProperties_AdditionalProperties) {
1271
1403
  VALIDATE(s, "{ \"keyword\": \"value\" }", true);
1272
1404
  INVALIDATE(s, "{ \"keyword\": 42 }", "/additionalProperties", "type", "/keyword",
1273
1405
  "{ \"type\": {"
1406
+ " \"errorCode\": 20,"
1274
1407
  " \"instanceRef\": \"#/keyword\", \"schemaRef\": \"#/additionalProperties\","
1275
1408
  " \"expected\": [\"string\"], \"actual\": \"integer\""
1276
1409
  "}}");
1277
1410
  }
1411
+
1412
+ // Replaces test Issue285 and tests failure as well as success
1413
+ TEST(SchemaValidator, Object_PatternProperties_AdditionalPropertiesBoolean) {
1414
+ Document sd;
1415
+ sd.Parse(
1416
+ "{"
1417
+ " \"type\": \"object\","
1418
+ " \"patternProperties\": {"
1419
+ " \"^S_\": { \"type\": \"string\" },"
1420
+ " \"^I_\": { \"type\": \"integer\" }"
1421
+ " },"
1422
+ " \"additionalProperties\": false"
1423
+ "}");
1424
+ SchemaDocument s(sd);
1425
+
1426
+ VALIDATE(s, "{ \"S_25\": \"This is a string\" }", true);
1427
+ VALIDATE(s, "{ \"I_0\": 42 }", true);
1428
+ INVALIDATE(s, "{ \"keyword\": \"value\" }", "", "additionalProperties", "/keyword",
1429
+ "{ \"additionalProperties\": {"
1430
+ " \"errorCode\": 16,"
1431
+ " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1432
+ " \"disallowed\": \"keyword\""
1433
+ "}}");
1434
+ }
1278
1435
  #endif
1279
1436
 
1280
1437
  TEST(SchemaValidator, Array) {
@@ -1286,6 +1443,7 @@ TEST(SchemaValidator, Array) {
1286
1443
  VALIDATE(s, "[3, \"different\", { \"types\" : \"of values\" }]", true);
1287
1444
  INVALIDATE(s, "{\"Not\": \"an array\"}", "", "type", "",
1288
1445
  "{ \"type\": {"
1446
+ " \"errorCode\": 20,"
1289
1447
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1290
1448
  " \"expected\": [\"array\"], \"actual\": \"object\""
1291
1449
  "}}");
@@ -1305,6 +1463,7 @@ TEST(SchemaValidator, Array_ItemsList) {
1305
1463
  VALIDATE(s, "[1, 2, 3, 4, 5]", true);
1306
1464
  INVALIDATE(s, "[1, 2, \"3\", 4, 5]", "/items", "type", "/2",
1307
1465
  "{ \"type\": {"
1466
+ " \"errorCode\": 20,"
1308
1467
  " \"instanceRef\": \"#/2\", \"schemaRef\": \"#/items\","
1309
1468
  " \"expected\": [\"number\"], \"actual\": \"string\""
1310
1469
  "}}");
@@ -1337,14 +1496,16 @@ TEST(SchemaValidator, Array_ItemsTuple) {
1337
1496
 
1338
1497
  VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\"]", true);
1339
1498
  INVALIDATE(s, "[24, \"Sussex\", \"Drive\"]", "/items/2", "enum", "/2",
1340
- "{ \"enum\": { \"instanceRef\": \"#/2\", \"schemaRef\": \"#/items/2\" }}");
1499
+ "{ \"enum\": { \"errorCode\": 19, \"instanceRef\": \"#/2\", \"schemaRef\": \"#/items/2\" }}");
1341
1500
  INVALIDATE(s, "[\"Palais de l'Elysee\"]", "/items/0", "type", "/0",
1342
1501
  "{ \"type\": {"
1502
+ " \"errorCode\": 20,"
1343
1503
  " \"instanceRef\": \"#/0\", \"schemaRef\": \"#/items/0\","
1344
1504
  " \"expected\": [\"number\"], \"actual\": \"string\""
1345
1505
  "}}");
1346
1506
  INVALIDATE(s, "[\"Twenty-four\", \"Sussex\", \"Drive\"]", "/items/0", "type", "/0",
1347
1507
  "{ \"type\": {"
1508
+ " \"errorCode\": 20,"
1348
1509
  " \"instanceRef\": \"#/0\", \"schemaRef\": \"#/items/0\","
1349
1510
  " \"expected\": [\"number\"], \"actual\": \"string\""
1350
1511
  "}}"); // fail fast
@@ -1352,7 +1513,7 @@ TEST(SchemaValidator, Array_ItemsTuple) {
1352
1513
  VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\", \"Washington\"]", true);
1353
1514
  }
1354
1515
 
1355
- TEST(SchemaValidator, Array_AdditionalItmes) {
1516
+ TEST(SchemaValidator, Array_AdditionalItems) {
1356
1517
  Document sd;
1357
1518
  sd.Parse(
1358
1519
  "{"
@@ -1379,8 +1540,9 @@ TEST(SchemaValidator, Array_AdditionalItmes) {
1379
1540
 
1380
1541
  VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\"]", true);
1381
1542
  VALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\"]", true);
1382
- INVALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\", \"Washington\"]", "", "items", "/4",
1543
+ INVALIDATE(s, "[1600, \"Pennsylvania\", \"Avenue\", \"NW\", \"Washington\"]", "", "additionalItems", "/4",
1383
1544
  "{ \"additionalItems\": {"
1545
+ " \"errorCode\": 12,"
1384
1546
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1385
1547
  " \"disallowed\": 4"
1386
1548
  "}}");
@@ -1393,11 +1555,13 @@ TEST(SchemaValidator, Array_ItemsRange) {
1393
1555
 
1394
1556
  INVALIDATE(s, "[]", "", "minItems", "",
1395
1557
  "{ \"minItems\": {"
1558
+ " \"errorCode\": 10,"
1396
1559
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1397
1560
  " \"expected\": 2, \"actual\": 0"
1398
1561
  "}}");
1399
1562
  INVALIDATE(s, "[1]", "", "minItems", "",
1400
1563
  "{ \"minItems\": {"
1564
+ " \"errorCode\": 10,"
1401
1565
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1402
1566
  " \"expected\": 2, \"actual\": 1"
1403
1567
  "}}");
@@ -1405,6 +1569,7 @@ TEST(SchemaValidator, Array_ItemsRange) {
1405
1569
  VALIDATE(s, "[1, 2, 3]", true);
1406
1570
  INVALIDATE(s, "[1, 2, 3, 4]", "", "maxItems", "",
1407
1571
  "{ \"maxItems\": {"
1572
+ " \"errorCode\": 9,"
1408
1573
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1409
1574
  " \"expected\": 3, \"actual\": 4"
1410
1575
  "}}");
@@ -1418,11 +1583,13 @@ TEST(SchemaValidator, Array_UniqueItems) {
1418
1583
  VALIDATE(s, "[1, 2, 3, 4, 5]", true);
1419
1584
  INVALIDATE(s, "[1, 2, 3, 3, 4]", "", "uniqueItems", "/3",
1420
1585
  "{ \"uniqueItems\": {"
1586
+ " \"errorCode\": 11,"
1421
1587
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1422
1588
  " \"duplicates\": [2, 3]"
1423
1589
  "}}");
1424
1590
  INVALIDATE(s, "[1, 2, 3, 3, 3]", "", "uniqueItems", "/3",
1425
1591
  "{ \"uniqueItems\": {"
1592
+ " \"errorCode\": 11,"
1426
1593
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1427
1594
  " \"duplicates\": [2, 3]"
1428
1595
  "}}"); // fail fast
@@ -1438,11 +1605,13 @@ TEST(SchemaValidator, Boolean) {
1438
1605
  VALIDATE(s, "false", true);
1439
1606
  INVALIDATE(s, "\"true\"", "", "type", "",
1440
1607
  "{ \"type\": {"
1608
+ " \"errorCode\": 20,"
1441
1609
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1442
1610
  " \"expected\": [\"boolean\"], \"actual\": \"string\""
1443
1611
  "}}");
1444
1612
  INVALIDATE(s, "0", "", "type", "",
1445
1613
  "{ \"type\": {"
1614
+ " \"errorCode\": 20,"
1446
1615
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1447
1616
  " \"expected\": [\"boolean\"], \"actual\": \"integer\""
1448
1617
  "}}");
@@ -1456,16 +1625,19 @@ TEST(SchemaValidator, Null) {
1456
1625
  VALIDATE(s, "null", true);
1457
1626
  INVALIDATE(s, "false", "", "type", "",
1458
1627
  "{ \"type\": {"
1628
+ " \"errorCode\": 20,"
1459
1629
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1460
1630
  " \"expected\": [\"null\"], \"actual\": \"boolean\""
1461
1631
  "}}");
1462
1632
  INVALIDATE(s, "0", "", "type", "",
1463
1633
  "{ \"type\": {"
1634
+ " \"errorCode\": 20,"
1464
1635
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1465
1636
  " \"expected\": [\"null\"], \"actual\": \"integer\""
1466
1637
  "}}");
1467
1638
  INVALIDATE(s, "\"\"", "", "type", "",
1468
1639
  "{ \"type\": {"
1640
+ " \"errorCode\": 20,"
1469
1641
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1470
1642
  " \"expected\": [\"null\"], \"actual\": \"string\""
1471
1643
  "}}");
@@ -1481,11 +1653,13 @@ TEST(SchemaValidator, ObjectInArray) {
1481
1653
  VALIDATE(s, "[\"a\"]", true);
1482
1654
  INVALIDATE(s, "[1]", "/items", "type", "/0",
1483
1655
  "{ \"type\": {"
1656
+ " \"errorCode\": 20,"
1484
1657
  " \"instanceRef\": \"#/0\", \"schemaRef\": \"#/items\","
1485
1658
  " \"expected\": [\"string\"], \"actual\": \"integer\""
1486
1659
  "}}");
1487
1660
  INVALIDATE(s, "[{}]", "/items", "type", "/0",
1488
1661
  "{ \"type\": {"
1662
+ " \"errorCode\": 20,"
1489
1663
  " \"instanceRef\": \"#/0\", \"schemaRef\": \"#/items\","
1490
1664
  " \"expected\": [\"string\"], \"actual\": \"object\""
1491
1665
  "}}");
@@ -1508,6 +1682,7 @@ TEST(SchemaValidator, MultiTypeInObject) {
1508
1682
  VALIDATE(s, "{ \"tel\": \"123-456\" }", true);
1509
1683
  INVALIDATE(s, "{ \"tel\": true }", "/properties/tel", "type", "/tel",
1510
1684
  "{ \"type\": {"
1685
+ " \"errorCode\": 20,"
1511
1686
  " \"instanceRef\": \"#/tel\", \"schemaRef\": \"#/properties/tel\","
1512
1687
  " \"expected\": [\"string\", \"integer\"], \"actual\": \"boolean\""
1513
1688
  "}}");
@@ -1530,6 +1705,7 @@ TEST(SchemaValidator, MultiTypeWithObject) {
1530
1705
  VALIDATE(s, "{ \"tel\": 999 }", true);
1531
1706
  INVALIDATE(s, "{ \"tel\": \"fail\" }", "/properties/tel", "type", "/tel",
1532
1707
  "{ \"type\": {"
1708
+ " \"errorCode\": 20,"
1533
1709
  " \"instanceRef\": \"#/tel\", \"schemaRef\": \"#/properties/tel\","
1534
1710
  " \"expected\": [\"integer\"], \"actual\": \"string\""
1535
1711
  "}}");
@@ -1550,48 +1726,71 @@ TEST(SchemaValidator, AllOf_Nested) {
1550
1726
  VALIDATE(s, "\"ok\"", true);
1551
1727
  VALIDATE(s, "\"OK\"", true);
1552
1728
  INVALIDATE(s, "\"okay\"", "", "allOf", "",
1553
- "{ \"enum\": {"
1554
- " \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\""
1729
+ "{ \"allOf\": {"
1730
+ " \"errors\": ["
1731
+ " {},{},"
1732
+ " { \"allOf\": {"
1733
+ " \"errors\": ["
1734
+ " {},"
1735
+ " { \"enum\": {\"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\" }}"
1736
+ " ],"
1737
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2\""
1738
+ " }}],"
1739
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
1555
1740
  "}}");
1556
1741
  INVALIDATE(s, "\"o\"", "", "allOf", "",
1557
- "{ \"minLength\": {"
1558
- " \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\","
1559
- " \"expected\": 2, \"actual\": \"o\""
1742
+ "{ \"allOf\": {"
1743
+ " \"errors\": ["
1744
+ " { \"minLength\": {\"actual\": \"o\", \"expected\": 2, \"errorCode\": 7, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\" }},"
1745
+ " {},{}"
1746
+ " ],"
1747
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
1560
1748
  "}}");
1561
1749
  INVALIDATE(s, "\"n\"", "", "allOf", "",
1562
- "{ \"minLength\": {"
1563
- " \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\","
1564
- " \"expected\": 2, \"actual\": \"n\""
1565
- " },"
1566
- " \"enum\": ["
1567
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"},"
1568
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}"
1569
- " ]"
1570
- "}")
1750
+ "{ \"allOf\": {"
1751
+ " \"errors\": ["
1752
+ " { \"minLength\": {\"actual\": \"n\", \"expected\": 2, \"errorCode\": 7, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\" }},"
1753
+ " {},"
1754
+ " { \"allOf\": {"
1755
+ " \"errors\": ["
1756
+ " { \"enum\": {\"errorCode\": 19 ,\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"}},"
1757
+ " { \"enum\": {\"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}}"
1758
+ " ],"
1759
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2\""
1760
+ " }}"
1761
+ " ],"
1762
+ " \"errorCode\":23,\"instanceRef\":\"#\",\"schemaRef\":\"#\""
1763
+ "}}");
1571
1764
  INVALIDATE(s, "\"too long\"", "", "allOf", "",
1572
- "{ \"maxLength\": {"
1573
- " \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\","
1574
- " \"expected\": 5, \"actual\": \"too long\""
1575
- " },"
1576
- " \"enum\": ["
1577
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"},"
1578
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}"
1579
- " ]"
1580
- "}");
1765
+ "{ \"allOf\": {"
1766
+ " \"errors\": ["
1767
+ " {},"
1768
+ " { \"maxLength\": {\"actual\": \"too long\", \"expected\": 5, \"errorCode\": 6, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\" }},"
1769
+ " { \"allOf\": {"
1770
+ " \"errors\": ["
1771
+ " { \"enum\": {\"errorCode\": 19 ,\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"}},"
1772
+ " { \"enum\": {\"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}}"
1773
+ " ],"
1774
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2\""
1775
+ " }}"
1776
+ " ],"
1777
+ " \"errorCode\":23,\"instanceRef\":\"#\",\"schemaRef\":\"#\""
1778
+ "}}");
1581
1779
  INVALIDATE(s, "123", "", "allOf", "",
1582
- "{ \"type\": ["
1583
- " { \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\","
1584
- " \"expected\": [\"string\"], \"actual\": \"integer\""
1585
- " },"
1586
- " { \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\","
1587
- " \"expected\": [\"string\"], \"actual\": \"integer\""
1588
- " }"
1589
- " ],"
1590
- " \"enum\": ["
1591
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"},"
1592
- " {\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}"
1593
- " ]"
1594
- "}");
1780
+ "{ \"allOf\": {"
1781
+ " \"errors\": ["
1782
+ " {\"type\": {\"expected\": [\"string\"], \"actual\": \"integer\", \"errorCode\": 20, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/0\"}},"
1783
+ " {\"type\": {\"expected\": [\"string\"], \"actual\": \"integer\", \"errorCode\": 20, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/1\"}},"
1784
+ " { \"allOf\": {"
1785
+ " \"errors\": ["
1786
+ " { \"enum\": {\"errorCode\": 19 ,\"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/0\"}},"
1787
+ " { \"enum\": {\"errorCode\": 19, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2/allOf/1\"}}"
1788
+ " ],"
1789
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#/allOf/2\""
1790
+ " }}"
1791
+ " ],"
1792
+ " \"errorCode\":23,\"instanceRef\":\"#\",\"schemaRef\":\"#\""
1793
+ "}}");
1595
1794
  }
1596
1795
 
1597
1796
  TEST(SchemaValidator, EscapedPointer) {
@@ -1606,6 +1805,7 @@ TEST(SchemaValidator, EscapedPointer) {
1606
1805
  SchemaDocument s(sd);
1607
1806
  INVALIDATE(s, "{\"~/\":true}", "/properties/~0~1", "type", "/~0~1",
1608
1807
  "{ \"type\": {"
1808
+ " \"errorCode\": 20,"
1609
1809
  " \"instanceRef\": \"#/~0~1\", \"schemaRef\": \"#/properties/~0~1\","
1610
1810
  " \"expected\": [\"number\"], \"actual\": \"boolean\""
1611
1811
  "}}");
@@ -1650,11 +1850,14 @@ TEST(SchemaValidator, ValidateMetaSchema) {
1650
1850
  ASSERT_FALSE(d.HasParseError());
1651
1851
  SchemaDocument sd(d);
1652
1852
  SchemaValidator validator(sd);
1653
- if (!d.Accept(validator)) {
1853
+ d.Accept(validator);
1854
+ if (!validator.IsValid()) {
1654
1855
  StringBuffer sb;
1655
1856
  validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);
1656
1857
  printf("Invalid schema: %s\n", sb.GetString());
1657
1858
  printf("Invalid keyword: %s\n", validator.GetInvalidSchemaKeyword());
1859
+ printf("Invalid code: %d\n", validator.GetInvalidSchemaCode());
1860
+ printf("Invalid message: %s\n", GetValidateError_En(validator.GetInvalidSchemaCode()));
1658
1861
  sb.Clear();
1659
1862
  validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);
1660
1863
  printf("Invalid document: %s\n", sb.GetString());
@@ -1681,7 +1884,8 @@ TEST(SchemaValidator, ValidateMetaSchema_UTF16) {
1681
1884
  ASSERT_FALSE(d.HasParseError());
1682
1885
  SD sd(d);
1683
1886
  SV validator(sd);
1684
- if (!d.Accept(validator)) {
1887
+ d.Accept(validator);
1888
+ if (!validator.IsValid()) {
1685
1889
  GenericStringBuffer<UTF16<> > sb;
1686
1890
  validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);
1687
1891
  wprintf(L"Invalid schema: %ls\n", sb.GetString());
@@ -1709,13 +1913,15 @@ public:
1709
1913
  "jsonschema/remotes/integer.json",
1710
1914
  "jsonschema/remotes/subSchemas.json",
1711
1915
  "jsonschema/remotes/folder/folderInteger.json",
1712
- "draft-04/schema"
1916
+ "draft-04/schema",
1917
+ "unittestschema/address.json"
1713
1918
  };
1714
1919
  const char* uris[kCount] = {
1715
1920
  "http://localhost:1234/integer.json",
1716
1921
  "http://localhost:1234/subSchemas.json",
1717
1922
  "http://localhost:1234/folder/folderInteger.json",
1718
- "http://json-schema.org/draft-04/schema"
1923
+ "http://json-schema.org/draft-04/schema",
1924
+ "http://localhost:1234/address.json"
1719
1925
  };
1720
1926
 
1721
1927
  for (size_t i = 0; i < kCount; i++) {
@@ -1757,7 +1963,7 @@ private:
1757
1963
  RemoteSchemaDocumentProvider(const RemoteSchemaDocumentProvider&);
1758
1964
  RemoteSchemaDocumentProvider& operator=(const RemoteSchemaDocumentProvider&);
1759
1965
 
1760
- static const size_t kCount = 4;
1966
+ static const size_t kCount = 5;
1761
1967
  SchemaDocumentType* sd_[kCount];
1762
1968
  typename DocumentType::AllocatorType documentAllocator_;
1763
1969
  typename SchemaDocumentType::AllocatorType schemaAllocator_;
@@ -1826,6 +2032,7 @@ TEST(SchemaValidator, TestSuite) {
1826
2032
  ADD_FAILURE();
1827
2033
  }
1828
2034
  else {
2035
+ //printf("json test suite file %s parsed ok\n", filename);
1829
2036
  GenericDocument<UTF8<>, MemoryPoolAllocator<>, MemoryPoolAllocator<> > d(&documentAllocator, 1024, &documentStackAllocator);
1830
2037
  d.Parse(json);
1831
2038
  if (d.HasParseError()) {
@@ -1846,11 +2053,14 @@ TEST(SchemaValidator, TestSuite) {
1846
2053
  bool expected = (*testItr)["valid"].GetBool();
1847
2054
  testCount++;
1848
2055
  validator.Reset();
1849
- bool actual = data.Accept(validator);
2056
+ data.Accept(validator);
2057
+ bool actual = validator.IsValid();
1850
2058
  if (expected != actual)
1851
2059
  printf("Fail: %30s \"%s\" \"%s\"\n", filename, description1, description2);
1852
- else
2060
+ else {
2061
+ //printf("Passed: %30s \"%s\" \"%s\"\n", filename, description1, description2);
1853
2062
  passCount++;
2063
+ }
1854
2064
  }
1855
2065
  }
1856
2066
  //printf("%zu %zu %zu\n", documentAllocator.Size(), schemaAllocator.Size(), validatorAllocator.Size());
@@ -1865,8 +2075,8 @@ TEST(SchemaValidator, TestSuite) {
1865
2075
  jsonAllocator.Clear();
1866
2076
  }
1867
2077
  printf("%d / %d passed (%2d%%)\n", passCount, testCount, passCount * 100 / testCount);
1868
- // if (passCount != testCount)
1869
- // ADD_FAILURE();
2078
+ // if (passCount != testCount)
2079
+ // ADD_FAILURE();
1870
2080
  }
1871
2081
 
1872
2082
  TEST(SchemaValidatingReader, Simple) {
@@ -1897,12 +2107,14 @@ TEST(SchemaValidatingReader, Invalid) {
1897
2107
  EXPECT_FALSE(reader.IsValid());
1898
2108
  EXPECT_EQ(kParseErrorTermination, reader.GetParseResult().Code());
1899
2109
  EXPECT_STREQ("maxLength", reader.GetInvalidSchemaKeyword());
2110
+ EXPECT_TRUE(reader.GetInvalidSchemaCode() == kValidateErrorMaxLength);
1900
2111
  EXPECT_TRUE(reader.GetInvalidSchemaPointer() == SchemaDocument::PointerType(""));
1901
2112
  EXPECT_TRUE(reader.GetInvalidDocumentPointer() == SchemaDocument::PointerType(""));
1902
2113
  EXPECT_TRUE(d.IsNull());
1903
2114
  Document e;
1904
2115
  e.Parse(
1905
2116
  "{ \"maxLength\": {"
2117
+ " \"errorCode\": 6,"
1906
2118
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1907
2119
  " \"expected\": 3, \"actual\": \"ABCD\""
1908
2120
  "}}");
@@ -1933,9 +2145,11 @@ TEST(SchemaValidatingWriter, Simple) {
1933
2145
  EXPECT_FALSE(validator.IsValid());
1934
2146
  EXPECT_TRUE(validator.GetInvalidSchemaPointer() == SchemaDocument::PointerType(""));
1935
2147
  EXPECT_TRUE(validator.GetInvalidDocumentPointer() == SchemaDocument::PointerType(""));
2148
+ EXPECT_TRUE(validator.GetInvalidSchemaCode() == kValidateErrorMaxLength);
1936
2149
  Document e;
1937
2150
  e.Parse(
1938
2151
  "{ \"maxLength\": {"
2152
+ " \"errorCode\": 6,"
1939
2153
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1940
2154
  " \"expected\": 3, \"actual\": \"ABCD\""
1941
2155
  "}}");
@@ -1963,6 +2177,7 @@ TEST(Schema, Issue552) {
1963
2177
  VALIDATE(s, "\"Life, the universe, and everything\"", true);
1964
2178
  INVALIDATE(s, "[\"Life\", \"the universe\", \"and everything\"]", "", "type", "",
1965
2179
  "{ \"type\": {"
2180
+ " \"errorCode\": 20,"
1966
2181
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1967
2182
  " \"expected\": [\"string\", \"number\"], \"actual\": \"array\""
1968
2183
  "}}");
@@ -1978,6 +2193,7 @@ TEST(SchemaValidator, Issue608) {
1978
2193
  VALIDATE(s, "{\"a\" : null, \"b\": null}", true);
1979
2194
  INVALIDATE(s, "{\"a\" : null, \"a\" : null}", "", "required", "",
1980
2195
  "{ \"required\": {"
2196
+ " \"errorCode\": 15,"
1981
2197
  " \"instanceRef\": \"#\", \"schemaRef\": \"#\","
1982
2198
  " \"missing\": [\"b\"]"
1983
2199
  "}}");
@@ -1991,13 +2207,6 @@ TEST(SchemaValidator, Issue728_AllOfRef) {
1991
2207
  VALIDATE(s, "{\"key1\": \"abc\", \"key2\": \"def\"}", true);
1992
2208
  }
1993
2209
 
1994
- TEST(SchemaValidator, Issue825) {
1995
- Document sd;
1996
- sd.Parse("{\"type\": \"object\", \"additionalProperties\": false, \"patternProperties\": {\"^i\": { \"type\": \"string\" } } }");
1997
- SchemaDocument s(sd);
1998
- VALIDATE(s, "{ \"item\": \"hello\" }", true);
1999
- }
2000
-
2001
2210
  TEST(SchemaValidator, Issue1017_allOfHandler) {
2002
2211
  Document sd;
2003
2212
  sd.Parse("{\"allOf\": [{\"type\": \"object\",\"properties\": {\"cyanArray2\": {\"type\": \"array\",\"items\": { \"type\": \"string\" }}}},{\"type\": \"object\",\"properties\": {\"blackArray\": {\"type\": \"array\",\"items\": { \"type\": \"string\" }}},\"required\": [ \"blackArray\" ]}]}");
@@ -2027,19 +2236,25 @@ TEST(SchemaValidator, Ref_remote) {
2027
2236
  typedef GenericPointer<Value, MemoryPoolAllocator<> > PointerType;
2028
2237
  INVALIDATE_(s, "null", "/integer", "type", "",
2029
2238
  "{ \"type\": {"
2239
+ " \"errorCode\": 20,"
2030
2240
  " \"instanceRef\": \"#\","
2031
2241
  " \"schemaRef\": \"http://localhost:1234/subSchemas.json#/integer\","
2032
2242
  " \"expected\": [\"integer\"], \"actual\": \"null\""
2033
2243
  "}}",
2034
- SchemaValidatorType, PointerType);
2244
+ kValidateDefaultFlags, SchemaValidatorType, PointerType);
2035
2245
  }
2036
2246
 
2037
2247
  TEST(SchemaValidator, Ref_remote_issue1210) {
2038
2248
  class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
2039
2249
  SchemaDocument** collection;
2040
2250
 
2041
- SchemaDocumentProvider(const SchemaDocumentProvider&);
2042
- SchemaDocumentProvider& operator=(const SchemaDocumentProvider&);
2251
+ // Dummy private copy constructor & assignment operator.
2252
+ // Function bodies added so that they compile in MSVC 2019.
2253
+ SchemaDocumentProvider(const SchemaDocumentProvider&) : collection(NULL) {
2254
+ }
2255
+ SchemaDocumentProvider& operator=(const SchemaDocumentProvider&) {
2256
+ return *this;
2257
+ }
2043
2258
 
2044
2259
  public:
2045
2260
  SchemaDocumentProvider(SchemaDocument** collection) : collection(collection) { }
@@ -2067,6 +2282,306 @@ TEST(SchemaValidator, Ref_remote_issue1210) {
2067
2282
  VALIDATE(sx, "{\"country\":\"US\"}", true);
2068
2283
  }
2069
2284
 
2285
+ // Test that when kValidateContinueOnErrorFlag is set, all errors are reported.
2286
+ TEST(SchemaValidator, ContinueOnErrors) {
2287
+ CrtAllocator allocator;
2288
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2289
+ Document sd;
2290
+ sd.Parse(schema);
2291
+ ASSERT_FALSE(sd.HasParseError());
2292
+ SchemaDocument s(sd);
2293
+ VALIDATE(s, "{\"version\": 1.0, \"address\": {\"number\": 24, \"street1\": \"The Woodlands\", \"street3\": \"Ham\", \"city\": \"Romsey\", \"area\": \"Kent\", \"country\": \"UK\", \"postcode\": \"SO51 0GP\"}, \"phones\": [\"0111-222333\", \"0777-666888\"], \"names\": [\"Fred\", \"Bloggs\"]}", true);
2294
+ INVALIDATE_(s, "{\"version\": 1.01, \"address\": {\"number\": 0, \"street2\": false, \"street3\": \"Ham\", \"city\": \"RomseyTownFC\", \"area\": \"BC\", \"country\": \"USA\", \"postcode\": \"999ABC\"}, \"phones\": [], \"planet\": \"Earth\", \"extra\": {\"S_xxx\": 123}}", "#", "errors", "#",
2295
+ "{ \"multipleOf\": {"
2296
+ " \"errorCode\": 1, \"instanceRef\": \"#/version\", \"schemaRef\": \"#/definitions/decimal_type\", \"expected\": 1.0, \"actual\": 1.01"
2297
+ " },"
2298
+ " \"minimum\": {"
2299
+ " \"errorCode\": 5, \"instanceRef\": \"#/address/number\", \"schemaRef\": \"#/definitions/positiveInt_type\", \"expected\": 0, \"actual\": 0, \"exclusiveMinimum\": true"
2300
+ " },"
2301
+ " \"type\": ["
2302
+ " {\"expected\": [\"null\", \"string\"], \"actual\": \"boolean\", \"errorCode\": 20, \"instanceRef\": \"#/address/street2\", \"schemaRef\": \"#/definitions/address_type/properties/street2\"},"
2303
+ " {\"expected\": [\"string\"], \"actual\": \"integer\", \"errorCode\": 20, \"instanceRef\": \"#/extra/S_xxx\", \"schemaRef\": \"#/properties/extra/patternProperties/%5ES_\"}"
2304
+ " ],"
2305
+ " \"maxLength\": {"
2306
+ " \"actual\": \"RomseyTownFC\", \"expected\": 10, \"errorCode\": 6, \"instanceRef\": \"#/address/city\", \"schemaRef\": \"#/definitions/address_type/properties/city\""
2307
+ " },"
2308
+ " \"anyOf\": {"
2309
+ " \"errors\":["
2310
+ " {\"pattern\": {\"actual\": \"999ABC\", \"errorCode\": 8, \"instanceRef\": \"#/address/postcode\", \"schemaRef\": \"#/definitions/address_type/properties/postcode/anyOf/0\"}},"
2311
+ " {\"pattern\": {\"actual\": \"999ABC\", \"errorCode\": 8, \"instanceRef\": \"#/address/postcode\", \"schemaRef\": \"#/definitions/address_type/properties/postcode/anyOf/1\"}}"
2312
+ " ],"
2313
+ " \"errorCode\": 24, \"instanceRef\": \"#/address/postcode\", \"schemaRef\": \"#/definitions/address_type/properties/postcode\""
2314
+ " },"
2315
+ " \"allOf\": {"
2316
+ " \"errors\":["
2317
+ " {\"enum\":{\"errorCode\":19,\"instanceRef\":\"#/address/country\",\"schemaRef\":\"#/definitions/country_type\"}}"
2318
+ " ],"
2319
+ " \"errorCode\":23,\"instanceRef\":\"#/address/country\",\"schemaRef\":\"#/definitions/address_type/properties/country\""
2320
+ " },"
2321
+ " \"minItems\": {"
2322
+ " \"actual\": 0, \"expected\": 1, \"errorCode\": 10, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\""
2323
+ " },"
2324
+ " \"additionalProperties\": {"
2325
+ " \"disallowed\": \"planet\", \"errorCode\": 16, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2326
+ " },"
2327
+ " \"required\": {"
2328
+ " \"missing\": [\"street1\"], \"errorCode\": 15, \"instanceRef\": \"#/address\", \"schemaRef\": \"#/definitions/address_type\""
2329
+ " }"
2330
+ "}",
2331
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2332
+ INVALIDATE_(s, "{\"address\": {\"number\": 200, \"street1\": {}, \"street3\": null, \"city\": \"Rom\", \"area\": \"Dorset\", \"postcode\": \"SO51 0GP\"}, \"phones\": [\"0111-222333\", \"0777-666888\", \"0777-666888\"], \"names\": [\"Fred\", \"S\", \"M\", \"Bloggs\"]}", "#", "errors", "#",
2333
+ "{ \"maximum\": {"
2334
+ " \"errorCode\": 3, \"instanceRef\": \"#/address/number\", \"schemaRef\": \"#/definitions/positiveInt_type\", \"expected\": 100, \"actual\": 200, \"exclusiveMaximum\": true"
2335
+ " },"
2336
+ " \"type\": {"
2337
+ " \"expected\": [\"string\"], \"actual\": \"object\", \"errorCode\": 20, \"instanceRef\": \"#/address/street1\", \"schemaRef\": \"#/definitions/address_type/properties/street1\""
2338
+ " },"
2339
+ " \"not\": {"
2340
+ " \"errorCode\": 25, \"instanceRef\": \"#/address/street3\", \"schemaRef\": \"#/definitions/address_type/properties/street3\""
2341
+ " },"
2342
+ " \"minLength\": {"
2343
+ " \"actual\": \"Rom\", \"expected\": 4, \"errorCode\": 7, \"instanceRef\": \"#/address/city\", \"schemaRef\": \"#/definitions/address_type/properties/city\""
2344
+ " },"
2345
+ " \"maxItems\": {"
2346
+ " \"actual\": 3, \"expected\": 2, \"errorCode\": 9, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\""
2347
+ " },"
2348
+ " \"uniqueItems\": {"
2349
+ " \"duplicates\": [1, 2], \"errorCode\": 11, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\""
2350
+ " },"
2351
+ " \"minProperties\": {\"actual\": 6, \"expected\": 7, \"errorCode\": 14, \"instanceRef\": \"#/address\", \"schemaRef\": \"#/definitions/address_type\""
2352
+ " },"
2353
+ " \"additionalItems\": ["
2354
+ " {\"disallowed\": 2, \"errorCode\": 12, \"instanceRef\": \"#/names\", \"schemaRef\": \"#/properties/names\"},"
2355
+ " {\"disallowed\": 3, \"errorCode\": 12, \"instanceRef\": \"#/names\", \"schemaRef\": \"#/properties/names\"}"
2356
+ " ],"
2357
+ " \"dependencies\": {"
2358
+ " \"errors\": {"
2359
+ " \"address\": {\"required\": {\"missing\": [\"version\"], \"errorCode\": 15, \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/address\"}},"
2360
+ " \"names\": {\"required\": {\"missing\": [\"version\"], \"errorCode\": 15, \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/names\"}}"
2361
+ " },"
2362
+ " \"errorCode\": 18, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2363
+ " },"
2364
+ " \"oneOf\": {"
2365
+ " \"errors\": ["
2366
+ " {\"enum\": {\"errorCode\": 19, \"instanceRef\": \"#/address/area\", \"schemaRef\": \"#/definitions/county_type\"}},"
2367
+ " {\"enum\": {\"errorCode\": 19, \"instanceRef\": \"#/address/area\", \"schemaRef\": \"#/definitions/province_type\"}}"
2368
+ " ],"
2369
+ " \"errorCode\": 21, \"instanceRef\": \"#/address/area\", \"schemaRef\": \"#/definitions/address_type/properties/area\""
2370
+ " }"
2371
+ "}",
2372
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2373
+
2374
+ CrtAllocator::Free(schema);
2375
+ }
2376
+
2377
+ // Test that when kValidateContinueOnErrorFlag is set, it is not propagated to oneOf sub-validator so we only get the first error.
2378
+ TEST(SchemaValidator, ContinueOnErrors_OneOf) {
2379
+ typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
2380
+ RemoteSchemaDocumentProvider<SchemaDocumentType> provider;
2381
+ CrtAllocator allocator;
2382
+ char* schema = ReadFile("unittestschema/oneOf_address.json", allocator);
2383
+ Document sd;
2384
+ sd.Parse(schema);
2385
+ ASSERT_FALSE(sd.HasParseError());
2386
+ SchemaDocumentType s(sd, 0, 0, &provider);
2387
+ typedef GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > SchemaValidatorType;
2388
+ typedef GenericPointer<Value, MemoryPoolAllocator<> > PointerType;
2389
+ INVALIDATE_(s, "{\"version\": 1.01, \"address\": {\"number\": 0, \"street2\": false, \"street3\": \"Ham\", \"city\": \"RomseyTownFC\", \"area\": \"BC\", \"country\": \"USA\", \"postcode\": \"999ABC\"}, \"phones\": [], \"planet\": \"Earth\", \"extra\": {\"S_xxx\": 123}}", "#", "errors", "#",
2390
+ "{ \"oneOf\": {"
2391
+ " \"errors\": [{"
2392
+ " \"multipleOf\": {"
2393
+ " \"errorCode\": 1, \"instanceRef\": \"#/version\", \"schemaRef\": \"http://localhost:1234/address.json#/definitions/decimal_type\", \"expected\": 1.0, \"actual\": 1.01"
2394
+ " }"
2395
+ " }],"
2396
+ " \"errorCode\": 21, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2397
+ " }"
2398
+ "}",
2399
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidatorType, PointerType);
2400
+ CrtAllocator::Free(schema);
2401
+ }
2402
+
2403
+ // Test that when kValidateContinueOnErrorFlag is set, it is not propagated to allOf sub-validator so we only get the first error.
2404
+ TEST(SchemaValidator, ContinueOnErrors_AllOf) {
2405
+ typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
2406
+ RemoteSchemaDocumentProvider<SchemaDocumentType> provider;
2407
+ CrtAllocator allocator;
2408
+ char* schema = ReadFile("unittestschema/allOf_address.json", allocator);
2409
+ Document sd;
2410
+ sd.Parse(schema);
2411
+ ASSERT_FALSE(sd.HasParseError());
2412
+ SchemaDocumentType s(sd, 0, 0, &provider);
2413
+ typedef GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > SchemaValidatorType;
2414
+ typedef GenericPointer<Value, MemoryPoolAllocator<> > PointerType;
2415
+ INVALIDATE_(s, "{\"version\": 1.01, \"address\": {\"number\": 0, \"street2\": false, \"street3\": \"Ham\", \"city\": \"RomseyTownFC\", \"area\": \"BC\", \"country\": \"USA\", \"postcode\": \"999ABC\"}, \"phones\": [], \"planet\": \"Earth\", \"extra\": {\"S_xxx\": 123}}", "#", "errors", "#",
2416
+ "{ \"allOf\": {"
2417
+ " \"errors\": [{"
2418
+ " \"multipleOf\": {"
2419
+ " \"errorCode\": 1, \"instanceRef\": \"#/version\", \"schemaRef\": \"http://localhost:1234/address.json#/definitions/decimal_type\", \"expected\": 1.0, \"actual\": 1.01"
2420
+ " }"
2421
+ " }],"
2422
+ " \"errorCode\": 23, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2423
+ " }"
2424
+ "}",
2425
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidatorType, PointerType);
2426
+ CrtAllocator::Free(schema);
2427
+ }
2428
+
2429
+ // Test that when kValidateContinueOnErrorFlag is set, it is not propagated to anyOf sub-validator so we only get the first error.
2430
+ TEST(SchemaValidator, ContinueOnErrors_AnyOf) {
2431
+ typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
2432
+ RemoteSchemaDocumentProvider<SchemaDocumentType> provider;
2433
+ CrtAllocator allocator;
2434
+ char* schema = ReadFile("unittestschema/anyOf_address.json", allocator);
2435
+ Document sd;
2436
+ sd.Parse(schema);
2437
+ ASSERT_FALSE(sd.HasParseError());
2438
+ SchemaDocumentType s(sd, 0, 0, &provider);
2439
+ typedef GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > SchemaValidatorType;
2440
+ typedef GenericPointer<Value, MemoryPoolAllocator<> > PointerType;
2441
+ INVALIDATE_(s, "{\"version\": 1.01, \"address\": {\"number\": 0, \"street2\": false, \"street3\": \"Ham\", \"city\": \"RomseyTownFC\", \"area\": \"BC\", \"country\": \"USA\", \"postcode\": \"999ABC\"}, \"phones\": [], \"planet\": \"Earth\", \"extra\": {\"S_xxx\": 123}}", "#", "errors", "#",
2442
+ "{ \"anyOf\": {"
2443
+ " \"errors\": [{"
2444
+ " \"multipleOf\": {"
2445
+ " \"errorCode\": 1, \"instanceRef\": \"#/version\", \"schemaRef\": \"http://localhost:1234/address.json#/definitions/decimal_type\", \"expected\": 1.0, \"actual\": 1.01"
2446
+ " }"
2447
+ " }],"
2448
+ " \"errorCode\": 24, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2449
+ " }"
2450
+ "}",
2451
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidatorType, PointerType);
2452
+
2453
+ CrtAllocator::Free(schema);
2454
+ }
2455
+
2456
+ // Test that when kValidateContinueOnErrorFlag is set, arrays with uniqueItems:true are correctly processed when an item is invalid.
2457
+ // This tests that we don't blow up if a hasher does not get created.
2458
+ TEST(SchemaValidator, ContinueOnErrors_UniqueItems) {
2459
+ CrtAllocator allocator;
2460
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2461
+ Document sd;
2462
+ sd.Parse(schema);
2463
+ ASSERT_FALSE(sd.HasParseError());
2464
+ SchemaDocument s(sd);
2465
+ VALIDATE(s, "{\"phones\":[\"12-34\",\"56-78\"]}", true);
2466
+ INVALIDATE_(s, "{\"phones\":[\"12-34\",\"12-34\"]}", "#", "errors", "#",
2467
+ "{\"uniqueItems\": {\"duplicates\": [0,1], \"errorCode\": 11, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\"}}",
2468
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2469
+ INVALIDATE_(s, "{\"phones\":[\"ab-34\",\"cd-78\"]}", "#", "errors", "#",
2470
+ "{\"pattern\": ["
2471
+ " {\"actual\": \"ab-34\", \"errorCode\": 8, \"instanceRef\": \"#/phones/0\", \"schemaRef\": \"#/definitions/phone_type\"},"
2472
+ " {\"actual\": \"cd-78\", \"errorCode\": 8, \"instanceRef\": \"#/phones/1\", \"schemaRef\": \"#/definitions/phone_type\"}"
2473
+ "]}",
2474
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2475
+ CrtAllocator::Free(schema);
2476
+ }
2477
+
2478
+ // Test that when kValidateContinueOnErrorFlag is set, an enum field is correctly processed when it has an invalid value.
2479
+ // This tests that we don't blow up if a hasher does not get created.
2480
+ TEST(SchemaValidator, ContinueOnErrors_Enum) {
2481
+ CrtAllocator allocator;
2482
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2483
+ Document sd;
2484
+ sd.Parse(schema);
2485
+ ASSERT_FALSE(sd.HasParseError());
2486
+ SchemaDocument s(sd);
2487
+ VALIDATE(s, "{\"gender\":\"M\"}", true);
2488
+ INVALIDATE_(s, "{\"gender\":\"X\"}", "#", "errors", "#",
2489
+ "{\"enum\": {\"errorCode\": 19, \"instanceRef\": \"#/gender\", \"schemaRef\": \"#/properties/gender\"}}",
2490
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2491
+ INVALIDATE_(s, "{\"gender\":1}", "#", "errors", "#",
2492
+ "{\"type\": {\"expected\":[\"string\"], \"actual\": \"integer\", \"errorCode\": 20, \"instanceRef\": \"#/gender\", \"schemaRef\": \"#/properties/gender\"}}",
2493
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2494
+ CrtAllocator::Free(schema);
2495
+ }
2496
+
2497
+ // Test that when kValidateContinueOnErrorFlag is set, an array appearing for an object property is handled
2498
+ // This tests that we don't blow up when there is a type mismatch.
2499
+ TEST(SchemaValidator, ContinueOnErrors_RogueArray) {
2500
+ CrtAllocator allocator;
2501
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2502
+ Document sd;
2503
+ sd.Parse(schema);
2504
+ ASSERT_FALSE(sd.HasParseError());
2505
+ SchemaDocument s(sd);
2506
+ INVALIDATE_(s, "{\"address\":[{\"number\": 0}]}", "#", "errors", "#",
2507
+ "{\"type\": {\"expected\":[\"object\"], \"actual\": \"array\", \"errorCode\": 20, \"instanceRef\": \"#/address\", \"schemaRef\": \"#/definitions/address_type\"},"
2508
+ " \"dependencies\": {"
2509
+ " \"errors\": {"
2510
+ " \"address\": {\"required\": {\"missing\": [\"version\"], \"errorCode\": 15, \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/address\"}}"
2511
+ " },\"errorCode\": 18, \"instanceRef\": \"#\", \"schemaRef\": \"#\"}}",
2512
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2513
+ CrtAllocator::Free(schema);
2514
+ }
2515
+
2516
+ // Test that when kValidateContinueOnErrorFlag is set, an object appearing for an array property is handled
2517
+ // This tests that we don't blow up when there is a type mismatch.
2518
+ TEST(SchemaValidator, ContinueOnErrors_RogueObject) {
2519
+ CrtAllocator allocator;
2520
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2521
+ Document sd;
2522
+ sd.Parse(schema);
2523
+ ASSERT_FALSE(sd.HasParseError());
2524
+ SchemaDocument s(sd);
2525
+ INVALIDATE_(s, "{\"phones\":{\"number\": 0}}", "#", "errors", "#",
2526
+ "{\"type\": {\"expected\":[\"array\"], \"actual\": \"object\", \"errorCode\": 20, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\"}}",
2527
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2528
+ CrtAllocator::Free(schema);
2529
+ }
2530
+
2531
+ // Test that when kValidateContinueOnErrorFlag is set, a string appearing for an array or object property is handled
2532
+ // This tests that we don't blow up when there is a type mismatch.
2533
+ TEST(SchemaValidator, ContinueOnErrors_RogueString) {
2534
+ CrtAllocator allocator;
2535
+ char* schema = ReadFile("unittestschema/address.json", allocator);
2536
+ Document sd;
2537
+ sd.Parse(schema);
2538
+ ASSERT_FALSE(sd.HasParseError());
2539
+ SchemaDocument s(sd);
2540
+ INVALIDATE_(s, "{\"address\":\"number\"}", "#", "errors", "#",
2541
+ "{\"type\": {\"expected\":[\"object\"], \"actual\": \"string\", \"errorCode\": 20, \"instanceRef\": \"#/address\", \"schemaRef\": \"#/definitions/address_type\"},"
2542
+ " \"dependencies\": {"
2543
+ " \"errors\": {"
2544
+ " \"address\": {\"required\": {\"missing\": [\"version\"], \"errorCode\": 15, \"instanceRef\": \"#\", \"schemaRef\": \"#/dependencies/address\"}}"
2545
+ " },\"errorCode\": 18, \"instanceRef\": \"#\", \"schemaRef\": \"#\"}}",
2546
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2547
+ INVALIDATE_(s, "{\"phones\":\"number\"}", "#", "errors", "#",
2548
+ "{\"type\": {\"expected\":[\"array\"], \"actual\": \"string\", \"errorCode\": 20, \"instanceRef\": \"#/phones\", \"schemaRef\": \"#/properties/phones\"}}",
2549
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2550
+ CrtAllocator::Free(schema);
2551
+ }
2552
+
2553
+ // Test that when kValidateContinueOnErrorFlag is set, an incorrect simple type with a sub-schema is handled correctly.
2554
+ // This tests that we don't blow up when there is a type mismatch but there is a sub-schema present
2555
+ TEST(SchemaValidator, ContinueOnErrors_Issue2) {
2556
+ Document sd;
2557
+ sd.Parse("{\"type\":\"string\", \"anyOf\":[{\"maxLength\":2}]}");
2558
+ ASSERT_FALSE(sd.HasParseError());
2559
+ SchemaDocument s(sd);
2560
+ VALIDATE(s, "\"AB\"", true);
2561
+ INVALIDATE_(s, "\"ABC\"", "#", "errors", "#",
2562
+ "{ \"anyOf\": {"
2563
+ " \"errors\": [{"
2564
+ " \"maxLength\": {"
2565
+ " \"errorCode\": 6, \"instanceRef\": \"#\", \"schemaRef\": \"#/anyOf/0\", \"expected\": 2, \"actual\": \"ABC\""
2566
+ " }"
2567
+ " }],"
2568
+ " \"errorCode\": 24, \"instanceRef\": \"#\", \"schemaRef\": \"#\""
2569
+ " }"
2570
+ "}",
2571
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2572
+ // Invalid type
2573
+ INVALIDATE_(s, "333", "#", "errors", "#",
2574
+ "{ \"type\": {"
2575
+ " \"errorCode\": 20, \"instanceRef\": \"#\", \"schemaRef\": \"#\", \"expected\": [\"string\"], \"actual\": \"integer\""
2576
+ " }"
2577
+ "}",
2578
+ kValidateDefaultFlags | kValidateContinueOnErrorFlag, SchemaValidator, Pointer);
2579
+ }
2580
+
2581
+ TEST(SchemaValidator, Schema_UnknownError) {
2582
+ ASSERT_TRUE(SchemaValidator::SchemaType::GetValidateErrorKeyword(kValidateErrors).GetString() == std::string("null"));
2583
+ }
2584
+
2070
2585
  #if defined(_MSC_VER) || defined(__clang__)
2071
2586
  RAPIDJSON_DIAG_POP
2072
2587
  #endif