rj_schema 0.2.4 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (627) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rj_schema/rapidjson/CHANGELOG.md +158 -0
  3. data/ext/rj_schema/rapidjson/CMakeLists.txt +248 -0
  4. data/ext/rj_schema/rapidjson/CMakeModules/FindGTestSrc.cmake +30 -0
  5. data/ext/rj_schema/rapidjson/RapidJSON.pc.in +7 -0
  6. data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +25 -0
  7. data/ext/rj_schema/rapidjson/RapidJSONConfigVersion.cmake.in +10 -0
  8. data/ext/rj_schema/rapidjson/appveyor.yml +102 -0
  9. data/ext/rj_schema/rapidjson/bin/data/abcde.txt +1 -0
  10. data/ext/rj_schema/rapidjson/bin/data/glossary.json +22 -0
  11. data/ext/rj_schema/rapidjson/bin/data/menu.json +27 -0
  12. data/ext/rj_schema/rapidjson/bin/data/readme.txt +1 -0
  13. data/ext/rj_schema/rapidjson/bin/data/sample.json +3315 -0
  14. data/ext/rj_schema/rapidjson/bin/data/webapp.json +88 -0
  15. data/ext/rj_schema/rapidjson/bin/data/widget.json +26 -0
  16. data/ext/rj_schema/rapidjson/bin/draft-04/schema +150 -0
  17. data/ext/rj_schema/rapidjson/bin/encodings/utf16be.json +0 -0
  18. data/ext/rj_schema/rapidjson/bin/encodings/utf16bebom.json +0 -0
  19. data/ext/rj_schema/rapidjson/bin/encodings/utf16le.json +0 -0
  20. data/ext/rj_schema/rapidjson/bin/encodings/utf16lebom.json +0 -0
  21. data/ext/rj_schema/rapidjson/bin/encodings/utf32be.json +0 -0
  22. data/ext/rj_schema/rapidjson/bin/encodings/utf32bebom.json +0 -0
  23. data/ext/rj_schema/rapidjson/bin/encodings/utf32le.json +0 -0
  24. data/ext/rj_schema/rapidjson/bin/encodings/utf32lebom.json +0 -0
  25. data/ext/rj_schema/rapidjson/bin/encodings/utf8.json +7 -0
  26. data/ext/rj_schema/rapidjson/bin/encodings/utf8bom.json +7 -0
  27. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail1.json +1 -0
  28. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail10.json +1 -0
  29. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail11.json +1 -0
  30. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail12.json +1 -0
  31. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail13.json +1 -0
  32. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail14.json +1 -0
  33. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail15.json +1 -0
  34. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail16.json +1 -0
  35. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail17.json +1 -0
  36. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail18.json +1 -0
  37. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail19.json +1 -0
  38. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail2.json +1 -0
  39. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail20.json +1 -0
  40. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail21.json +1 -0
  41. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail22.json +1 -0
  42. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail23.json +1 -0
  43. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail24.json +1 -0
  44. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail25.json +1 -0
  45. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail26.json +1 -0
  46. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail27.json +2 -0
  47. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail28.json +2 -0
  48. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail29.json +1 -0
  49. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail3.json +1 -0
  50. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail30.json +1 -0
  51. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail31.json +1 -0
  52. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail32.json +1 -0
  53. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail33.json +1 -0
  54. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail4.json +1 -0
  55. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail5.json +1 -0
  56. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail6.json +1 -0
  57. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail7.json +1 -0
  58. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail8.json +1 -0
  59. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail9.json +1 -0
  60. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass1.json +58 -0
  61. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass2.json +1 -0
  62. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass3.json +6 -0
  63. data/ext/rj_schema/rapidjson/bin/jsonchecker/readme.txt +3 -0
  64. data/ext/rj_schema/rapidjson/bin/jsonschema/LICENSE +19 -0
  65. data/ext/rj_schema/rapidjson/bin/jsonschema/README.md +148 -0
  66. data/ext/rj_schema/rapidjson/bin/jsonschema/bin/jsonschema_suite +283 -0
  67. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/folder/folderInteger.json +3 -0
  68. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/integer.json +3 -0
  69. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/subSchemas.json +8 -0
  70. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalItems.json +82 -0
  71. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalProperties.json +88 -0
  72. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/default.json +49 -0
  73. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/dependencies.json +108 -0
  74. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/disallow.json +80 -0
  75. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/divisibleBy.json +60 -0
  76. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/enum.json +71 -0
  77. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/extends.json +94 -0
  78. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/items.json +46 -0
  79. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxItems.json +28 -0
  80. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxLength.json +33 -0
  81. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maximum.json +42 -0
  82. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minItems.json +28 -0
  83. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minLength.json +33 -0
  84. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minimum.json +42 -0
  85. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/bignum.json +107 -0
  86. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/format.json +222 -0
  87. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/jsregex.json +18 -0
  88. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/zeroTerminatedFloats.json +15 -0
  89. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/pattern.json +34 -0
  90. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/patternProperties.json +110 -0
  91. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/properties.json +92 -0
  92. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/ref.json +159 -0
  93. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/refRemote.json +74 -0
  94. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/required.json +53 -0
  95. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/type.json +474 -0
  96. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/uniqueItems.json +79 -0
  97. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalItems.json +82 -0
  98. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalProperties.json +88 -0
  99. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/allOf.json +112 -0
  100. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/anyOf.json +68 -0
  101. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/default.json +49 -0
  102. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/definitions.json +32 -0
  103. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/dependencies.json +113 -0
  104. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/enum.json +72 -0
  105. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/items.json +46 -0
  106. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxItems.json +28 -0
  107. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxLength.json +33 -0
  108. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxProperties.json +28 -0
  109. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maximum.json +42 -0
  110. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minItems.json +28 -0
  111. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minLength.json +33 -0
  112. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minProperties.json +28 -0
  113. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minimum.json +42 -0
  114. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/multipleOf.json +60 -0
  115. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/not.json +96 -0
  116. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/oneOf.json +68 -0
  117. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/bignum.json +107 -0
  118. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/format.json +148 -0
  119. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/zeroTerminatedFloats.json +15 -0
  120. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/pattern.json +34 -0
  121. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/patternProperties.json +110 -0
  122. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/properties.json +92 -0
  123. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/ref.json +159 -0
  124. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/refRemote.json +74 -0
  125. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/required.json +39 -0
  126. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/type.json +330 -0
  127. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/uniqueItems.json +79 -0
  128. data/ext/rj_schema/rapidjson/bin/jsonschema/tox.ini +8 -0
  129. data/ext/rj_schema/rapidjson/bin/types/alotofkeys.json +502 -0
  130. data/ext/rj_schema/rapidjson/bin/types/booleans.json +102 -0
  131. data/ext/rj_schema/rapidjson/bin/types/floats.json +102 -0
  132. data/ext/rj_schema/rapidjson/bin/types/guids.json +102 -0
  133. data/ext/rj_schema/rapidjson/bin/types/integers.json +102 -0
  134. data/ext/rj_schema/rapidjson/bin/types/mixed.json +592 -0
  135. data/ext/rj_schema/rapidjson/bin/types/nulls.json +102 -0
  136. data/ext/rj_schema/rapidjson/bin/types/paragraphs.json +102 -0
  137. data/ext/rj_schema/rapidjson/bin/types/readme.txt +1 -0
  138. data/ext/rj_schema/rapidjson/bin/unittestschema/address.json +139 -0
  139. data/ext/rj_schema/rapidjson/bin/unittestschema/allOf_address.json +7 -0
  140. data/ext/rj_schema/rapidjson/bin/unittestschema/anyOf_address.json +7 -0
  141. data/ext/rj_schema/rapidjson/bin/unittestschema/idandref.json +69 -0
  142. data/ext/rj_schema/rapidjson/bin/unittestschema/oneOf_address.json +7 -0
  143. data/ext/rj_schema/rapidjson/contrib/natvis/LICENSE +45 -0
  144. data/ext/rj_schema/rapidjson/contrib/natvis/README.md +7 -0
  145. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +38 -0
  146. data/ext/rj_schema/rapidjson/doc/CMakeLists.txt +27 -0
  147. data/ext/rj_schema/rapidjson/doc/Doxyfile.in +2369 -0
  148. data/ext/rj_schema/rapidjson/doc/Doxyfile.zh-cn.in +2369 -0
  149. data/ext/rj_schema/rapidjson/doc/diagram/architecture.dot +50 -0
  150. data/ext/rj_schema/rapidjson/doc/diagram/architecture.png +0 -0
  151. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.dot +65 -0
  152. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.png +0 -0
  153. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.dot +62 -0
  154. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.png +0 -0
  155. data/ext/rj_schema/rapidjson/doc/diagram/makefile +8 -0
  156. data/ext/rj_schema/rapidjson/doc/diagram/move1.dot +47 -0
  157. data/ext/rj_schema/rapidjson/doc/diagram/move1.png +0 -0
  158. data/ext/rj_schema/rapidjson/doc/diagram/move2.dot +62 -0
  159. data/ext/rj_schema/rapidjson/doc/diagram/move2.png +0 -0
  160. data/ext/rj_schema/rapidjson/doc/diagram/move3.dot +60 -0
  161. data/ext/rj_schema/rapidjson/doc/diagram/move3.png +0 -0
  162. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.dot +56 -0
  163. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.png +0 -0
  164. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.dot +54 -0
  165. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.png +0 -0
  166. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.dot +58 -0
  167. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.png +0 -0
  168. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.dot +73 -0
  169. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.png +0 -0
  170. data/ext/rj_schema/rapidjson/doc/dom.md +281 -0
  171. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +285 -0
  172. data/ext/rj_schema/rapidjson/doc/encoding.md +146 -0
  173. data/ext/rj_schema/rapidjson/doc/encoding.zh-cn.md +152 -0
  174. data/ext/rj_schema/rapidjson/doc/faq.md +289 -0
  175. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +290 -0
  176. data/ext/rj_schema/rapidjson/doc/features.md +104 -0
  177. data/ext/rj_schema/rapidjson/doc/features.zh-cn.md +103 -0
  178. data/ext/rj_schema/rapidjson/doc/internals.md +368 -0
  179. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +363 -0
  180. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.png +0 -0
  181. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.svg +119 -0
  182. data/ext/rj_schema/rapidjson/doc/misc/DoxygenLayout.xml +194 -0
  183. data/ext/rj_schema/rapidjson/doc/misc/doxygenextra.css +274 -0
  184. data/ext/rj_schema/rapidjson/doc/misc/footer.html +11 -0
  185. data/ext/rj_schema/rapidjson/doc/misc/header.html +24 -0
  186. data/ext/rj_schema/rapidjson/doc/npm.md +31 -0
  187. data/ext/rj_schema/rapidjson/doc/performance.md +26 -0
  188. data/ext/rj_schema/rapidjson/doc/performance.zh-cn.md +26 -0
  189. data/ext/rj_schema/rapidjson/doc/pointer.md +234 -0
  190. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +234 -0
  191. data/ext/rj_schema/rapidjson/doc/sax.md +509 -0
  192. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +487 -0
  193. data/ext/rj_schema/rapidjson/doc/schema.md +505 -0
  194. data/ext/rj_schema/rapidjson/doc/schema.zh-cn.md +237 -0
  195. data/ext/rj_schema/rapidjson/doc/stream.md +429 -0
  196. data/ext/rj_schema/rapidjson/doc/stream.zh-cn.md +429 -0
  197. data/ext/rj_schema/rapidjson/doc/tutorial.md +536 -0
  198. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +535 -0
  199. data/ext/rj_schema/rapidjson/docker/debian/Dockerfile +8 -0
  200. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +46 -0
  201. data/ext/rj_schema/rapidjson/example/archiver/archiver.cpp +292 -0
  202. data/ext/rj_schema/rapidjson/example/archiver/archiver.h +145 -0
  203. data/ext/rj_schema/rapidjson/example/archiver/archivertest.cpp +287 -0
  204. data/ext/rj_schema/rapidjson/example/capitalize/capitalize.cpp +67 -0
  205. data/ext/rj_schema/rapidjson/example/condense/condense.cpp +32 -0
  206. data/ext/rj_schema/rapidjson/example/filterkey/filterkey.cpp +135 -0
  207. data/ext/rj_schema/rapidjson/example/filterkeydom/filterkeydom.cpp +170 -0
  208. data/ext/rj_schema/rapidjson/example/jsonx/jsonx.cpp +207 -0
  209. data/ext/rj_schema/rapidjson/example/lookaheadparser/lookaheadparser.cpp +350 -0
  210. data/ext/rj_schema/rapidjson/example/messagereader/messagereader.cpp +105 -0
  211. data/ext/rj_schema/rapidjson/example/parsebyparts/parsebyparts.cpp +176 -0
  212. data/ext/rj_schema/rapidjson/example/pretty/pretty.cpp +30 -0
  213. data/ext/rj_schema/rapidjson/example/prettyauto/prettyauto.cpp +56 -0
  214. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +198 -0
  215. data/ext/rj_schema/rapidjson/example/serialize/serialize.cpp +173 -0
  216. data/ext/rj_schema/rapidjson/example/simpledom/simpledom.cpp +29 -0
  217. data/ext/rj_schema/rapidjson/example/simplepullreader/simplepullreader.cpp +53 -0
  218. data/ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp +42 -0
  219. data/ext/rj_schema/rapidjson/example/simplewriter/simplewriter.cpp +36 -0
  220. data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
  221. data/ext/rj_schema/rapidjson/example/traverseaspointer.cpp +39 -0
  222. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +151 -0
  223. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +692 -0
  224. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +78 -0
  225. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +3027 -0
  226. data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +299 -0
  227. data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +716 -0
  228. data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +122 -0
  229. data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +216 -0
  230. data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +99 -0
  231. data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +104 -0
  232. data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +151 -0
  233. data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +290 -0
  234. data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
  235. data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +257 -0
  236. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +245 -0
  237. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +78 -0
  238. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +308 -0
  239. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +186 -0
  240. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +55 -0
  241. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +739 -0
  242. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +232 -0
  243. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +83 -0
  244. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +290 -0
  245. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +46 -0
  246. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +128 -0
  247. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +70 -0
  248. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +71 -0
  249. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/inttypes.h +316 -0
  250. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/stdint.h +300 -0
  251. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +81 -0
  252. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +1482 -0
  253. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +277 -0
  254. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +741 -0
  255. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +2244 -0
  256. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +2795 -0
  257. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +223 -0
  258. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +121 -0
  259. data/ext/rj_schema/rapidjson/include/rapidjson/uri.h +466 -0
  260. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +710 -0
  261. data/ext/rj_schema/rapidjson/include_dirs.js +2 -0
  262. data/ext/rj_schema/rapidjson/library.json +15 -0
  263. data/ext/rj_schema/rapidjson/license.txt +57 -0
  264. data/ext/rj_schema/rapidjson/package.json +24 -0
  265. data/ext/rj_schema/rapidjson/rapidjson.autopkg +77 -0
  266. data/ext/rj_schema/rapidjson/readme.md +210 -0
  267. data/ext/rj_schema/rapidjson/readme.zh-cn.md +152 -0
  268. data/ext/rj_schema/rapidjson/test/CMakeLists.txt +20 -0
  269. data/ext/rj_schema/rapidjson/test/perftest/CMakeLists.txt +28 -0
  270. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +974 -0
  271. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +24 -0
  272. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +186 -0
  273. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +166 -0
  274. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +564 -0
  275. data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +223 -0
  276. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +95 -0
  277. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +292 -0
  278. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +138 -0
  279. data/ext/rj_schema/rapidjson/test/unittest/clzlltest.cpp +34 -0
  280. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +115 -0
  281. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +674 -0
  282. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +98 -0
  283. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +313 -0
  284. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +451 -0
  285. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +155 -0
  286. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +230 -0
  287. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +181 -0
  288. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +160 -0
  289. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +143 -0
  290. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +70 -0
  291. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +92 -0
  292. data/ext/rj_schema/rapidjson/test/unittest/platformtest.cpp +40 -0
  293. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +1730 -0
  294. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +373 -0
  295. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +2228 -0
  296. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +639 -0
  297. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +2952 -0
  298. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +219 -0
  299. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +30 -0
  300. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +192 -0
  301. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +132 -0
  302. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +51 -0
  303. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +143 -0
  304. data/ext/rj_schema/rapidjson/test/unittest/uritest.cpp +718 -0
  305. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +1861 -0
  306. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +598 -0
  307. data/ext/rj_schema/rapidjson/test/valgrind.supp +17 -0
  308. data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
  309. data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +33 -0
  310. data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
  311. data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
  312. data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
  313. data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +122 -0
  314. data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
  315. data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
  316. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
  317. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
  318. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
  319. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
  320. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
  321. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
  322. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
  323. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
  324. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
  325. data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
  326. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +126 -0
  327. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +242 -0
  328. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CONTRIBUTORS +40 -0
  329. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/LICENSE +28 -0
  330. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/Makefile.am +224 -0
  331. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +344 -0
  332. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
  333. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
  334. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +146 -0
  335. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +564 -0
  336. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +3660 -0
  337. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DesignDoc.md +280 -0
  338. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +15 -0
  339. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +447 -0
  340. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +627 -0
  341. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/KnownIssues.md +19 -0
  342. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +1262 -0
  343. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-cardinalities.h +147 -0
  344. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +2571 -0
  345. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +833 -0
  346. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +1379 -0
  347. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +347 -0
  348. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +2258 -0
  349. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +675 -0
  350. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +458 -0
  351. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +178 -0
  352. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +5255 -0
  353. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-actions.h +246 -0
  354. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +91 -0
  355. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +1918 -0
  356. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +95 -0
  357. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +8 -0
  358. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +10 -0
  359. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +38 -0
  360. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-port.h +46 -0
  361. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +286 -0
  362. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump +136 -0
  363. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +574 -0
  364. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +87 -0
  365. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/make/Makefile +101 -0
  366. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.sln +32 -0
  367. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.vcproj +191 -0
  368. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_config.vsprops +15 -0
  369. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_main.vcproj +187 -0
  370. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_test.vcproj +201 -0
  371. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +46 -0
  372. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +145 -0
  373. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +19 -0
  374. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +151 -0
  375. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +176 -0
  376. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +46 -0
  377. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +145 -0
  378. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_config.props +19 -0
  379. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +151 -0
  380. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +176 -0
  381. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +240 -0
  382. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/LICENSE +203 -0
  383. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +34 -0
  384. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README.cppclean +115 -0
  385. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/__init__.py +0 -0
  386. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +1733 -0
  387. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class.py +227 -0
  388. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class_test.py +448 -0
  389. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/keywords.py +59 -0
  390. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/tokenize.py +287 -0
  391. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/utils.py +41 -0
  392. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/gmock_gen.py +31 -0
  393. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock-config.in +303 -0
  394. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock_doctor.py +640 -0
  395. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload.py +1387 -0
  396. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload_gmock.py +78 -0
  397. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-all.cc +47 -0
  398. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +156 -0
  399. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +204 -0
  400. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +573 -0
  401. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +883 -0
  402. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +205 -0
  403. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock_main.cc +54 -0
  404. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
  405. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +1575 -0
  406. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +428 -0
  407. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +1230 -0
  408. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +647 -0
  409. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +129 -0
  410. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +1341 -0
  411. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +718 -0
  412. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +6767 -0
  413. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +710 -0
  414. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +511 -0
  415. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-port_test.cc +43 -0
  416. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +2771 -0
  417. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_all_test.cc +51 -0
  418. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_ex_test.cc +81 -0
  419. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test.py +108 -0
  420. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test_.cc +100 -0
  421. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +40 -0
  422. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +40 -0
  423. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +691 -0
  424. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +183 -0
  425. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +310 -0
  426. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +317 -0
  427. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +323 -0
  428. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +262 -0
  429. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +110 -0
  430. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CHANGES +157 -0
  431. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +312 -0
  432. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CONTRIBUTORS +37 -0
  433. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/LICENSE +28 -0
  434. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +339 -0
  435. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +341 -0
  436. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
  437. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
  438. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +280 -0
  439. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.cbproj +138 -0
  440. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.groupproj +54 -0
  441. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_all.cc +38 -0
  442. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_link.cc +40 -0
  443. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_main.cbproj +82 -0
  444. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_unittest.cbproj +88 -0
  445. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +68 -0
  446. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
  447. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +177 -0
  448. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +93 -0
  449. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/advanced.md +2416 -0
  450. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/faq.md +1092 -0
  451. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/primer.md +536 -0
  452. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/samples.md +14 -0
  453. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +342 -0
  454. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +249 -0
  455. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +1438 -0
  456. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +501 -0
  457. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +1082 -0
  458. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +231 -0
  459. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-test-part.h +179 -0
  460. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +264 -0
  461. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +2332 -0
  462. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +357 -0
  463. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +61 -0
  464. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +70 -0
  465. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
  466. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +45 -0
  467. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +275 -0
  468. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +205 -0
  469. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +1277 -0
  470. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
  471. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +5139 -0
  472. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +279 -0
  473. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +723 -0
  474. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +100 -0
  475. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +2687 -0
  476. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +167 -0
  477. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
  478. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
  479. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +3347 -0
  480. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +313 -0
  481. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/acx_pthread.m4 +363 -0
  482. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/gtest.m4 +74 -0
  483. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/make/Makefile +82 -0
  484. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
  485. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
  486. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
  487. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
  488. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
  489. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
  490. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
  491. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
  492. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
  493. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
  494. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
  495. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
  496. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
  497. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
  498. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
  499. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
  500. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
  501. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
  502. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +127 -0
  503. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +68 -0
  504. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.h +43 -0
  505. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +140 -0
  506. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +154 -0
  507. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.cc +56 -0
  508. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.h +85 -0
  509. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +110 -0
  510. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3-inl.h +172 -0
  511. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +152 -0
  512. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.cc +46 -0
  513. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.h +53 -0
  514. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +49 -0
  515. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +199 -0
  516. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +225 -0
  517. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +118 -0
  518. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +174 -0
  519. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +157 -0
  520. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/common.py +83 -0
  521. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +253 -0
  522. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +730 -0
  523. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gtest-config.in +274 -0
  524. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/pump.py +855 -0
  525. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/release_docs.py +158 -0
  526. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/test/Makefile +59 -0
  527. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1387 -0
  528. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload_gtest.py +78 -0
  529. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +48 -0
  530. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +1536 -0
  531. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +385 -0
  532. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +1175 -0
  533. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +1277 -0
  534. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +458 -0
  535. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +102 -0
  536. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +119 -0
  537. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +5846 -0
  538. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +38 -0
  539. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
  540. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_ex_test.cc +93 -0
  541. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +1424 -0
  542. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +652 -0
  543. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-linked_ptr_test.cc +154 -0
  544. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +311 -0
  545. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-message_test.cc +159 -0
  546. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +213 -0
  547. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +61 -0
  548. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +1110 -0
  549. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +53 -0
  550. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +1303 -0
  551. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +1737 -0
  552. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-test-part_test.cc +208 -0
  553. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-tuple_test.cc +320 -0
  554. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +45 -0
  555. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +380 -0
  556. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.h +66 -0
  557. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +341 -0
  558. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +47 -0
  559. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
  560. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +210 -0
  561. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +87 -0
  562. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +235 -0
  563. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +311 -0
  564. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +129 -0
  565. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +63 -0
  566. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +119 -0
  567. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +124 -0
  568. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +189 -0
  569. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +638 -0
  570. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +138 -0
  571. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +172 -0
  572. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test_.cc +46 -0
  573. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
  574. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
  575. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
  576. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +207 -0
  577. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest_.cc +157 -0
  578. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +45 -0
  579. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_no_test_unittest.cc +56 -0
  580. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +344 -0
  581. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +1067 -0
  582. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +781 -0
  583. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +2427 -0
  584. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_premature_exit_test.cc +127 -0
  585. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +57 -0
  586. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +236 -0
  587. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test.py +325 -0
  588. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test_.cc +103 -0
  589. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_sole_header_test.cc +57 -0
  590. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +250 -0
  591. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +318 -0
  592. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
  593. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
  594. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_ex_test.cc +92 -0
  595. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +171 -0
  596. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test_.cc +72 -0
  597. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +69 -0
  598. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +43 -0
  599. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +7797 -0
  600. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +48 -0
  601. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +48 -0
  602. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +140 -0
  603. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +378 -0
  604. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +179 -0
  605. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +196 -0
  606. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +36 -0
  607. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +55 -0
  608. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/DebugProject.xcconfig +30 -0
  609. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/FrameworkTarget.xcconfig +17 -0
  610. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/General.xcconfig +41 -0
  611. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/ReleaseProject.xcconfig +32 -0
  612. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/StaticLibraryTarget.xcconfig +18 -0
  613. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/TestTarget.xcconfig +8 -0
  614. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Resources/Info.plist +30 -0
  615. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/Info.plist +28 -0
  616. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj +457 -0
  617. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/runtests.sh +62 -0
  618. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.cc +63 -0
  619. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.h +59 -0
  620. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget_test.cc +68 -0
  621. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/runtests.sh +65 -0
  622. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +100 -0
  623. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +1182 -0
  624. data/ext/rj_schema/rapidjson/travis-doxygen.sh +128 -0
  625. data/ext/rj_schema/rj_schema.cpp +162 -18
  626. data/lib/rj_schema.rb +1 -1
  627. metadata +626 -3
@@ -0,0 +1,40 @@
1
+ // Tencent is pleased to support the open source community by making RapidJSON available.
2
+ //
3
+ // Copyright (C) 2021 THL A29 Limited, a Tencent company, and Milo Yip.
4
+ //
5
+ // Licensed under the MIT License (the "License"); you may not use this file except
6
+ // in compliance with the License. You may obtain a copy of the License at
7
+ //
8
+ // http://opensource.org/licenses/MIT
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software distributed
11
+ // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ // specific language governing permissions and limitations under the License.
14
+
15
+ #include "unittest.h"
16
+
17
+ // see https://github.com/Tencent/rapidjson/issues/1448
18
+ // including windows.h on purpose to provoke a compile time problem as GetObject is a
19
+ // macro that gets defined when windows.h is included
20
+ #ifdef _WIN32
21
+ #include <windows.h>
22
+ #endif
23
+
24
+ #include "rapidjson/document.h"
25
+ #undef GetObject
26
+
27
+ using namespace rapidjson;
28
+
29
+ TEST(Platform, GetObject) {
30
+ Document doc;
31
+ doc.Parse(" { \"object\" : { \"pi\": 3.1416} } ");
32
+ EXPECT_TRUE(doc.IsObject());
33
+ EXPECT_TRUE(doc.HasMember("object"));
34
+ const Document::ValueType& o = doc["object"];
35
+ EXPECT_TRUE(o.IsObject());
36
+ Value::ConstObject sub = o.GetObject();
37
+ EXPECT_TRUE(sub.HasMember("pi"));
38
+ Value::ConstObject sub2 = o.GetObj();
39
+ EXPECT_TRUE(sub2.HasMember("pi"));
40
+ }
@@ -0,0 +1,1730 @@
1
+ // Tencent is pleased to support the open source community by making RapidJSON available.
2
+ //
3
+ // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.
4
+ //
5
+ // Licensed under the MIT License (the "License"); you may not use this file except
6
+ // in compliance with the License. You may obtain a copy of the License at
7
+ //
8
+ // http://opensource.org/licenses/MIT
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software distributed
11
+ // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12
+ // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ // specific language governing permissions and limitations under the License.
14
+
15
+ #include "unittest.h"
16
+ #include "rapidjson/pointer.h"
17
+ #include "rapidjson/stringbuffer.h"
18
+ #include "rapidjson/ostreamwrapper.h"
19
+ #include <sstream>
20
+ #include <map>
21
+ #include <algorithm>
22
+
23
+ using namespace rapidjson;
24
+
25
+ static const char kJson[] = "{\n"
26
+ " \"foo\":[\"bar\", \"baz\"],\n"
27
+ " \"\" : 0,\n"
28
+ " \"a/b\" : 1,\n"
29
+ " \"c%d\" : 2,\n"
30
+ " \"e^f\" : 3,\n"
31
+ " \"g|h\" : 4,\n"
32
+ " \"i\\\\j\" : 5,\n"
33
+ " \"k\\\"l\" : 6,\n"
34
+ " \" \" : 7,\n"
35
+ " \"m~n\" : 8\n"
36
+ "}";
37
+
38
+ TEST(Pointer, DefaultConstructor) {
39
+ Pointer p;
40
+ EXPECT_TRUE(p.IsValid());
41
+ EXPECT_EQ(0u, p.GetTokenCount());
42
+ }
43
+
44
+ TEST(Pointer, Parse) {
45
+ {
46
+ Pointer p("");
47
+ EXPECT_TRUE(p.IsValid());
48
+ EXPECT_EQ(0u, p.GetTokenCount());
49
+ }
50
+
51
+ {
52
+ Pointer p("/");
53
+ EXPECT_TRUE(p.IsValid());
54
+ EXPECT_EQ(1u, p.GetTokenCount());
55
+ EXPECT_EQ(0u, p.GetTokens()[0].length);
56
+ EXPECT_STREQ("", p.GetTokens()[0].name);
57
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
58
+ }
59
+
60
+ {
61
+ Pointer p("/foo");
62
+ EXPECT_TRUE(p.IsValid());
63
+ EXPECT_EQ(1u, p.GetTokenCount());
64
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
65
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
66
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
67
+ }
68
+
69
+ #if RAPIDJSON_HAS_STDSTRING
70
+ {
71
+ Pointer p(std::string("/foo"));
72
+ EXPECT_TRUE(p.IsValid());
73
+ EXPECT_EQ(1u, p.GetTokenCount());
74
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
75
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
76
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
77
+ }
78
+ #endif
79
+
80
+ {
81
+ Pointer p("/foo/0");
82
+ EXPECT_TRUE(p.IsValid());
83
+ EXPECT_EQ(2u, p.GetTokenCount());
84
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
85
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
86
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
87
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
88
+ EXPECT_STREQ("0", p.GetTokens()[1].name);
89
+ EXPECT_EQ(0u, p.GetTokens()[1].index);
90
+ }
91
+
92
+ {
93
+ // Unescape ~1
94
+ Pointer p("/a~1b");
95
+ EXPECT_TRUE(p.IsValid());
96
+ EXPECT_EQ(1u, p.GetTokenCount());
97
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
98
+ EXPECT_STREQ("a/b", p.GetTokens()[0].name);
99
+ }
100
+
101
+ {
102
+ // Unescape ~0
103
+ Pointer p("/m~0n");
104
+ EXPECT_TRUE(p.IsValid());
105
+ EXPECT_EQ(1u, p.GetTokenCount());
106
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
107
+ EXPECT_STREQ("m~n", p.GetTokens()[0].name);
108
+ }
109
+
110
+ {
111
+ // empty name
112
+ Pointer p("/");
113
+ EXPECT_TRUE(p.IsValid());
114
+ EXPECT_EQ(1u, p.GetTokenCount());
115
+ EXPECT_EQ(0u, p.GetTokens()[0].length);
116
+ EXPECT_STREQ("", p.GetTokens()[0].name);
117
+ }
118
+
119
+ {
120
+ // empty and non-empty name
121
+ Pointer p("//a");
122
+ EXPECT_TRUE(p.IsValid());
123
+ EXPECT_EQ(2u, p.GetTokenCount());
124
+ EXPECT_EQ(0u, p.GetTokens()[0].length);
125
+ EXPECT_STREQ("", p.GetTokens()[0].name);
126
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
127
+ EXPECT_STREQ("a", p.GetTokens()[1].name);
128
+ }
129
+
130
+ {
131
+ // Null characters
132
+ Pointer p("/\0\0", 3);
133
+ EXPECT_TRUE(p.IsValid());
134
+ EXPECT_EQ(1u, p.GetTokenCount());
135
+ EXPECT_EQ(2u, p.GetTokens()[0].length);
136
+ EXPECT_EQ('\0', p.GetTokens()[0].name[0]);
137
+ EXPECT_EQ('\0', p.GetTokens()[0].name[1]);
138
+ EXPECT_EQ('\0', p.GetTokens()[0].name[2]);
139
+ }
140
+
141
+ {
142
+ // Valid index
143
+ Pointer p("/123");
144
+ EXPECT_TRUE(p.IsValid());
145
+ EXPECT_EQ(1u, p.GetTokenCount());
146
+ EXPECT_STREQ("123", p.GetTokens()[0].name);
147
+ EXPECT_EQ(123u, p.GetTokens()[0].index);
148
+ }
149
+
150
+ {
151
+ // Invalid index (with leading zero)
152
+ Pointer p("/01");
153
+ EXPECT_TRUE(p.IsValid());
154
+ EXPECT_EQ(1u, p.GetTokenCount());
155
+ EXPECT_STREQ("01", p.GetTokens()[0].name);
156
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
157
+ }
158
+
159
+ if (sizeof(SizeType) == 4) {
160
+ // Invalid index (overflow)
161
+ Pointer p("/4294967296");
162
+ EXPECT_TRUE(p.IsValid());
163
+ EXPECT_EQ(1u, p.GetTokenCount());
164
+ EXPECT_STREQ("4294967296", p.GetTokens()[0].name);
165
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
166
+ }
167
+
168
+ {
169
+ // kPointerParseErrorTokenMustBeginWithSolidus
170
+ Pointer p(" ");
171
+ EXPECT_FALSE(p.IsValid());
172
+ EXPECT_EQ(kPointerParseErrorTokenMustBeginWithSolidus, p.GetParseErrorCode());
173
+ EXPECT_EQ(0u, p.GetParseErrorOffset());
174
+ }
175
+
176
+ {
177
+ // kPointerParseErrorInvalidEscape
178
+ Pointer p("/~");
179
+ EXPECT_FALSE(p.IsValid());
180
+ EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());
181
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
182
+ }
183
+
184
+ {
185
+ // kPointerParseErrorInvalidEscape
186
+ Pointer p("/~2");
187
+ EXPECT_FALSE(p.IsValid());
188
+ EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());
189
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
190
+ }
191
+ }
192
+
193
+ TEST(Pointer, Parse_URIFragment) {
194
+ {
195
+ Pointer p("#");
196
+ EXPECT_TRUE(p.IsValid());
197
+ EXPECT_EQ(0u, p.GetTokenCount());
198
+ }
199
+
200
+ {
201
+ Pointer p("#/foo");
202
+ EXPECT_TRUE(p.IsValid());
203
+ EXPECT_EQ(1u, p.GetTokenCount());
204
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
205
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
206
+ }
207
+
208
+ {
209
+ Pointer p("#/foo/0");
210
+ EXPECT_TRUE(p.IsValid());
211
+ EXPECT_EQ(2u, p.GetTokenCount());
212
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
213
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
214
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
215
+ EXPECT_STREQ("0", p.GetTokens()[1].name);
216
+ EXPECT_EQ(0u, p.GetTokens()[1].index);
217
+ }
218
+
219
+ {
220
+ // Unescape ~1
221
+ Pointer p("#/a~1b");
222
+ EXPECT_TRUE(p.IsValid());
223
+ EXPECT_EQ(1u, p.GetTokenCount());
224
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
225
+ EXPECT_STREQ("a/b", p.GetTokens()[0].name);
226
+ }
227
+
228
+ {
229
+ // Unescape ~0
230
+ Pointer p("#/m~0n");
231
+ EXPECT_TRUE(p.IsValid());
232
+ EXPECT_EQ(1u, p.GetTokenCount());
233
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
234
+ EXPECT_STREQ("m~n", p.GetTokens()[0].name);
235
+ }
236
+
237
+ {
238
+ // empty name
239
+ Pointer p("#/");
240
+ EXPECT_TRUE(p.IsValid());
241
+ EXPECT_EQ(1u, p.GetTokenCount());
242
+ EXPECT_EQ(0u, p.GetTokens()[0].length);
243
+ EXPECT_STREQ("", p.GetTokens()[0].name);
244
+ }
245
+
246
+ {
247
+ // empty and non-empty name
248
+ Pointer p("#//a");
249
+ EXPECT_TRUE(p.IsValid());
250
+ EXPECT_EQ(2u, p.GetTokenCount());
251
+ EXPECT_EQ(0u, p.GetTokens()[0].length);
252
+ EXPECT_STREQ("", p.GetTokens()[0].name);
253
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
254
+ EXPECT_STREQ("a", p.GetTokens()[1].name);
255
+ }
256
+
257
+ {
258
+ // Null characters
259
+ Pointer p("#/%00%00");
260
+ EXPECT_TRUE(p.IsValid());
261
+ EXPECT_EQ(1u, p.GetTokenCount());
262
+ EXPECT_EQ(2u, p.GetTokens()[0].length);
263
+ EXPECT_EQ('\0', p.GetTokens()[0].name[0]);
264
+ EXPECT_EQ('\0', p.GetTokens()[0].name[1]);
265
+ EXPECT_EQ('\0', p.GetTokens()[0].name[2]);
266
+ }
267
+
268
+ {
269
+ // Percentage Escapes
270
+ EXPECT_STREQ("c%d", Pointer("#/c%25d").GetTokens()[0].name);
271
+ EXPECT_STREQ("e^f", Pointer("#/e%5Ef").GetTokens()[0].name);
272
+ EXPECT_STREQ("g|h", Pointer("#/g%7Ch").GetTokens()[0].name);
273
+ EXPECT_STREQ("i\\j", Pointer("#/i%5Cj").GetTokens()[0].name);
274
+ EXPECT_STREQ("k\"l", Pointer("#/k%22l").GetTokens()[0].name);
275
+ EXPECT_STREQ(" ", Pointer("#/%20").GetTokens()[0].name);
276
+ }
277
+
278
+ {
279
+ // Valid index
280
+ Pointer p("#/123");
281
+ EXPECT_TRUE(p.IsValid());
282
+ EXPECT_EQ(1u, p.GetTokenCount());
283
+ EXPECT_STREQ("123", p.GetTokens()[0].name);
284
+ EXPECT_EQ(123u, p.GetTokens()[0].index);
285
+ }
286
+
287
+ {
288
+ // Invalid index (with leading zero)
289
+ Pointer p("#/01");
290
+ EXPECT_TRUE(p.IsValid());
291
+ EXPECT_EQ(1u, p.GetTokenCount());
292
+ EXPECT_STREQ("01", p.GetTokens()[0].name);
293
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
294
+ }
295
+
296
+ if (sizeof(SizeType) == 4) {
297
+ // Invalid index (overflow)
298
+ Pointer p("#/4294967296");
299
+ EXPECT_TRUE(p.IsValid());
300
+ EXPECT_EQ(1u, p.GetTokenCount());
301
+ EXPECT_STREQ("4294967296", p.GetTokens()[0].name);
302
+ EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);
303
+ }
304
+
305
+ {
306
+ // Decode UTF-8 perecent encoding to UTF-8
307
+ Pointer p("#/%C2%A2");
308
+ EXPECT_TRUE(p.IsValid());
309
+ EXPECT_EQ(1u, p.GetTokenCount());
310
+ EXPECT_STREQ("\xC2\xA2", p.GetTokens()[0].name);
311
+ }
312
+
313
+ {
314
+ // Decode UTF-8 perecent encoding to UTF-16
315
+ GenericPointer<GenericValue<UTF16<> > > p(L"#/%C2%A2");
316
+ EXPECT_TRUE(p.IsValid());
317
+ EXPECT_EQ(1u, p.GetTokenCount());
318
+ EXPECT_EQ(static_cast<UTF16<>::Ch>(0x00A2), p.GetTokens()[0].name[0]);
319
+ EXPECT_EQ(1u, p.GetTokens()[0].length);
320
+ }
321
+
322
+ {
323
+ // Decode UTF-8 perecent encoding to UTF-16
324
+ GenericPointer<GenericValue<UTF16<> > > p(L"#/%E2%82%AC");
325
+ EXPECT_TRUE(p.IsValid());
326
+ EXPECT_EQ(1u, p.GetTokenCount());
327
+ EXPECT_EQ(static_cast<UTF16<>::Ch>(0x20AC), p.GetTokens()[0].name[0]);
328
+ EXPECT_EQ(1u, p.GetTokens()[0].length);
329
+ }
330
+
331
+ {
332
+ // kPointerParseErrorTokenMustBeginWithSolidus
333
+ Pointer p("# ");
334
+ EXPECT_FALSE(p.IsValid());
335
+ EXPECT_EQ(kPointerParseErrorTokenMustBeginWithSolidus, p.GetParseErrorCode());
336
+ EXPECT_EQ(1u, p.GetParseErrorOffset());
337
+ }
338
+
339
+ {
340
+ // kPointerParseErrorInvalidEscape
341
+ Pointer p("#/~");
342
+ EXPECT_FALSE(p.IsValid());
343
+ EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());
344
+ EXPECT_EQ(3u, p.GetParseErrorOffset());
345
+ }
346
+
347
+ {
348
+ // kPointerParseErrorInvalidEscape
349
+ Pointer p("#/~2");
350
+ EXPECT_FALSE(p.IsValid());
351
+ EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());
352
+ EXPECT_EQ(3u, p.GetParseErrorOffset());
353
+ }
354
+
355
+ {
356
+ // kPointerParseErrorInvalidPercentEncoding
357
+ Pointer p("#/%");
358
+ EXPECT_FALSE(p.IsValid());
359
+ EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());
360
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
361
+ }
362
+
363
+ {
364
+ // kPointerParseErrorInvalidPercentEncoding (invalid hex)
365
+ Pointer p("#/%g0");
366
+ EXPECT_FALSE(p.IsValid());
367
+ EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());
368
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
369
+ }
370
+
371
+ {
372
+ // kPointerParseErrorInvalidPercentEncoding (invalid hex)
373
+ Pointer p("#/%0g");
374
+ EXPECT_FALSE(p.IsValid());
375
+ EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());
376
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
377
+ }
378
+
379
+ {
380
+ // kPointerParseErrorInvalidPercentEncoding (incomplete UTF-8 sequence)
381
+ Pointer p("#/%C2");
382
+ EXPECT_FALSE(p.IsValid());
383
+ EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());
384
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
385
+ }
386
+
387
+ {
388
+ // kPointerParseErrorCharacterMustPercentEncode
389
+ Pointer p("#/ ");
390
+ EXPECT_FALSE(p.IsValid());
391
+ EXPECT_EQ(kPointerParseErrorCharacterMustPercentEncode, p.GetParseErrorCode());
392
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
393
+ }
394
+
395
+ {
396
+ // kPointerParseErrorCharacterMustPercentEncode
397
+ Pointer p("#/\n");
398
+ EXPECT_FALSE(p.IsValid());
399
+ EXPECT_EQ(kPointerParseErrorCharacterMustPercentEncode, p.GetParseErrorCode());
400
+ EXPECT_EQ(2u, p.GetParseErrorOffset());
401
+ }
402
+ }
403
+
404
+ TEST(Pointer, Stringify) {
405
+ // Test by roundtrip
406
+ const char* sources[] = {
407
+ "",
408
+ "/foo",
409
+ "/foo/0",
410
+ "/",
411
+ "/a~1b",
412
+ "/c%d",
413
+ "/e^f",
414
+ "/g|h",
415
+ "/i\\j",
416
+ "/k\"l",
417
+ "/ ",
418
+ "/m~0n",
419
+ "/\xC2\xA2",
420
+ "/\xE2\x82\xAC",
421
+ "/\xF0\x9D\x84\x9E"
422
+ };
423
+
424
+ for (size_t i = 0; i < sizeof(sources) / sizeof(sources[0]); i++) {
425
+ Pointer p(sources[i]);
426
+ StringBuffer s;
427
+ EXPECT_TRUE(p.Stringify(s));
428
+ EXPECT_STREQ(sources[i], s.GetString());
429
+
430
+ // Stringify to URI fragment
431
+ StringBuffer s2;
432
+ EXPECT_TRUE(p.StringifyUriFragment(s2));
433
+ Pointer p2(s2.GetString(), s2.GetSize());
434
+ EXPECT_TRUE(p2.IsValid());
435
+ EXPECT_TRUE(p == p2);
436
+ }
437
+
438
+ {
439
+ // Strigify to URI fragment with an invalid UTF-8 sequence
440
+ Pointer p("/\xC2");
441
+ StringBuffer s;
442
+ EXPECT_FALSE(p.StringifyUriFragment(s));
443
+ }
444
+ }
445
+
446
+ // Construct a Pointer with static tokens, no dynamic allocation involved.
447
+ #define NAME(s) { s, static_cast<SizeType>(sizeof(s) / sizeof(s[0]) - 1), kPointerInvalidIndex }
448
+ #define INDEX(i) { #i, static_cast<SizeType>(sizeof(#i) - 1), i }
449
+
450
+ static const Pointer::Token kTokens[] = { NAME("foo"), INDEX(0) }; // equivalent to "/foo/0"
451
+
452
+ #undef NAME
453
+ #undef INDEX
454
+
455
+ TEST(Pointer, ConstructorWithToken) {
456
+ Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));
457
+ EXPECT_TRUE(p.IsValid());
458
+ EXPECT_EQ(2u, p.GetTokenCount());
459
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
460
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
461
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
462
+ EXPECT_STREQ("0", p.GetTokens()[1].name);
463
+ EXPECT_EQ(0u, p.GetTokens()[1].index);
464
+ }
465
+
466
+ TEST(Pointer, CopyConstructor) {
467
+ {
468
+ CrtAllocator allocator;
469
+ Pointer p("/foo/0", &allocator);
470
+ Pointer q(p);
471
+ EXPECT_TRUE(q.IsValid());
472
+ EXPECT_EQ(2u, q.GetTokenCount());
473
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
474
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
475
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
476
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
477
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
478
+
479
+ // Copied pointer needs to have its own allocator
480
+ EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
481
+ }
482
+
483
+ // Static tokens
484
+ {
485
+ Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));
486
+ Pointer q(p);
487
+ EXPECT_TRUE(q.IsValid());
488
+ EXPECT_EQ(2u, q.GetTokenCount());
489
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
490
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
491
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
492
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
493
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
494
+ }
495
+ }
496
+
497
+ TEST(Pointer, Assignment) {
498
+ {
499
+ CrtAllocator allocator;
500
+ Pointer p("/foo/0", &allocator);
501
+ Pointer q;
502
+ q = p;
503
+ EXPECT_TRUE(q.IsValid());
504
+ EXPECT_EQ(2u, q.GetTokenCount());
505
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
506
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
507
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
508
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
509
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
510
+ EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
511
+ q = static_cast<const Pointer &>(q);
512
+ EXPECT_TRUE(q.IsValid());
513
+ EXPECT_EQ(2u, q.GetTokenCount());
514
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
515
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
516
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
517
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
518
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
519
+ EXPECT_NE(&p.GetAllocator(), &q.GetAllocator());
520
+ }
521
+
522
+ // Static tokens
523
+ {
524
+ Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));
525
+ Pointer q;
526
+ q = p;
527
+ EXPECT_TRUE(q.IsValid());
528
+ EXPECT_EQ(2u, q.GetTokenCount());
529
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
530
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
531
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
532
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
533
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
534
+ }
535
+ }
536
+
537
+ TEST(Pointer, Swap) {
538
+ Pointer p("/foo/0");
539
+ Pointer q(&p.GetAllocator());
540
+
541
+ q.Swap(p);
542
+ EXPECT_EQ(&q.GetAllocator(), &p.GetAllocator());
543
+ EXPECT_TRUE(p.IsValid());
544
+ EXPECT_TRUE(q.IsValid());
545
+ EXPECT_EQ(0u, p.GetTokenCount());
546
+ EXPECT_EQ(2u, q.GetTokenCount());
547
+ EXPECT_EQ(3u, q.GetTokens()[0].length);
548
+ EXPECT_STREQ("foo", q.GetTokens()[0].name);
549
+ EXPECT_EQ(1u, q.GetTokens()[1].length);
550
+ EXPECT_STREQ("0", q.GetTokens()[1].name);
551
+ EXPECT_EQ(0u, q.GetTokens()[1].index);
552
+
553
+ // std::swap compatibility
554
+ std::swap(p, q);
555
+ EXPECT_EQ(&p.GetAllocator(), &q.GetAllocator());
556
+ EXPECT_TRUE(q.IsValid());
557
+ EXPECT_TRUE(p.IsValid());
558
+ EXPECT_EQ(0u, q.GetTokenCount());
559
+ EXPECT_EQ(2u, p.GetTokenCount());
560
+ EXPECT_EQ(3u, p.GetTokens()[0].length);
561
+ EXPECT_STREQ("foo", p.GetTokens()[0].name);
562
+ EXPECT_EQ(1u, p.GetTokens()[1].length);
563
+ EXPECT_STREQ("0", p.GetTokens()[1].name);
564
+ EXPECT_EQ(0u, p.GetTokens()[1].index);
565
+ }
566
+
567
+ TEST(Pointer, Append) {
568
+ {
569
+ Pointer p;
570
+ Pointer q = p.Append("foo");
571
+ EXPECT_TRUE(Pointer("/foo") == q);
572
+ q = q.Append(1234);
573
+ EXPECT_TRUE(Pointer("/foo/1234") == q);
574
+ q = q.Append("");
575
+ EXPECT_TRUE(Pointer("/foo/1234/") == q);
576
+ }
577
+
578
+ {
579
+ Pointer p;
580
+ Pointer q = p.Append(Value("foo").Move());
581
+ EXPECT_TRUE(Pointer("/foo") == q);
582
+ q = q.Append(Value(1234).Move());
583
+ EXPECT_TRUE(Pointer("/foo/1234") == q);
584
+ q = q.Append(Value(kStringType).Move());
585
+ EXPECT_TRUE(Pointer("/foo/1234/") == q);
586
+ }
587
+
588
+ #if RAPIDJSON_HAS_STDSTRING
589
+ {
590
+ Pointer p;
591
+ Pointer q = p.Append(std::string("foo"));
592
+ EXPECT_TRUE(Pointer("/foo") == q);
593
+ }
594
+ #endif
595
+ }
596
+
597
+ TEST(Pointer, Equality) {
598
+ EXPECT_TRUE(Pointer("/foo/0") == Pointer("/foo/0"));
599
+ EXPECT_FALSE(Pointer("/foo/0") == Pointer("/foo/1"));
600
+ EXPECT_FALSE(Pointer("/foo/0") == Pointer("/foo/0/1"));
601
+ EXPECT_FALSE(Pointer("/foo/0") == Pointer("a"));
602
+ EXPECT_FALSE(Pointer("a") == Pointer("a")); // Invalid always not equal
603
+ }
604
+
605
+ TEST(Pointer, Inequality) {
606
+ EXPECT_FALSE(Pointer("/foo/0") != Pointer("/foo/0"));
607
+ EXPECT_TRUE(Pointer("/foo/0") != Pointer("/foo/1"));
608
+ EXPECT_TRUE(Pointer("/foo/0") != Pointer("/foo/0/1"));
609
+ EXPECT_TRUE(Pointer("/foo/0") != Pointer("a"));
610
+ EXPECT_TRUE(Pointer("a") != Pointer("a")); // Invalid always not equal
611
+ }
612
+
613
+ TEST(Pointer, Create) {
614
+ Document d;
615
+ {
616
+ Value* v = &Pointer("").Create(d, d.GetAllocator());
617
+ EXPECT_EQ(&d, v);
618
+ }
619
+ {
620
+ Value* v = &Pointer("/foo").Create(d, d.GetAllocator());
621
+ EXPECT_EQ(&d["foo"], v);
622
+ }
623
+ {
624
+ Value* v = &Pointer("/foo/0").Create(d, d.GetAllocator());
625
+ EXPECT_EQ(&d["foo"][0], v);
626
+ }
627
+ {
628
+ Value* v = &Pointer("/foo/-").Create(d, d.GetAllocator());
629
+ EXPECT_EQ(&d["foo"][1], v);
630
+ }
631
+
632
+ {
633
+ Value* v = &Pointer("/foo/-/-").Create(d, d.GetAllocator());
634
+ // "foo/-" is a newly created null value x.
635
+ // "foo/-/-" finds that x is not an array, it converts x to empty object
636
+ // and treats - as "-" member name
637
+ EXPECT_EQ(&d["foo"][2]["-"], v);
638
+ }
639
+
640
+ {
641
+ // Document with no allocator
642
+ Value* v = &Pointer("/foo/-").Create(d);
643
+ EXPECT_EQ(&d["foo"][3], v);
644
+ }
645
+
646
+ {
647
+ // Value (not document) must give allocator
648
+ Value* v = &Pointer("/-").Create(d["foo"], d.GetAllocator());
649
+ EXPECT_EQ(&d["foo"][4], v);
650
+ }
651
+ }
652
+
653
+ static const char kJsonIds[] = "{\n"
654
+ " \"id\": \"/root/\","
655
+ " \"foo\":[\"bar\", \"baz\", {\"id\": \"inarray\", \"child\": 1}],\n"
656
+ " \"int\" : 2,\n"
657
+ " \"str\" : \"val\",\n"
658
+ " \"obj\": {\"id\": \"inobj\", \"child\": 3},\n"
659
+ " \"jbo\": {\"id\": true, \"child\": 4}\n"
660
+ "}";
661
+
662
+
663
+ TEST(Pointer, GetUri) {
664
+ CrtAllocator allocator;
665
+ Document d;
666
+ d.Parse(kJsonIds);
667
+ Pointer::UriType doc("http://doc");
668
+ Pointer::UriType root("http://doc/root/");
669
+ Pointer::UriType empty = Pointer::UriType();
670
+
671
+ EXPECT_TRUE(Pointer("").GetUri(d, doc) == doc);
672
+ EXPECT_TRUE(Pointer("/foo").GetUri(d, doc) == root);
673
+ EXPECT_TRUE(Pointer("/foo/0").GetUri(d, doc) == root);
674
+ EXPECT_TRUE(Pointer("/foo/2").GetUri(d, doc) == root);
675
+ EXPECT_TRUE(Pointer("/foo/2/child").GetUri(d, doc) == Pointer::UriType("http://doc/root/inarray"));
676
+ EXPECT_TRUE(Pointer("/int").GetUri(d, doc) == root);
677
+ EXPECT_TRUE(Pointer("/str").GetUri(d, doc) == root);
678
+ EXPECT_TRUE(Pointer("/obj").GetUri(d, doc) == root);
679
+ EXPECT_TRUE(Pointer("/obj/child").GetUri(d, doc) == Pointer::UriType("http://doc/root/inobj"));
680
+ EXPECT_TRUE(Pointer("/jbo").GetUri(d, doc) == root);
681
+ EXPECT_TRUE(Pointer("/jbo/child").GetUri(d, doc) == root); // id not string
682
+
683
+ size_t unresolvedTokenIndex;
684
+ EXPECT_TRUE(Pointer("/abc").GetUri(d, doc, &unresolvedTokenIndex, &allocator) == empty); // Out of boundary
685
+ EXPECT_EQ(0u, unresolvedTokenIndex);
686
+ EXPECT_TRUE(Pointer("/foo/3").GetUri(d, doc, &unresolvedTokenIndex, &allocator) == empty); // Out of boundary
687
+ EXPECT_EQ(1u, unresolvedTokenIndex);
688
+ EXPECT_TRUE(Pointer("/foo/a").GetUri(d, doc, &unresolvedTokenIndex, &allocator) == empty); // "/foo" is an array, cannot query by "a"
689
+ EXPECT_EQ(1u, unresolvedTokenIndex);
690
+ EXPECT_TRUE(Pointer("/foo/0/0").GetUri(d, doc, &unresolvedTokenIndex, &allocator) == empty); // "/foo/0" is an string, cannot further query
691
+ EXPECT_EQ(2u, unresolvedTokenIndex);
692
+ EXPECT_TRUE(Pointer("/foo/0/a").GetUri(d, doc, &unresolvedTokenIndex, &allocator) == empty); // "/foo/0" is an string, cannot further query
693
+ EXPECT_EQ(2u, unresolvedTokenIndex);
694
+
695
+ Pointer::Token tokens[] = { { "foo ...", 3, kPointerInvalidIndex } };
696
+ EXPECT_TRUE(Pointer(tokens, 1).GetUri(d, doc) == root);
697
+ }
698
+
699
+ TEST(Pointer, Get) {
700
+ Document d;
701
+ d.Parse(kJson);
702
+
703
+ EXPECT_EQ(&d, Pointer("").Get(d));
704
+ EXPECT_EQ(&d["foo"], Pointer("/foo").Get(d));
705
+ EXPECT_EQ(&d["foo"][0], Pointer("/foo/0").Get(d));
706
+ EXPECT_EQ(&d[""], Pointer("/").Get(d));
707
+ EXPECT_EQ(&d["a/b"], Pointer("/a~1b").Get(d));
708
+ EXPECT_EQ(&d["c%d"], Pointer("/c%d").Get(d));
709
+ EXPECT_EQ(&d["e^f"], Pointer("/e^f").Get(d));
710
+ EXPECT_EQ(&d["g|h"], Pointer("/g|h").Get(d));
711
+ EXPECT_EQ(&d["i\\j"], Pointer("/i\\j").Get(d));
712
+ EXPECT_EQ(&d["k\"l"], Pointer("/k\"l").Get(d));
713
+ EXPECT_EQ(&d[" "], Pointer("/ ").Get(d));
714
+ EXPECT_EQ(&d["m~n"], Pointer("/m~0n").Get(d));
715
+
716
+ EXPECT_TRUE(Pointer("/abc").Get(d) == 0); // Out of boundary
717
+ size_t unresolvedTokenIndex;
718
+ EXPECT_TRUE(Pointer("/foo/2").Get(d, &unresolvedTokenIndex) == 0); // Out of boundary
719
+ EXPECT_EQ(1u, unresolvedTokenIndex);
720
+ EXPECT_TRUE(Pointer("/foo/a").Get(d, &unresolvedTokenIndex) == 0); // "/foo" is an array, cannot query by "a"
721
+ EXPECT_EQ(1u, unresolvedTokenIndex);
722
+ EXPECT_TRUE(Pointer("/foo/0/0").Get(d, &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
723
+ EXPECT_EQ(2u, unresolvedTokenIndex);
724
+ EXPECT_TRUE(Pointer("/foo/0/a").Get(d, &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
725
+ EXPECT_EQ(2u, unresolvedTokenIndex);
726
+
727
+ Pointer::Token tokens[] = { { "foo ...", 3, kPointerInvalidIndex } };
728
+ EXPECT_EQ(&d["foo"], Pointer(tokens, 1).Get(d));
729
+ }
730
+
731
+ TEST(Pointer, GetWithDefault) {
732
+ Document d;
733
+ d.Parse(kJson);
734
+
735
+ // Value version
736
+ Document::AllocatorType& a = d.GetAllocator();
737
+ const Value v("qux");
738
+ EXPECT_TRUE(Value("bar") == Pointer("/foo/0").GetWithDefault(d, v, a));
739
+ EXPECT_TRUE(Value("baz") == Pointer("/foo/1").GetWithDefault(d, v, a));
740
+ EXPECT_TRUE(Value("qux") == Pointer("/foo/2").GetWithDefault(d, v, a));
741
+ EXPECT_TRUE(Value("last") == Pointer("/foo/-").GetWithDefault(d, Value("last").Move(), a));
742
+ EXPECT_STREQ("last", d["foo"][3].GetString());
743
+
744
+ EXPECT_TRUE(Pointer("/foo/null").GetWithDefault(d, Value().Move(), a).IsNull());
745
+ EXPECT_TRUE(Pointer("/foo/null").GetWithDefault(d, "x", a).IsNull());
746
+
747
+ // Generic version
748
+ EXPECT_EQ(-1, Pointer("/foo/int").GetWithDefault(d, -1, a).GetInt());
749
+ EXPECT_EQ(-1, Pointer("/foo/int").GetWithDefault(d, -2, a).GetInt());
750
+ EXPECT_EQ(0x87654321, Pointer("/foo/uint").GetWithDefault(d, 0x87654321, a).GetUint());
751
+ EXPECT_EQ(0x87654321, Pointer("/foo/uint").GetWithDefault(d, 0x12345678, a).GetUint());
752
+
753
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
754
+ EXPECT_EQ(i64, Pointer("/foo/int64").GetWithDefault(d, i64, a).GetInt64());
755
+ EXPECT_EQ(i64, Pointer("/foo/int64").GetWithDefault(d, i64 + 1, a).GetInt64());
756
+
757
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
758
+ EXPECT_EQ(u64, Pointer("/foo/uint64").GetWithDefault(d, u64, a).GetUint64());
759
+ EXPECT_EQ(u64, Pointer("/foo/uint64").GetWithDefault(d, u64 - 1, a).GetUint64());
760
+
761
+ EXPECT_TRUE(Pointer("/foo/true").GetWithDefault(d, true, a).IsTrue());
762
+ EXPECT_TRUE(Pointer("/foo/true").GetWithDefault(d, false, a).IsTrue());
763
+
764
+ EXPECT_TRUE(Pointer("/foo/false").GetWithDefault(d, false, a).IsFalse());
765
+ EXPECT_TRUE(Pointer("/foo/false").GetWithDefault(d, true, a).IsFalse());
766
+
767
+ // StringRef version
768
+ EXPECT_STREQ("Hello", Pointer("/foo/hello").GetWithDefault(d, "Hello", a).GetString());
769
+
770
+ // Copy string version
771
+ {
772
+ char buffer[256];
773
+ strcpy(buffer, "World");
774
+ EXPECT_STREQ("World", Pointer("/foo/world").GetWithDefault(d, buffer, a).GetString());
775
+ memset(buffer, 0, sizeof(buffer));
776
+ }
777
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
778
+
779
+ #if RAPIDJSON_HAS_STDSTRING
780
+ EXPECT_STREQ("C++", Pointer("/foo/C++").GetWithDefault(d, std::string("C++"), a).GetString());
781
+ #endif
782
+ }
783
+
784
+ TEST(Pointer, GetWithDefault_NoAllocator) {
785
+ Document d;
786
+ d.Parse(kJson);
787
+
788
+ // Value version
789
+ const Value v("qux");
790
+ EXPECT_TRUE(Value("bar") == Pointer("/foo/0").GetWithDefault(d, v));
791
+ EXPECT_TRUE(Value("baz") == Pointer("/foo/1").GetWithDefault(d, v));
792
+ EXPECT_TRUE(Value("qux") == Pointer("/foo/2").GetWithDefault(d, v));
793
+ EXPECT_TRUE(Value("last") == Pointer("/foo/-").GetWithDefault(d, Value("last").Move()));
794
+ EXPECT_STREQ("last", d["foo"][3].GetString());
795
+
796
+ EXPECT_TRUE(Pointer("/foo/null").GetWithDefault(d, Value().Move()).IsNull());
797
+ EXPECT_TRUE(Pointer("/foo/null").GetWithDefault(d, "x").IsNull());
798
+
799
+ // Generic version
800
+ EXPECT_EQ(-1, Pointer("/foo/int").GetWithDefault(d, -1).GetInt());
801
+ EXPECT_EQ(-1, Pointer("/foo/int").GetWithDefault(d, -2).GetInt());
802
+ EXPECT_EQ(0x87654321, Pointer("/foo/uint").GetWithDefault(d, 0x87654321).GetUint());
803
+ EXPECT_EQ(0x87654321, Pointer("/foo/uint").GetWithDefault(d, 0x12345678).GetUint());
804
+
805
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
806
+ EXPECT_EQ(i64, Pointer("/foo/int64").GetWithDefault(d, i64).GetInt64());
807
+ EXPECT_EQ(i64, Pointer("/foo/int64").GetWithDefault(d, i64 + 1).GetInt64());
808
+
809
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
810
+ EXPECT_EQ(u64, Pointer("/foo/uint64").GetWithDefault(d, u64).GetUint64());
811
+ EXPECT_EQ(u64, Pointer("/foo/uint64").GetWithDefault(d, u64 - 1).GetUint64());
812
+
813
+ EXPECT_TRUE(Pointer("/foo/true").GetWithDefault(d, true).IsTrue());
814
+ EXPECT_TRUE(Pointer("/foo/true").GetWithDefault(d, false).IsTrue());
815
+
816
+ EXPECT_TRUE(Pointer("/foo/false").GetWithDefault(d, false).IsFalse());
817
+ EXPECT_TRUE(Pointer("/foo/false").GetWithDefault(d, true).IsFalse());
818
+
819
+ // StringRef version
820
+ EXPECT_STREQ("Hello", Pointer("/foo/hello").GetWithDefault(d, "Hello").GetString());
821
+
822
+ // Copy string version
823
+ {
824
+ char buffer[256];
825
+ strcpy(buffer, "World");
826
+ EXPECT_STREQ("World", Pointer("/foo/world").GetWithDefault(d, buffer).GetString());
827
+ memset(buffer, 0, sizeof(buffer));
828
+ }
829
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
830
+
831
+ #if RAPIDJSON_HAS_STDSTRING
832
+ EXPECT_STREQ("C++", Pointer("/foo/C++").GetWithDefault(d, std::string("C++")).GetString());
833
+ #endif
834
+ }
835
+
836
+ TEST(Pointer, Set) {
837
+ Document d;
838
+ d.Parse(kJson);
839
+ Document::AllocatorType& a = d.GetAllocator();
840
+
841
+ // Value version
842
+ Pointer("/foo/0").Set(d, Value(123).Move(), a);
843
+ EXPECT_EQ(123, d["foo"][0].GetInt());
844
+
845
+ Pointer("/foo/-").Set(d, Value(456).Move(), a);
846
+ EXPECT_EQ(456, d["foo"][2].GetInt());
847
+
848
+ Pointer("/foo/null").Set(d, Value().Move(), a);
849
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
850
+
851
+ // Const Value version
852
+ const Value foo(d["foo"], a);
853
+ Pointer("/clone").Set(d, foo, a);
854
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
855
+
856
+ // Generic version
857
+ Pointer("/foo/int").Set(d, -1, a);
858
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
859
+
860
+ Pointer("/foo/uint").Set(d, 0x87654321, a);
861
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
862
+
863
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
864
+ Pointer("/foo/int64").Set(d, i64, a);
865
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
866
+
867
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
868
+ Pointer("/foo/uint64").Set(d, u64, a);
869
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
870
+
871
+ Pointer("/foo/true").Set(d, true, a);
872
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
873
+
874
+ Pointer("/foo/false").Set(d, false, a);
875
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
876
+
877
+ // StringRef version
878
+ Pointer("/foo/hello").Set(d, "Hello", a);
879
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
880
+
881
+ // Copy string version
882
+ {
883
+ char buffer[256];
884
+ strcpy(buffer, "World");
885
+ Pointer("/foo/world").Set(d, buffer, a);
886
+ memset(buffer, 0, sizeof(buffer));
887
+ }
888
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
889
+
890
+ #if RAPIDJSON_HAS_STDSTRING
891
+ Pointer("/foo/c++").Set(d, std::string("C++"), a);
892
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
893
+ #endif
894
+ }
895
+
896
+ TEST(Pointer, Set_NoAllocator) {
897
+ Document d;
898
+ d.Parse(kJson);
899
+
900
+ // Value version
901
+ Pointer("/foo/0").Set(d, Value(123).Move());
902
+ EXPECT_EQ(123, d["foo"][0].GetInt());
903
+
904
+ Pointer("/foo/-").Set(d, Value(456).Move());
905
+ EXPECT_EQ(456, d["foo"][2].GetInt());
906
+
907
+ Pointer("/foo/null").Set(d, Value().Move());
908
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
909
+
910
+ // Const Value version
911
+ const Value foo(d["foo"], d.GetAllocator());
912
+ Pointer("/clone").Set(d, foo);
913
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
914
+
915
+ // Generic version
916
+ Pointer("/foo/int").Set(d, -1);
917
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
918
+
919
+ Pointer("/foo/uint").Set(d, 0x87654321);
920
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
921
+
922
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
923
+ Pointer("/foo/int64").Set(d, i64);
924
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
925
+
926
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
927
+ Pointer("/foo/uint64").Set(d, u64);
928
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
929
+
930
+ Pointer("/foo/true").Set(d, true);
931
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
932
+
933
+ Pointer("/foo/false").Set(d, false);
934
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
935
+
936
+ // StringRef version
937
+ Pointer("/foo/hello").Set(d, "Hello");
938
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
939
+
940
+ // Copy string version
941
+ {
942
+ char buffer[256];
943
+ strcpy(buffer, "World");
944
+ Pointer("/foo/world").Set(d, buffer);
945
+ memset(buffer, 0, sizeof(buffer));
946
+ }
947
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
948
+
949
+ #if RAPIDJSON_HAS_STDSTRING
950
+ Pointer("/foo/c++").Set(d, std::string("C++"));
951
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
952
+ #endif
953
+ }
954
+
955
+ TEST(Pointer, Swap_Value) {
956
+ Document d;
957
+ d.Parse(kJson);
958
+ Document::AllocatorType& a = d.GetAllocator();
959
+ Pointer("/foo/0").Swap(d, *Pointer("/foo/1").Get(d), a);
960
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
961
+ EXPECT_STREQ("bar", d["foo"][1].GetString());
962
+ }
963
+
964
+ TEST(Pointer, Swap_Value_NoAllocator) {
965
+ Document d;
966
+ d.Parse(kJson);
967
+ Pointer("/foo/0").Swap(d, *Pointer("/foo/1").Get(d));
968
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
969
+ EXPECT_STREQ("bar", d["foo"][1].GetString());
970
+ }
971
+
972
+ TEST(Pointer, Erase) {
973
+ Document d;
974
+ d.Parse(kJson);
975
+
976
+ EXPECT_FALSE(Pointer("").Erase(d));
977
+ EXPECT_FALSE(Pointer("/nonexist").Erase(d));
978
+ EXPECT_FALSE(Pointer("/nonexist/nonexist").Erase(d));
979
+ EXPECT_FALSE(Pointer("/foo/nonexist").Erase(d));
980
+ EXPECT_FALSE(Pointer("/foo/nonexist/nonexist").Erase(d));
981
+ EXPECT_FALSE(Pointer("/foo/0/nonexist").Erase(d));
982
+ EXPECT_FALSE(Pointer("/foo/0/nonexist/nonexist").Erase(d));
983
+ EXPECT_FALSE(Pointer("/foo/2/nonexist").Erase(d));
984
+ EXPECT_TRUE(Pointer("/foo/0").Erase(d));
985
+ EXPECT_EQ(1u, d["foo"].Size());
986
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
987
+ EXPECT_TRUE(Pointer("/foo/0").Erase(d));
988
+ EXPECT_TRUE(d["foo"].Empty());
989
+ EXPECT_TRUE(Pointer("/foo").Erase(d));
990
+ EXPECT_TRUE(Pointer("/foo").Get(d) == 0);
991
+
992
+ Pointer("/a/0/b/0").Create(d);
993
+
994
+ EXPECT_TRUE(Pointer("/a/0/b/0").Get(d) != 0);
995
+ EXPECT_TRUE(Pointer("/a/0/b/0").Erase(d));
996
+ EXPECT_TRUE(Pointer("/a/0/b/0").Get(d) == 0);
997
+
998
+ EXPECT_TRUE(Pointer("/a/0/b").Get(d) != 0);
999
+ EXPECT_TRUE(Pointer("/a/0/b").Erase(d));
1000
+ EXPECT_TRUE(Pointer("/a/0/b").Get(d) == 0);
1001
+
1002
+ EXPECT_TRUE(Pointer("/a/0").Get(d) != 0);
1003
+ EXPECT_TRUE(Pointer("/a/0").Erase(d));
1004
+ EXPECT_TRUE(Pointer("/a/0").Get(d) == 0);
1005
+
1006
+ EXPECT_TRUE(Pointer("/a").Get(d) != 0);
1007
+ EXPECT_TRUE(Pointer("/a").Erase(d));
1008
+ EXPECT_TRUE(Pointer("/a").Get(d) == 0);
1009
+ }
1010
+
1011
+ TEST(Pointer, CreateValueByPointer) {
1012
+ Document d;
1013
+ Document::AllocatorType& a = d.GetAllocator();
1014
+
1015
+ {
1016
+ Value& v = CreateValueByPointer(d, Pointer("/foo/0"), a);
1017
+ EXPECT_EQ(&d["foo"][0], &v);
1018
+ }
1019
+ {
1020
+ Value& v = CreateValueByPointer(d, "/foo/1", a);
1021
+ EXPECT_EQ(&d["foo"][1], &v);
1022
+ }
1023
+ }
1024
+
1025
+ TEST(Pointer, CreateValueByPointer_NoAllocator) {
1026
+ Document d;
1027
+
1028
+ {
1029
+ Value& v = CreateValueByPointer(d, Pointer("/foo/0"));
1030
+ EXPECT_EQ(&d["foo"][0], &v);
1031
+ }
1032
+ {
1033
+ Value& v = CreateValueByPointer(d, "/foo/1");
1034
+ EXPECT_EQ(&d["foo"][1], &v);
1035
+ }
1036
+ }
1037
+
1038
+ TEST(Pointer, GetValueByPointer) {
1039
+ Document d;
1040
+ d.Parse(kJson);
1041
+
1042
+ EXPECT_EQ(&d["foo"][0], GetValueByPointer(d, Pointer("/foo/0")));
1043
+ EXPECT_EQ(&d["foo"][0], GetValueByPointer(d, "/foo/0"));
1044
+
1045
+ size_t unresolvedTokenIndex;
1046
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/2", &unresolvedTokenIndex) == 0); // Out of boundary
1047
+ EXPECT_EQ(1u, unresolvedTokenIndex);
1048
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/a", &unresolvedTokenIndex) == 0); // "/foo" is an array, cannot query by "a"
1049
+ EXPECT_EQ(1u, unresolvedTokenIndex);
1050
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/0/0", &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
1051
+ EXPECT_EQ(2u, unresolvedTokenIndex);
1052
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/0/a", &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
1053
+ EXPECT_EQ(2u, unresolvedTokenIndex);
1054
+
1055
+ // const version
1056
+ const Value& v = d;
1057
+ EXPECT_EQ(&d["foo"][0], GetValueByPointer(v, Pointer("/foo/0")));
1058
+ EXPECT_EQ(&d["foo"][0], GetValueByPointer(v, "/foo/0"));
1059
+
1060
+ EXPECT_TRUE(GetValueByPointer(v, "/foo/2", &unresolvedTokenIndex) == 0); // Out of boundary
1061
+ EXPECT_EQ(1u, unresolvedTokenIndex);
1062
+ EXPECT_TRUE(GetValueByPointer(v, "/foo/a", &unresolvedTokenIndex) == 0); // "/foo" is an array, cannot query by "a"
1063
+ EXPECT_EQ(1u, unresolvedTokenIndex);
1064
+ EXPECT_TRUE(GetValueByPointer(v, "/foo/0/0", &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
1065
+ EXPECT_EQ(2u, unresolvedTokenIndex);
1066
+ EXPECT_TRUE(GetValueByPointer(v, "/foo/0/a", &unresolvedTokenIndex) == 0); // "/foo/0" is an string, cannot further query
1067
+ EXPECT_EQ(2u, unresolvedTokenIndex);
1068
+
1069
+ }
1070
+
1071
+ TEST(Pointer, GetValueByPointerWithDefault_Pointer) {
1072
+ Document d;
1073
+ d.Parse(kJson);
1074
+
1075
+ Document::AllocatorType& a = d.GetAllocator();
1076
+ const Value v("qux");
1077
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, Pointer("/foo/0"), v, a));
1078
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, Pointer("/foo/0"), v, a));
1079
+ EXPECT_TRUE(Value("baz") == GetValueByPointerWithDefault(d, Pointer("/foo/1"), v, a));
1080
+ EXPECT_TRUE(Value("qux") == GetValueByPointerWithDefault(d, Pointer("/foo/2"), v, a));
1081
+ EXPECT_TRUE(Value("last") == GetValueByPointerWithDefault(d, Pointer("/foo/-"), Value("last").Move(), a));
1082
+ EXPECT_STREQ("last", d["foo"][3].GetString());
1083
+
1084
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/null"), Value().Move(), a).IsNull());
1085
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/null"), "x", a).IsNull());
1086
+
1087
+ // Generic version
1088
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer("/foo/int"), -1, a).GetInt());
1089
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer("/foo/int"), -2, a).GetInt());
1090
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer("/foo/uint"), 0x87654321, a).GetUint());
1091
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer("/foo/uint"), 0x12345678, a).GetUint());
1092
+
1093
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1094
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer("/foo/int64"), i64, a).GetInt64());
1095
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer("/foo/int64"), i64 + 1, a).GetInt64());
1096
+
1097
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1098
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer("/foo/uint64"), u64, a).GetUint64());
1099
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer("/foo/uint64"), u64 - 1, a).GetUint64());
1100
+
1101
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/true"), true, a).IsTrue());
1102
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/true"), false, a).IsTrue());
1103
+
1104
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/false"), false, a).IsFalse());
1105
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/false"), true, a).IsFalse());
1106
+
1107
+ // StringRef version
1108
+ EXPECT_STREQ("Hello", GetValueByPointerWithDefault(d, Pointer("/foo/hello"), "Hello", a).GetString());
1109
+
1110
+ // Copy string version
1111
+ {
1112
+ char buffer[256];
1113
+ strcpy(buffer, "World");
1114
+ EXPECT_STREQ("World", GetValueByPointerWithDefault(d, Pointer("/foo/world"), buffer, a).GetString());
1115
+ memset(buffer, 0, sizeof(buffer));
1116
+ }
1117
+ EXPECT_STREQ("World", GetValueByPointer(d, Pointer("/foo/world"))->GetString());
1118
+
1119
+ #if RAPIDJSON_HAS_STDSTRING
1120
+ EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++"), a).GetString());
1121
+ #endif
1122
+ }
1123
+
1124
+ TEST(Pointer, GetValueByPointerWithDefault_String) {
1125
+ Document d;
1126
+ d.Parse(kJson);
1127
+
1128
+ Document::AllocatorType& a = d.GetAllocator();
1129
+ const Value v("qux");
1130
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, "/foo/0", v, a));
1131
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, "/foo/0", v, a));
1132
+ EXPECT_TRUE(Value("baz") == GetValueByPointerWithDefault(d, "/foo/1", v, a));
1133
+ EXPECT_TRUE(Value("qux") == GetValueByPointerWithDefault(d, "/foo/2", v, a));
1134
+ EXPECT_TRUE(Value("last") == GetValueByPointerWithDefault(d, "/foo/-", Value("last").Move(), a));
1135
+ EXPECT_STREQ("last", d["foo"][3].GetString());
1136
+
1137
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/null", Value().Move(), a).IsNull());
1138
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/null", "x", a).IsNull());
1139
+
1140
+ // Generic version
1141
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, "/foo/int", -1, a).GetInt());
1142
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, "/foo/int", -2, a).GetInt());
1143
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, "/foo/uint", 0x87654321, a).GetUint());
1144
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, "/foo/uint", 0x12345678, a).GetUint());
1145
+
1146
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1147
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, "/foo/int64", i64, a).GetInt64());
1148
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, "/foo/int64", i64 + 1, a).GetInt64());
1149
+
1150
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1151
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, "/foo/uint64", u64, a).GetUint64());
1152
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, "/foo/uint64", u64 - 1, a).GetUint64());
1153
+
1154
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/true", true, a).IsTrue());
1155
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/true", false, a).IsTrue());
1156
+
1157
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/false", false, a).IsFalse());
1158
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/false", true, a).IsFalse());
1159
+
1160
+ // StringRef version
1161
+ EXPECT_STREQ("Hello", GetValueByPointerWithDefault(d, "/foo/hello", "Hello", a).GetString());
1162
+
1163
+ // Copy string version
1164
+ {
1165
+ char buffer[256];
1166
+ strcpy(buffer, "World");
1167
+ EXPECT_STREQ("World", GetValueByPointerWithDefault(d, "/foo/world", buffer, a).GetString());
1168
+ memset(buffer, 0, sizeof(buffer));
1169
+ }
1170
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1171
+
1172
+ #if RAPIDJSON_HAS_STDSTRING
1173
+ EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, "/foo/C++", std::string("C++"), a).GetString());
1174
+ #endif
1175
+ }
1176
+
1177
+ TEST(Pointer, GetValueByPointerWithDefault_Pointer_NoAllocator) {
1178
+ Document d;
1179
+ d.Parse(kJson);
1180
+
1181
+ const Value v("qux");
1182
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, Pointer("/foo/0"), v));
1183
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, Pointer("/foo/0"), v));
1184
+ EXPECT_TRUE(Value("baz") == GetValueByPointerWithDefault(d, Pointer("/foo/1"), v));
1185
+ EXPECT_TRUE(Value("qux") == GetValueByPointerWithDefault(d, Pointer("/foo/2"), v));
1186
+ EXPECT_TRUE(Value("last") == GetValueByPointerWithDefault(d, Pointer("/foo/-"), Value("last").Move()));
1187
+ EXPECT_STREQ("last", d["foo"][3].GetString());
1188
+
1189
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/null"), Value().Move()).IsNull());
1190
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/null"), "x").IsNull());
1191
+
1192
+ // Generic version
1193
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer("/foo/int"), -1).GetInt());
1194
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer("/foo/int"), -2).GetInt());
1195
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer("/foo/uint"), 0x87654321).GetUint());
1196
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer("/foo/uint"), 0x12345678).GetUint());
1197
+
1198
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1199
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer("/foo/int64"), i64).GetInt64());
1200
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer("/foo/int64"), i64 + 1).GetInt64());
1201
+
1202
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1203
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer("/foo/uint64"), u64).GetUint64());
1204
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer("/foo/uint64"), u64 - 1).GetUint64());
1205
+
1206
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/true"), true).IsTrue());
1207
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/true"), false).IsTrue());
1208
+
1209
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/false"), false).IsFalse());
1210
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer("/foo/false"), true).IsFalse());
1211
+
1212
+ // StringRef version
1213
+ EXPECT_STREQ("Hello", GetValueByPointerWithDefault(d, Pointer("/foo/hello"), "Hello").GetString());
1214
+
1215
+ // Copy string version
1216
+ {
1217
+ char buffer[256];
1218
+ strcpy(buffer, "World");
1219
+ EXPECT_STREQ("World", GetValueByPointerWithDefault(d, Pointer("/foo/world"), buffer).GetString());
1220
+ memset(buffer, 0, sizeof(buffer));
1221
+ }
1222
+ EXPECT_STREQ("World", GetValueByPointer(d, Pointer("/foo/world"))->GetString());
1223
+
1224
+ #if RAPIDJSON_HAS_STDSTRING
1225
+ EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++")).GetString());
1226
+ #endif
1227
+ }
1228
+
1229
+ TEST(Pointer, GetValueByPointerWithDefault_String_NoAllocator) {
1230
+ Document d;
1231
+ d.Parse(kJson);
1232
+
1233
+ const Value v("qux");
1234
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, "/foo/0", v));
1235
+ EXPECT_TRUE(Value("bar") == GetValueByPointerWithDefault(d, "/foo/0", v));
1236
+ EXPECT_TRUE(Value("baz") == GetValueByPointerWithDefault(d, "/foo/1", v));
1237
+ EXPECT_TRUE(Value("qux") == GetValueByPointerWithDefault(d, "/foo/2", v));
1238
+ EXPECT_TRUE(Value("last") == GetValueByPointerWithDefault(d, "/foo/-", Value("last").Move()));
1239
+ EXPECT_STREQ("last", d["foo"][3].GetString());
1240
+
1241
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/null", Value().Move()).IsNull());
1242
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/null", "x").IsNull());
1243
+
1244
+ // Generic version
1245
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, "/foo/int", -1).GetInt());
1246
+ EXPECT_EQ(-1, GetValueByPointerWithDefault(d, "/foo/int", -2).GetInt());
1247
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, "/foo/uint", 0x87654321).GetUint());
1248
+ EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, "/foo/uint", 0x12345678).GetUint());
1249
+
1250
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1251
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, "/foo/int64", i64).GetInt64());
1252
+ EXPECT_EQ(i64, GetValueByPointerWithDefault(d, "/foo/int64", i64 + 1).GetInt64());
1253
+
1254
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1255
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, "/foo/uint64", u64).GetUint64());
1256
+ EXPECT_EQ(u64, GetValueByPointerWithDefault(d, "/foo/uint64", u64 - 1).GetUint64());
1257
+
1258
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/true", true).IsTrue());
1259
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/true", false).IsTrue());
1260
+
1261
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/false", false).IsFalse());
1262
+ EXPECT_TRUE(GetValueByPointerWithDefault(d, "/foo/false", true).IsFalse());
1263
+
1264
+ // StringRef version
1265
+ EXPECT_STREQ("Hello", GetValueByPointerWithDefault(d, "/foo/hello", "Hello").GetString());
1266
+
1267
+ // Copy string version
1268
+ {
1269
+ char buffer[256];
1270
+ strcpy(buffer, "World");
1271
+ EXPECT_STREQ("World", GetValueByPointerWithDefault(d, "/foo/world", buffer).GetString());
1272
+ memset(buffer, 0, sizeof(buffer));
1273
+ }
1274
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1275
+
1276
+ #if RAPIDJSON_HAS_STDSTRING
1277
+ EXPECT_STREQ("C++", GetValueByPointerWithDefault(d, Pointer("/foo/C++"), std::string("C++")).GetString());
1278
+ #endif
1279
+ }
1280
+
1281
+ TEST(Pointer, SetValueByPointer_Pointer) {
1282
+ Document d;
1283
+ d.Parse(kJson);
1284
+ Document::AllocatorType& a = d.GetAllocator();
1285
+
1286
+ // Value version
1287
+ SetValueByPointer(d, Pointer("/foo/0"), Value(123).Move(), a);
1288
+ EXPECT_EQ(123, d["foo"][0].GetInt());
1289
+
1290
+ SetValueByPointer(d, Pointer("/foo/null"), Value().Move(), a);
1291
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
1292
+
1293
+ // Const Value version
1294
+ const Value foo(d["foo"], d.GetAllocator());
1295
+ SetValueByPointer(d, Pointer("/clone"), foo, a);
1296
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
1297
+
1298
+ // Generic version
1299
+ SetValueByPointer(d, Pointer("/foo/int"), -1, a);
1300
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
1301
+
1302
+ SetValueByPointer(d, Pointer("/foo/uint"), 0x87654321, a);
1303
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
1304
+
1305
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1306
+ SetValueByPointer(d, Pointer("/foo/int64"), i64, a);
1307
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
1308
+
1309
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1310
+ SetValueByPointer(d, Pointer("/foo/uint64"), u64, a);
1311
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
1312
+
1313
+ SetValueByPointer(d, Pointer("/foo/true"), true, a);
1314
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
1315
+
1316
+ SetValueByPointer(d, Pointer("/foo/false"), false, a);
1317
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
1318
+
1319
+ // StringRef version
1320
+ SetValueByPointer(d, Pointer("/foo/hello"), "Hello", a);
1321
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
1322
+
1323
+ // Copy string version
1324
+ {
1325
+ char buffer[256];
1326
+ strcpy(buffer, "World");
1327
+ SetValueByPointer(d, Pointer("/foo/world"), buffer, a);
1328
+ memset(buffer, 0, sizeof(buffer));
1329
+ }
1330
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1331
+
1332
+ #if RAPIDJSON_HAS_STDSTRING
1333
+ SetValueByPointer(d, Pointer("/foo/c++"), std::string("C++"), a);
1334
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
1335
+ #endif
1336
+ }
1337
+
1338
+ TEST(Pointer, SetValueByPointer_String) {
1339
+ Document d;
1340
+ d.Parse(kJson);
1341
+ Document::AllocatorType& a = d.GetAllocator();
1342
+
1343
+ // Value version
1344
+ SetValueByPointer(d, "/foo/0", Value(123).Move(), a);
1345
+ EXPECT_EQ(123, d["foo"][0].GetInt());
1346
+
1347
+ SetValueByPointer(d, "/foo/null", Value().Move(), a);
1348
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
1349
+
1350
+ // Const Value version
1351
+ const Value foo(d["foo"], d.GetAllocator());
1352
+ SetValueByPointer(d, "/clone", foo, a);
1353
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
1354
+
1355
+ // Generic version
1356
+ SetValueByPointer(d, "/foo/int", -1, a);
1357
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
1358
+
1359
+ SetValueByPointer(d, "/foo/uint", 0x87654321, a);
1360
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
1361
+
1362
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1363
+ SetValueByPointer(d, "/foo/int64", i64, a);
1364
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
1365
+
1366
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1367
+ SetValueByPointer(d, "/foo/uint64", u64, a);
1368
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
1369
+
1370
+ SetValueByPointer(d, "/foo/true", true, a);
1371
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
1372
+
1373
+ SetValueByPointer(d, "/foo/false", false, a);
1374
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
1375
+
1376
+ // StringRef version
1377
+ SetValueByPointer(d, "/foo/hello", "Hello", a);
1378
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
1379
+
1380
+ // Copy string version
1381
+ {
1382
+ char buffer[256];
1383
+ strcpy(buffer, "World");
1384
+ SetValueByPointer(d, "/foo/world", buffer, a);
1385
+ memset(buffer, 0, sizeof(buffer));
1386
+ }
1387
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1388
+
1389
+ #if RAPIDJSON_HAS_STDSTRING
1390
+ SetValueByPointer(d, "/foo/c++", std::string("C++"), a);
1391
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
1392
+ #endif
1393
+ }
1394
+
1395
+ TEST(Pointer, SetValueByPointer_Pointer_NoAllocator) {
1396
+ Document d;
1397
+ d.Parse(kJson);
1398
+
1399
+ // Value version
1400
+ SetValueByPointer(d, Pointer("/foo/0"), Value(123).Move());
1401
+ EXPECT_EQ(123, d["foo"][0].GetInt());
1402
+
1403
+ SetValueByPointer(d, Pointer("/foo/null"), Value().Move());
1404
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
1405
+
1406
+ // Const Value version
1407
+ const Value foo(d["foo"], d.GetAllocator());
1408
+ SetValueByPointer(d, Pointer("/clone"), foo);
1409
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
1410
+
1411
+ // Generic version
1412
+ SetValueByPointer(d, Pointer("/foo/int"), -1);
1413
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
1414
+
1415
+ SetValueByPointer(d, Pointer("/foo/uint"), 0x87654321);
1416
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
1417
+
1418
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1419
+ SetValueByPointer(d, Pointer("/foo/int64"), i64);
1420
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
1421
+
1422
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1423
+ SetValueByPointer(d, Pointer("/foo/uint64"), u64);
1424
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
1425
+
1426
+ SetValueByPointer(d, Pointer("/foo/true"), true);
1427
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
1428
+
1429
+ SetValueByPointer(d, Pointer("/foo/false"), false);
1430
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
1431
+
1432
+ // StringRef version
1433
+ SetValueByPointer(d, Pointer("/foo/hello"), "Hello");
1434
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
1435
+
1436
+ // Copy string version
1437
+ {
1438
+ char buffer[256];
1439
+ strcpy(buffer, "World");
1440
+ SetValueByPointer(d, Pointer("/foo/world"), buffer);
1441
+ memset(buffer, 0, sizeof(buffer));
1442
+ }
1443
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1444
+
1445
+ #if RAPIDJSON_HAS_STDSTRING
1446
+ SetValueByPointer(d, Pointer("/foo/c++"), std::string("C++"));
1447
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
1448
+ #endif
1449
+ }
1450
+
1451
+ TEST(Pointer, SetValueByPointer_String_NoAllocator) {
1452
+ Document d;
1453
+ d.Parse(kJson);
1454
+
1455
+ // Value version
1456
+ SetValueByPointer(d, "/foo/0", Value(123).Move());
1457
+ EXPECT_EQ(123, d["foo"][0].GetInt());
1458
+
1459
+ SetValueByPointer(d, "/foo/null", Value().Move());
1460
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/null")->IsNull());
1461
+
1462
+ // Const Value version
1463
+ const Value foo(d["foo"], d.GetAllocator());
1464
+ SetValueByPointer(d, "/clone", foo);
1465
+ EXPECT_EQ(foo, *GetValueByPointer(d, "/clone"));
1466
+
1467
+ // Generic version
1468
+ SetValueByPointer(d, "/foo/int", -1);
1469
+ EXPECT_EQ(-1, GetValueByPointer(d, "/foo/int")->GetInt());
1470
+
1471
+ SetValueByPointer(d, "/foo/uint", 0x87654321);
1472
+ EXPECT_EQ(0x87654321, GetValueByPointer(d, "/foo/uint")->GetUint());
1473
+
1474
+ const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));
1475
+ SetValueByPointer(d, "/foo/int64", i64);
1476
+ EXPECT_EQ(i64, GetValueByPointer(d, "/foo/int64")->GetInt64());
1477
+
1478
+ const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);
1479
+ SetValueByPointer(d, "/foo/uint64", u64);
1480
+ EXPECT_EQ(u64, GetValueByPointer(d, "/foo/uint64")->GetUint64());
1481
+
1482
+ SetValueByPointer(d, "/foo/true", true);
1483
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/true")->IsTrue());
1484
+
1485
+ SetValueByPointer(d, "/foo/false", false);
1486
+ EXPECT_TRUE(GetValueByPointer(d, "/foo/false")->IsFalse());
1487
+
1488
+ // StringRef version
1489
+ SetValueByPointer(d, "/foo/hello", "Hello");
1490
+ EXPECT_STREQ("Hello", GetValueByPointer(d, "/foo/hello")->GetString());
1491
+
1492
+ // Copy string version
1493
+ {
1494
+ char buffer[256];
1495
+ strcpy(buffer, "World");
1496
+ SetValueByPointer(d, "/foo/world", buffer);
1497
+ memset(buffer, 0, sizeof(buffer));
1498
+ }
1499
+ EXPECT_STREQ("World", GetValueByPointer(d, "/foo/world")->GetString());
1500
+
1501
+ #if RAPIDJSON_HAS_STDSTRING
1502
+ SetValueByPointer(d, "/foo/c++", std::string("C++"));
1503
+ EXPECT_STREQ("C++", GetValueByPointer(d, "/foo/c++")->GetString());
1504
+ #endif
1505
+ }
1506
+
1507
+ TEST(Pointer, SwapValueByPointer) {
1508
+ Document d;
1509
+ d.Parse(kJson);
1510
+ Document::AllocatorType& a = d.GetAllocator();
1511
+ SwapValueByPointer(d, Pointer("/foo/0"), *GetValueByPointer(d, "/foo/1"), a);
1512
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
1513
+ EXPECT_STREQ("bar", d["foo"][1].GetString());
1514
+
1515
+ SwapValueByPointer(d, "/foo/0", *GetValueByPointer(d, "/foo/1"), a);
1516
+ EXPECT_STREQ("bar", d["foo"][0].GetString());
1517
+ EXPECT_STREQ("baz", d["foo"][1].GetString());
1518
+ }
1519
+
1520
+ TEST(Pointer, SwapValueByPointer_NoAllocator) {
1521
+ Document d;
1522
+ d.Parse(kJson);
1523
+ SwapValueByPointer(d, Pointer("/foo/0"), *GetValueByPointer(d, "/foo/1"));
1524
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
1525
+ EXPECT_STREQ("bar", d["foo"][1].GetString());
1526
+
1527
+ SwapValueByPointer(d, "/foo/0", *GetValueByPointer(d, "/foo/1"));
1528
+ EXPECT_STREQ("bar", d["foo"][0].GetString());
1529
+ EXPECT_STREQ("baz", d["foo"][1].GetString());
1530
+ }
1531
+
1532
+ TEST(Pointer, EraseValueByPointer_Pointer) {
1533
+ Document d;
1534
+ d.Parse(kJson);
1535
+
1536
+ EXPECT_FALSE(EraseValueByPointer(d, Pointer("")));
1537
+ EXPECT_FALSE(Pointer("/foo/nonexist").Erase(d));
1538
+ EXPECT_TRUE(EraseValueByPointer(d, Pointer("/foo/0")));
1539
+ EXPECT_EQ(1u, d["foo"].Size());
1540
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
1541
+ EXPECT_TRUE(EraseValueByPointer(d, Pointer("/foo/0")));
1542
+ EXPECT_TRUE(d["foo"].Empty());
1543
+ EXPECT_TRUE(EraseValueByPointer(d, Pointer("/foo")));
1544
+ EXPECT_TRUE(Pointer("/foo").Get(d) == 0);
1545
+ }
1546
+
1547
+ TEST(Pointer, EraseValueByPointer_String) {
1548
+ Document d;
1549
+ d.Parse(kJson);
1550
+
1551
+ EXPECT_FALSE(EraseValueByPointer(d, ""));
1552
+ EXPECT_FALSE(Pointer("/foo/nonexist").Erase(d));
1553
+ EXPECT_TRUE(EraseValueByPointer(d, "/foo/0"));
1554
+ EXPECT_EQ(1u, d["foo"].Size());
1555
+ EXPECT_STREQ("baz", d["foo"][0].GetString());
1556
+ EXPECT_TRUE(EraseValueByPointer(d, "/foo/0"));
1557
+ EXPECT_TRUE(d["foo"].Empty());
1558
+ EXPECT_TRUE(EraseValueByPointer(d, "/foo"));
1559
+ EXPECT_TRUE(Pointer("/foo").Get(d) == 0);
1560
+ }
1561
+
1562
+ TEST(Pointer, Ambiguity) {
1563
+ {
1564
+ Document d;
1565
+ d.Parse("{\"0\" : [123]}");
1566
+ EXPECT_EQ(123, Pointer("/0/0").Get(d)->GetInt());
1567
+ Pointer("/0/a").Set(d, 456); // Change array [123] to object {456}
1568
+ EXPECT_EQ(456, Pointer("/0/a").Get(d)->GetInt());
1569
+ }
1570
+
1571
+ {
1572
+ Document d;
1573
+ EXPECT_FALSE(d.Parse("[{\"0\": 123}]").HasParseError());
1574
+ EXPECT_EQ(123, Pointer("/0/0").Get(d)->GetInt());
1575
+ Pointer("/0/1").Set(d, 456); // 1 is treated as "1" to index object
1576
+ EXPECT_EQ(123, Pointer("/0/0").Get(d)->GetInt());
1577
+ EXPECT_EQ(456, Pointer("/0/1").Get(d)->GetInt());
1578
+ }
1579
+ }
1580
+
1581
+ TEST(Pointer, ResolveOnObject) {
1582
+ Document d;
1583
+ EXPECT_FALSE(d.Parse("{\"a\": 123}").HasParseError());
1584
+
1585
+ {
1586
+ Value::ConstObject o = static_cast<const Document&>(d).GetObject();
1587
+ EXPECT_EQ(123, Pointer("/a").Get(o)->GetInt());
1588
+ }
1589
+
1590
+ {
1591
+ Value::Object o = d.GetObject();
1592
+ Pointer("/a").Set(o, 456, d.GetAllocator());
1593
+ EXPECT_EQ(456, Pointer("/a").Get(o)->GetInt());
1594
+ }
1595
+ }
1596
+
1597
+ TEST(Pointer, ResolveOnArray) {
1598
+ Document d;
1599
+ EXPECT_FALSE(d.Parse("[1, 2, 3]").HasParseError());
1600
+
1601
+ {
1602
+ Value::ConstArray a = static_cast<const Document&>(d).GetArray();
1603
+ EXPECT_EQ(2, Pointer("/1").Get(a)->GetInt());
1604
+ }
1605
+
1606
+ {
1607
+ Value::Array a = d.GetArray();
1608
+ Pointer("/1").Set(a, 123, d.GetAllocator());
1609
+ EXPECT_EQ(123, Pointer("/1").Get(a)->GetInt());
1610
+ }
1611
+ }
1612
+
1613
+ TEST(Pointer, LessThan) {
1614
+ static const struct {
1615
+ const char *str;
1616
+ bool valid;
1617
+ } pointers[] = {
1618
+ { "/a/b", true },
1619
+ { "/a", true },
1620
+ { "/d/1", true },
1621
+ { "/d/2/z", true },
1622
+ { "/d/2/3", true },
1623
+ { "/d/2", true },
1624
+ { "/a/c", true },
1625
+ { "/e/f~g", false },
1626
+ { "/d/2/zz", true },
1627
+ { "/d/1", true },
1628
+ { "/d/2/z", true },
1629
+ { "/e/f~~g", false },
1630
+ { "/e/f~0g", true },
1631
+ { "/e/f~1g", true },
1632
+ { "/e/f.g", true },
1633
+ { "", true }
1634
+ };
1635
+ static const char *ordered_pointers[] = {
1636
+ "",
1637
+ "/a",
1638
+ "/a/b",
1639
+ "/a/c",
1640
+ "/d/1",
1641
+ "/d/1",
1642
+ "/d/2",
1643
+ "/e/f.g",
1644
+ "/e/f~1g",
1645
+ "/e/f~0g",
1646
+ "/d/2/3",
1647
+ "/d/2/z",
1648
+ "/d/2/z",
1649
+ "/d/2/zz",
1650
+ NULL, // was invalid "/e/f~g"
1651
+ NULL // was invalid "/e/f~~g"
1652
+ };
1653
+ typedef MemoryPoolAllocator<> AllocatorType;
1654
+ typedef GenericPointer<Value, AllocatorType> PointerType;
1655
+ typedef std::multimap<PointerType, size_t> PointerMap;
1656
+ PointerMap map;
1657
+ PointerMap::iterator it;
1658
+ AllocatorType allocator;
1659
+ size_t i;
1660
+
1661
+ EXPECT_EQ(sizeof(pointers) / sizeof(pointers[0]),
1662
+ sizeof(ordered_pointers) / sizeof(ordered_pointers[0]));
1663
+
1664
+ for (i = 0; i < sizeof(pointers) / sizeof(pointers[0]); ++i) {
1665
+ it = map.insert(PointerMap::value_type(PointerType(pointers[i].str, &allocator), i));
1666
+ if (!it->first.IsValid()) {
1667
+ EXPECT_EQ(++it, map.end());
1668
+ }
1669
+ }
1670
+
1671
+ for (i = 0, it = map.begin(); it != map.end(); ++it, ++i) {
1672
+ EXPECT_TRUE(it->second < sizeof(pointers) / sizeof(pointers[0]));
1673
+ EXPECT_EQ(it->first.IsValid(), pointers[it->second].valid);
1674
+ EXPECT_TRUE(i < sizeof(ordered_pointers) / sizeof(ordered_pointers[0]));
1675
+ EXPECT_EQ(it->first.IsValid(), !!ordered_pointers[i]);
1676
+ if (it->first.IsValid()) {
1677
+ std::stringstream ss;
1678
+ OStreamWrapper os(ss);
1679
+ EXPECT_TRUE(it->first.Stringify(os));
1680
+ EXPECT_EQ(ss.str(), pointers[it->second].str);
1681
+ EXPECT_EQ(ss.str(), ordered_pointers[i]);
1682
+ }
1683
+ }
1684
+ }
1685
+
1686
+ // https://github.com/Tencent/rapidjson/issues/483
1687
+ namespace myjson {
1688
+
1689
+ class MyAllocator
1690
+ {
1691
+ public:
1692
+ static const bool kNeedFree = true;
1693
+ void * Malloc(size_t _size) { return malloc(_size); }
1694
+ void * Realloc(void *_org_p, size_t _org_size, size_t _new_size) { (void)_org_size; return realloc(_org_p, _new_size); }
1695
+ static void Free(void *_p) { return free(_p); }
1696
+ };
1697
+
1698
+ typedef rapidjson::GenericDocument<
1699
+ rapidjson::UTF8<>,
1700
+ rapidjson::MemoryPoolAllocator< MyAllocator >,
1701
+ MyAllocator
1702
+ > Document;
1703
+
1704
+ typedef rapidjson::GenericPointer<
1705
+ ::myjson::Document::ValueType,
1706
+ MyAllocator
1707
+ > Pointer;
1708
+
1709
+ typedef ::myjson::Document::ValueType Value;
1710
+
1711
+ }
1712
+
1713
+ TEST(Pointer, Issue483) {
1714
+ std::string mystr, path;
1715
+ myjson::Document document;
1716
+ myjson::Value value(rapidjson::kStringType);
1717
+ value.SetString(mystr.c_str(), static_cast<SizeType>(mystr.length()), document.GetAllocator());
1718
+ myjson::Pointer(path.c_str()).Set(document, value, document.GetAllocator());
1719
+ }
1720
+
1721
+ TEST(Pointer, Issue1899) {
1722
+ typedef GenericPointer<Value, MemoryPoolAllocator<> > PointerType;
1723
+ PointerType p;
1724
+ PointerType q = p.Append("foo");
1725
+ EXPECT_TRUE(PointerType("/foo") == q);
1726
+ q = q.Append(1234);
1727
+ EXPECT_TRUE(PointerType("/foo/1234") == q);
1728
+ q = q.Append("");
1729
+ EXPECT_TRUE(PointerType("/foo/1234/") == q);
1730
+ }