rj_schema 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (614) 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 +226 -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 +54 -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/booleans.json +102 -0
  130. data/ext/rj_schema/rapidjson/bin/types/floats.json +102 -0
  131. data/ext/rj_schema/rapidjson/bin/types/guids.json +102 -0
  132. data/ext/rj_schema/rapidjson/bin/types/integers.json +102 -0
  133. data/ext/rj_schema/rapidjson/bin/types/mixed.json +592 -0
  134. data/ext/rj_schema/rapidjson/bin/types/nulls.json +102 -0
  135. data/ext/rj_schema/rapidjson/bin/types/paragraphs.json +102 -0
  136. data/ext/rj_schema/rapidjson/bin/types/readme.txt +1 -0
  137. data/ext/rj_schema/rapidjson/contrib/natvis/LICENSE +45 -0
  138. data/ext/rj_schema/rapidjson/contrib/natvis/README.md +7 -0
  139. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +38 -0
  140. data/ext/rj_schema/rapidjson/doc/CMakeLists.txt +27 -0
  141. data/ext/rj_schema/rapidjson/doc/Doxyfile.in +2369 -0
  142. data/ext/rj_schema/rapidjson/doc/Doxyfile.zh-cn.in +2369 -0
  143. data/ext/rj_schema/rapidjson/doc/diagram/architecture.dot +50 -0
  144. data/ext/rj_schema/rapidjson/doc/diagram/architecture.png +0 -0
  145. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.dot +65 -0
  146. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.png +0 -0
  147. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.dot +62 -0
  148. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.png +0 -0
  149. data/ext/rj_schema/rapidjson/doc/diagram/makefile +8 -0
  150. data/ext/rj_schema/rapidjson/doc/diagram/move1.dot +47 -0
  151. data/ext/rj_schema/rapidjson/doc/diagram/move1.png +0 -0
  152. data/ext/rj_schema/rapidjson/doc/diagram/move2.dot +62 -0
  153. data/ext/rj_schema/rapidjson/doc/diagram/move2.png +0 -0
  154. data/ext/rj_schema/rapidjson/doc/diagram/move3.dot +60 -0
  155. data/ext/rj_schema/rapidjson/doc/diagram/move3.png +0 -0
  156. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.dot +56 -0
  157. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.png +0 -0
  158. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.dot +54 -0
  159. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.png +0 -0
  160. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.dot +58 -0
  161. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.png +0 -0
  162. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.dot +73 -0
  163. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.png +0 -0
  164. data/ext/rj_schema/rapidjson/doc/dom.md +281 -0
  165. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +285 -0
  166. data/ext/rj_schema/rapidjson/doc/encoding.md +146 -0
  167. data/ext/rj_schema/rapidjson/doc/encoding.zh-cn.md +152 -0
  168. data/ext/rj_schema/rapidjson/doc/faq.md +289 -0
  169. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +290 -0
  170. data/ext/rj_schema/rapidjson/doc/features.md +104 -0
  171. data/ext/rj_schema/rapidjson/doc/features.zh-cn.md +103 -0
  172. data/ext/rj_schema/rapidjson/doc/internals.md +368 -0
  173. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +363 -0
  174. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.png +0 -0
  175. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.svg +119 -0
  176. data/ext/rj_schema/rapidjson/doc/misc/DoxygenLayout.xml +194 -0
  177. data/ext/rj_schema/rapidjson/doc/misc/doxygenextra.css +274 -0
  178. data/ext/rj_schema/rapidjson/doc/misc/footer.html +11 -0
  179. data/ext/rj_schema/rapidjson/doc/misc/header.html +24 -0
  180. data/ext/rj_schema/rapidjson/doc/npm.md +31 -0
  181. data/ext/rj_schema/rapidjson/doc/performance.md +26 -0
  182. data/ext/rj_schema/rapidjson/doc/performance.zh-cn.md +26 -0
  183. data/ext/rj_schema/rapidjson/doc/pointer.md +234 -0
  184. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +234 -0
  185. data/ext/rj_schema/rapidjson/doc/sax.md +509 -0
  186. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +487 -0
  187. data/ext/rj_schema/rapidjson/doc/schema.md +505 -0
  188. data/ext/rj_schema/rapidjson/doc/schema.zh-cn.md +237 -0
  189. data/ext/rj_schema/rapidjson/doc/stream.md +429 -0
  190. data/ext/rj_schema/rapidjson/doc/stream.zh-cn.md +429 -0
  191. data/ext/rj_schema/rapidjson/doc/tutorial.md +536 -0
  192. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +535 -0
  193. data/ext/rj_schema/rapidjson/docker/debian/Dockerfile +8 -0
  194. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +46 -0
  195. data/ext/rj_schema/rapidjson/example/archiver/archiver.cpp +292 -0
  196. data/ext/rj_schema/rapidjson/example/archiver/archiver.h +145 -0
  197. data/ext/rj_schema/rapidjson/example/archiver/archivertest.cpp +287 -0
  198. data/ext/rj_schema/rapidjson/example/capitalize/capitalize.cpp +67 -0
  199. data/ext/rj_schema/rapidjson/example/condense/condense.cpp +32 -0
  200. data/ext/rj_schema/rapidjson/example/filterkey/filterkey.cpp +135 -0
  201. data/ext/rj_schema/rapidjson/example/filterkeydom/filterkeydom.cpp +170 -0
  202. data/ext/rj_schema/rapidjson/example/jsonx/jsonx.cpp +207 -0
  203. data/ext/rj_schema/rapidjson/example/lookaheadparser/lookaheadparser.cpp +350 -0
  204. data/ext/rj_schema/rapidjson/example/messagereader/messagereader.cpp +105 -0
  205. data/ext/rj_schema/rapidjson/example/parsebyparts/parsebyparts.cpp +176 -0
  206. data/ext/rj_schema/rapidjson/example/pretty/pretty.cpp +30 -0
  207. data/ext/rj_schema/rapidjson/example/prettyauto/prettyauto.cpp +56 -0
  208. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +78 -0
  209. data/ext/rj_schema/rapidjson/example/serialize/serialize.cpp +173 -0
  210. data/ext/rj_schema/rapidjson/example/simpledom/simpledom.cpp +29 -0
  211. data/ext/rj_schema/rapidjson/example/simplepullreader/simplepullreader.cpp +53 -0
  212. data/ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp +42 -0
  213. data/ext/rj_schema/rapidjson/example/simplewriter/simplewriter.cpp +36 -0
  214. data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
  215. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +151 -0
  216. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +284 -0
  217. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +78 -0
  218. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +2732 -0
  219. data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +299 -0
  220. data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +716 -0
  221. data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +74 -0
  222. data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +161 -0
  223. data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +99 -0
  224. data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +104 -0
  225. data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +151 -0
  226. data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +290 -0
  227. data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
  228. data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +257 -0
  229. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +245 -0
  230. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +78 -0
  231. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +308 -0
  232. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +186 -0
  233. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +55 -0
  234. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +739 -0
  235. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +232 -0
  236. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +69 -0
  237. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +290 -0
  238. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +46 -0
  239. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +128 -0
  240. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +70 -0
  241. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +71 -0
  242. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/inttypes.h +316 -0
  243. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/stdint.h +300 -0
  244. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +81 -0
  245. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +1415 -0
  246. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +277 -0
  247. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +676 -0
  248. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +2236 -0
  249. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +2496 -0
  250. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +223 -0
  251. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +121 -0
  252. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +710 -0
  253. data/ext/rj_schema/rapidjson/include_dirs.js +2 -0
  254. data/ext/rj_schema/rapidjson/library.json +15 -0
  255. data/ext/rj_schema/rapidjson/license.txt +57 -0
  256. data/ext/rj_schema/rapidjson/package.json +24 -0
  257. data/ext/rj_schema/rapidjson/rapidjson.autopkg +77 -0
  258. data/ext/rj_schema/rapidjson/readme.md +210 -0
  259. data/ext/rj_schema/rapidjson/readme.zh-cn.md +152 -0
  260. data/ext/rj_schema/rapidjson/test/CMakeLists.txt +20 -0
  261. data/ext/rj_schema/rapidjson/test/perftest/CMakeLists.txt +28 -0
  262. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +974 -0
  263. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +24 -0
  264. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +185 -0
  265. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +166 -0
  266. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +546 -0
  267. data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +223 -0
  268. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +92 -0
  269. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +100 -0
  270. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +138 -0
  271. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +115 -0
  272. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +672 -0
  273. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +98 -0
  274. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +313 -0
  275. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +451 -0
  276. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +155 -0
  277. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +230 -0
  278. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +181 -0
  279. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +160 -0
  280. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +143 -0
  281. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +70 -0
  282. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +92 -0
  283. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +1638 -0
  284. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +373 -0
  285. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +2225 -0
  286. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +639 -0
  287. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +2072 -0
  288. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +219 -0
  289. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +30 -0
  290. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +192 -0
  291. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +132 -0
  292. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +51 -0
  293. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +143 -0
  294. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +1851 -0
  295. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +598 -0
  296. data/ext/rj_schema/rapidjson/test/valgrind.supp +17 -0
  297. data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
  298. data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +33 -0
  299. data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
  300. data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
  301. data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
  302. data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +122 -0
  303. data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
  304. data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
  305. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
  306. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
  307. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
  308. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
  309. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
  310. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
  311. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
  312. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
  313. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
  314. data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
  315. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +126 -0
  316. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +242 -0
  317. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CONTRIBUTORS +40 -0
  318. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/LICENSE +28 -0
  319. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/Makefile.am +224 -0
  320. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +344 -0
  321. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
  322. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
  323. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +146 -0
  324. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +564 -0
  325. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +3660 -0
  326. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DesignDoc.md +280 -0
  327. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +15 -0
  328. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +447 -0
  329. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +627 -0
  330. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/KnownIssues.md +19 -0
  331. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +1262 -0
  332. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-cardinalities.h +147 -0
  333. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +2571 -0
  334. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +833 -0
  335. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +1379 -0
  336. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +347 -0
  337. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +2258 -0
  338. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +675 -0
  339. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +458 -0
  340. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +178 -0
  341. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +5255 -0
  342. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-actions.h +246 -0
  343. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +91 -0
  344. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +1918 -0
  345. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +95 -0
  346. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +8 -0
  347. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +10 -0
  348. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +38 -0
  349. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-port.h +46 -0
  350. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +286 -0
  351. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump +136 -0
  352. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +574 -0
  353. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +87 -0
  354. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/make/Makefile +101 -0
  355. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.sln +32 -0
  356. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.vcproj +191 -0
  357. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_config.vsprops +15 -0
  358. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_main.vcproj +187 -0
  359. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_test.vcproj +201 -0
  360. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +46 -0
  361. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +145 -0
  362. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +19 -0
  363. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +151 -0
  364. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +176 -0
  365. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +46 -0
  366. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +145 -0
  367. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_config.props +19 -0
  368. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +151 -0
  369. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +176 -0
  370. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +240 -0
  371. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/LICENSE +203 -0
  372. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +34 -0
  373. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README.cppclean +115 -0
  374. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/__init__.py +0 -0
  375. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +1733 -0
  376. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class.py +227 -0
  377. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class_test.py +448 -0
  378. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/keywords.py +59 -0
  379. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/tokenize.py +287 -0
  380. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/utils.py +41 -0
  381. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/gmock_gen.py +31 -0
  382. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock-config.in +303 -0
  383. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock_doctor.py +640 -0
  384. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload.py +1387 -0
  385. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload_gmock.py +78 -0
  386. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-all.cc +47 -0
  387. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +156 -0
  388. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +204 -0
  389. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +573 -0
  390. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +883 -0
  391. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +205 -0
  392. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock_main.cc +54 -0
  393. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
  394. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +1575 -0
  395. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +428 -0
  396. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +1230 -0
  397. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +647 -0
  398. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +129 -0
  399. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +1341 -0
  400. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +718 -0
  401. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +6767 -0
  402. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +710 -0
  403. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +511 -0
  404. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-port_test.cc +43 -0
  405. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +2771 -0
  406. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_all_test.cc +51 -0
  407. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_ex_test.cc +81 -0
  408. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test.py +108 -0
  409. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test_.cc +100 -0
  410. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +40 -0
  411. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +40 -0
  412. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +691 -0
  413. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +183 -0
  414. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +310 -0
  415. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +317 -0
  416. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +323 -0
  417. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +262 -0
  418. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +110 -0
  419. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CHANGES +157 -0
  420. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +312 -0
  421. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CONTRIBUTORS +37 -0
  422. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/LICENSE +28 -0
  423. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +339 -0
  424. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +341 -0
  425. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
  426. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
  427. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +280 -0
  428. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.cbproj +138 -0
  429. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.groupproj +54 -0
  430. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_all.cc +38 -0
  431. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_link.cc +40 -0
  432. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_main.cbproj +82 -0
  433. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_unittest.cbproj +88 -0
  434. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +68 -0
  435. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
  436. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +177 -0
  437. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +93 -0
  438. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/advanced.md +2416 -0
  439. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/faq.md +1092 -0
  440. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/primer.md +536 -0
  441. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/samples.md +14 -0
  442. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +342 -0
  443. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +249 -0
  444. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +1438 -0
  445. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +501 -0
  446. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +1082 -0
  447. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +231 -0
  448. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-test-part.h +179 -0
  449. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +264 -0
  450. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +2332 -0
  451. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +357 -0
  452. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +61 -0
  453. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +70 -0
  454. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
  455. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +45 -0
  456. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +275 -0
  457. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +205 -0
  458. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +1277 -0
  459. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
  460. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +5139 -0
  461. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +279 -0
  462. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +723 -0
  463. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +100 -0
  464. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +2687 -0
  465. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +167 -0
  466. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
  467. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
  468. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +3347 -0
  469. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +313 -0
  470. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/acx_pthread.m4 +363 -0
  471. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/gtest.m4 +74 -0
  472. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/make/Makefile +82 -0
  473. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
  474. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
  475. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
  476. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
  477. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
  478. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
  479. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
  480. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
  481. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
  482. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
  483. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
  484. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
  485. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
  486. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
  487. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
  488. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
  489. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
  490. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
  491. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +127 -0
  492. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +68 -0
  493. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.h +43 -0
  494. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +140 -0
  495. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +154 -0
  496. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.cc +56 -0
  497. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.h +85 -0
  498. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +110 -0
  499. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3-inl.h +172 -0
  500. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +152 -0
  501. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.cc +46 -0
  502. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.h +53 -0
  503. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +49 -0
  504. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +199 -0
  505. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +225 -0
  506. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +118 -0
  507. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +174 -0
  508. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +157 -0
  509. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/common.py +83 -0
  510. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +253 -0
  511. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +730 -0
  512. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gtest-config.in +274 -0
  513. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/pump.py +855 -0
  514. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/release_docs.py +158 -0
  515. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/test/Makefile +59 -0
  516. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1387 -0
  517. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload_gtest.py +78 -0
  518. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +48 -0
  519. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +1536 -0
  520. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +385 -0
  521. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +1175 -0
  522. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +1277 -0
  523. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +458 -0
  524. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +102 -0
  525. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +119 -0
  526. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +5846 -0
  527. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +38 -0
  528. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
  529. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_ex_test.cc +93 -0
  530. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +1424 -0
  531. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +652 -0
  532. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-linked_ptr_test.cc +154 -0
  533. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +311 -0
  534. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-message_test.cc +159 -0
  535. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +213 -0
  536. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +61 -0
  537. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +1110 -0
  538. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +53 -0
  539. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +1303 -0
  540. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +1737 -0
  541. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-test-part_test.cc +208 -0
  542. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-tuple_test.cc +320 -0
  543. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +45 -0
  544. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +380 -0
  545. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.h +66 -0
  546. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +341 -0
  547. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +47 -0
  548. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
  549. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +210 -0
  550. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +87 -0
  551. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +235 -0
  552. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +311 -0
  553. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +129 -0
  554. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +63 -0
  555. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +119 -0
  556. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +124 -0
  557. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +189 -0
  558. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +638 -0
  559. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +138 -0
  560. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +172 -0
  561. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test_.cc +46 -0
  562. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
  563. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
  564. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
  565. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +207 -0
  566. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest_.cc +157 -0
  567. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +45 -0
  568. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_no_test_unittest.cc +56 -0
  569. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +344 -0
  570. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +1067 -0
  571. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +781 -0
  572. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +2427 -0
  573. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_premature_exit_test.cc +127 -0
  574. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +57 -0
  575. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +236 -0
  576. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test.py +325 -0
  577. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test_.cc +103 -0
  578. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_sole_header_test.cc +57 -0
  579. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +250 -0
  580. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +318 -0
  581. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
  582. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
  583. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_ex_test.cc +92 -0
  584. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +171 -0
  585. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test_.cc +72 -0
  586. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +69 -0
  587. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +43 -0
  588. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +7797 -0
  589. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +48 -0
  590. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +48 -0
  591. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +140 -0
  592. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +378 -0
  593. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +179 -0
  594. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +196 -0
  595. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +36 -0
  596. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +55 -0
  597. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/DebugProject.xcconfig +30 -0
  598. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/FrameworkTarget.xcconfig +17 -0
  599. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/General.xcconfig +41 -0
  600. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/ReleaseProject.xcconfig +32 -0
  601. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/StaticLibraryTarget.xcconfig +18 -0
  602. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/TestTarget.xcconfig +8 -0
  603. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Resources/Info.plist +30 -0
  604. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/Info.plist +28 -0
  605. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj +457 -0
  606. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/runtests.sh +62 -0
  607. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.cc +63 -0
  608. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.h +59 -0
  609. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget_test.cc +68 -0
  610. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/runtests.sh +65 -0
  611. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +100 -0
  612. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +1182 -0
  613. data/ext/rj_schema/rapidjson/travis-doxygen.sh +128 -0
  614. metadata +613 -1
@@ -0,0 +1,51 @@
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. All rights reserved.
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/rapidjson.h"
17
+
18
+ #ifdef __clang__
19
+ #pragma GCC diagnostic push
20
+ #if __has_warning("-Wdeprecated")
21
+ #pragma GCC diagnostic ignored "-Wdeprecated"
22
+ #endif
23
+ #endif
24
+
25
+ AssertException::~AssertException() throw() {}
26
+
27
+ #ifdef __clang__
28
+ #pragma GCC diagnostic pop
29
+ #endif
30
+
31
+ int main(int argc, char **argv) {
32
+ ::testing::InitGoogleTest(&argc, argv);
33
+
34
+ std::cout << "RapidJSON v" << RAPIDJSON_VERSION_STRING << std::endl;
35
+
36
+ #ifdef _MSC_VER
37
+ _CrtMemState memoryState = { 0 };
38
+ (void)memoryState;
39
+ _CrtMemCheckpoint(&memoryState);
40
+ //_CrtSetBreakAlloc(X);
41
+ //void *testWhetherMemoryLeakDetectionWorks = malloc(1);
42
+ #endif
43
+
44
+ int ret = RUN_ALL_TESTS();
45
+
46
+ #ifdef _MSC_VER
47
+ // Current gtest constantly leak 2 blocks at exit
48
+ _CrtMemDumpAllObjectsSince(&memoryState);
49
+ #endif
50
+ return ret;
51
+ }
@@ -0,0 +1,143 @@
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. All rights reserved.
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
+ #ifndef UNITTEST_H_
16
+ #define UNITTEST_H_
17
+
18
+ // gtest indirectly included inttypes.h, without __STDC_CONSTANT_MACROS.
19
+ #ifndef __STDC_CONSTANT_MACROS
20
+ #ifdef __clang__
21
+ #pragma GCC diagnostic push
22
+ #if __has_warning("-Wreserved-id-macro")
23
+ #pragma GCC diagnostic ignored "-Wreserved-id-macro"
24
+ #endif
25
+ #endif
26
+
27
+ # define __STDC_CONSTANT_MACROS 1 // required by C++ standard
28
+
29
+ #ifdef __clang__
30
+ #pragma GCC diagnostic pop
31
+ #endif
32
+ #endif
33
+
34
+ #ifdef _MSC_VER
35
+ #define _CRTDBG_MAP_ALLOC
36
+ #include <crtdbg.h>
37
+ #pragma warning(disable : 4996) // 'function': was declared deprecated
38
+ #endif
39
+
40
+ #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
41
+ #if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
42
+ #pragma GCC diagnostic push
43
+ #endif
44
+ #pragma GCC diagnostic ignored "-Weffc++"
45
+ #endif
46
+
47
+ #include "gtest/gtest.h"
48
+ #include <stdexcept>
49
+
50
+ #if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
51
+ #pragma GCC diagnostic pop
52
+ #endif
53
+
54
+ #ifdef __clang__
55
+ // All TEST() macro generated this warning, disable globally
56
+ #pragma GCC diagnostic ignored "-Wglobal-constructors"
57
+ #endif
58
+
59
+ template <typename Ch>
60
+ inline unsigned StrLen(const Ch* s) {
61
+ const Ch* p = s;
62
+ while (*p) p++;
63
+ return unsigned(p - s);
64
+ }
65
+
66
+ template<typename Ch>
67
+ inline int StrCmp(const Ch* s1, const Ch* s2) {
68
+ while(*s1 && (*s1 == *s2)) { s1++; s2++; }
69
+ return static_cast<unsigned>(*s1) < static_cast<unsigned>(*s2) ? -1 : static_cast<unsigned>(*s1) > static_cast<unsigned>(*s2);
70
+ }
71
+
72
+ template <typename Ch>
73
+ inline Ch* StrDup(const Ch* str) {
74
+ size_t bufferSize = sizeof(Ch) * (StrLen(str) + 1);
75
+ Ch* buffer = static_cast<Ch*>(malloc(bufferSize));
76
+ memcpy(buffer, str, bufferSize);
77
+ return buffer;
78
+ }
79
+
80
+ inline FILE* TempFile(char *filename) {
81
+ #if defined(__WIN32__) || defined(_MSC_VER)
82
+ filename = tmpnam(filename);
83
+
84
+ // For Visual Studio, tmpnam() adds a backslash in front. Remove it.
85
+ if (filename[0] == '\\')
86
+ for (int i = 0; filename[i] != '\0'; i++)
87
+ filename[i] = filename[i + 1];
88
+
89
+ return fopen(filename, "wb");
90
+ #else
91
+ strcpy(filename, "/tmp/fileXXXXXX");
92
+ int fd = mkstemp(filename);
93
+ return fdopen(fd, "w");
94
+ #endif
95
+ }
96
+
97
+ // Use exception for catching assert
98
+ #ifdef _MSC_VER
99
+ #pragma warning(disable : 4127)
100
+ #endif
101
+
102
+ #ifdef __clang__
103
+ #pragma GCC diagnostic push
104
+ #if __has_warning("-Wdeprecated")
105
+ #pragma GCC diagnostic ignored "-Wdeprecated"
106
+ #endif
107
+ #endif
108
+
109
+ class AssertException : public std::logic_error {
110
+ public:
111
+ AssertException(const char* w) : std::logic_error(w) {}
112
+ AssertException(const AssertException& rhs) : std::logic_error(rhs) {}
113
+ virtual ~AssertException() throw();
114
+ };
115
+
116
+ #ifdef __clang__
117
+ #pragma GCC diagnostic pop
118
+ #endif
119
+
120
+ // Not using noexcept for testing RAPIDJSON_ASSERT()
121
+ #define RAPIDJSON_HAS_CXX11_NOEXCEPT 0
122
+
123
+ #ifndef RAPIDJSON_ASSERT
124
+ #define RAPIDJSON_ASSERT(x) (!(x) ? throw AssertException(RAPIDJSON_STRINGIFY(x)) : (void)0u)
125
+ #ifndef RAPIDJSON_ASSERT_THROWS
126
+ #define RAPIDJSON_ASSERT_THROWS
127
+ #endif
128
+ #endif
129
+
130
+ class Random {
131
+ public:
132
+ Random(unsigned seed = 0) : mSeed(seed) {}
133
+
134
+ unsigned operator()() {
135
+ mSeed = 214013 * mSeed + 2531011;
136
+ return mSeed;
137
+ }
138
+
139
+ private:
140
+ unsigned mSeed;
141
+ };
142
+
143
+ #endif // UNITTEST_H_
@@ -0,0 +1,1851 @@
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. All rights reserved.
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/document.h"
17
+ #include <algorithm>
18
+
19
+ #ifdef __clang__
20
+ RAPIDJSON_DIAG_PUSH
21
+ RAPIDJSON_DIAG_OFF(c++98-compat)
22
+ #endif
23
+
24
+ using namespace rapidjson;
25
+
26
+ TEST(Value, Size) {
27
+ if (sizeof(SizeType) == 4) {
28
+ #if RAPIDJSON_48BITPOINTER_OPTIMIZATION
29
+ EXPECT_EQ(16u, sizeof(Value));
30
+ #elif RAPIDJSON_64BIT
31
+ EXPECT_EQ(24u, sizeof(Value));
32
+ #else
33
+ EXPECT_EQ(16u, sizeof(Value));
34
+ #endif
35
+ }
36
+ }
37
+
38
+ TEST(Value, DefaultConstructor) {
39
+ Value x;
40
+ EXPECT_EQ(kNullType, x.GetType());
41
+ EXPECT_TRUE(x.IsNull());
42
+
43
+ //std::cout << "sizeof(Value): " << sizeof(x) << std::endl;
44
+ }
45
+
46
+ // Should not pass compilation
47
+ //TEST(Value, copy_constructor) {
48
+ // Value x(1234);
49
+ // Value y = x;
50
+ //}
51
+
52
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
53
+
54
+ #if 0 // Many old compiler does not support these. Turn it off temporaily.
55
+
56
+ #include <type_traits>
57
+
58
+ TEST(Value, Traits) {
59
+ typedef GenericValue<UTF8<>, CrtAllocator> Value;
60
+ static_assert(std::is_constructible<Value>::value, "");
61
+ static_assert(std::is_default_constructible<Value>::value, "");
62
+ #ifndef _MSC_VER
63
+ static_assert(!std::is_copy_constructible<Value>::value, "");
64
+ #endif
65
+ static_assert(std::is_move_constructible<Value>::value, "");
66
+
67
+ #ifndef _MSC_VER
68
+ static_assert(std::is_nothrow_constructible<Value>::value, "");
69
+ static_assert(std::is_nothrow_default_constructible<Value>::value, "");
70
+ static_assert(!std::is_nothrow_copy_constructible<Value>::value, "");
71
+ static_assert(std::is_nothrow_move_constructible<Value>::value, "");
72
+ #endif
73
+
74
+ static_assert(std::is_assignable<Value,Value>::value, "");
75
+ #ifndef _MSC_VER
76
+ static_assert(!std::is_copy_assignable<Value>::value, "");
77
+ #endif
78
+ static_assert(std::is_move_assignable<Value>::value, "");
79
+
80
+ #ifndef _MSC_VER
81
+ static_assert(std::is_nothrow_assignable<Value, Value>::value, "");
82
+ #endif
83
+ static_assert(!std::is_nothrow_copy_assignable<Value>::value, "");
84
+ #ifndef _MSC_VER
85
+ static_assert(std::is_nothrow_move_assignable<Value>::value, "");
86
+ #endif
87
+
88
+ static_assert(std::is_destructible<Value>::value, "");
89
+ #ifndef _MSC_VER
90
+ static_assert(std::is_nothrow_destructible<Value>::value, "");
91
+ #endif
92
+ }
93
+
94
+ #endif
95
+
96
+ TEST(Value, MoveConstructor) {
97
+ typedef GenericValue<UTF8<>, CrtAllocator> V;
98
+ V::AllocatorType allocator;
99
+
100
+ V x((V(kArrayType)));
101
+ x.Reserve(4u, allocator);
102
+ x.PushBack(1, allocator).PushBack(2, allocator).PushBack(3, allocator).PushBack(4, allocator);
103
+ EXPECT_TRUE(x.IsArray());
104
+ EXPECT_EQ(4u, x.Size());
105
+
106
+ // Value y(x); // does not compile (!is_copy_constructible)
107
+ V y(std::move(x));
108
+ EXPECT_TRUE(x.IsNull());
109
+ EXPECT_TRUE(y.IsArray());
110
+ EXPECT_EQ(4u, y.Size());
111
+
112
+ // Value z = y; // does not compile (!is_copy_assignable)
113
+ V z = std::move(y);
114
+ EXPECT_TRUE(y.IsNull());
115
+ EXPECT_TRUE(z.IsArray());
116
+ EXPECT_EQ(4u, z.Size());
117
+ }
118
+
119
+ #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
120
+
121
+ TEST(Value, AssignmentOperator) {
122
+ Value x(1234);
123
+ Value y;
124
+ y = x;
125
+ EXPECT_TRUE(x.IsNull()); // move semantic
126
+ EXPECT_EQ(1234, y.GetInt());
127
+
128
+ y = 5678;
129
+ EXPECT_TRUE(y.IsInt());
130
+ EXPECT_EQ(5678, y.GetInt());
131
+
132
+ x = "Hello";
133
+ EXPECT_TRUE(x.IsString());
134
+ EXPECT_STREQ(x.GetString(),"Hello");
135
+
136
+ y = StringRef(x.GetString(),x.GetStringLength());
137
+ EXPECT_TRUE(y.IsString());
138
+ EXPECT_EQ(y.GetString(),x.GetString());
139
+ EXPECT_EQ(y.GetStringLength(),x.GetStringLength());
140
+
141
+ static char mstr[] = "mutable";
142
+ // y = mstr; // should not compile
143
+ y = StringRef(mstr);
144
+ EXPECT_TRUE(y.IsString());
145
+ EXPECT_EQ(y.GetString(),mstr);
146
+
147
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
148
+ // C++11 move assignment
149
+ x = Value("World");
150
+ EXPECT_TRUE(x.IsString());
151
+ EXPECT_STREQ("World", x.GetString());
152
+
153
+ x = std::move(y);
154
+ EXPECT_TRUE(y.IsNull());
155
+ EXPECT_TRUE(x.IsString());
156
+ EXPECT_EQ(x.GetString(), mstr);
157
+
158
+ y = std::move(Value().SetInt(1234));
159
+ EXPECT_TRUE(y.IsInt());
160
+ EXPECT_EQ(1234, y);
161
+ #endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS
162
+ }
163
+
164
+ template <typename A, typename B>
165
+ void TestEqual(const A& a, const B& b) {
166
+ EXPECT_TRUE (a == b);
167
+ EXPECT_FALSE(a != b);
168
+ EXPECT_TRUE (b == a);
169
+ EXPECT_FALSE(b != a);
170
+ }
171
+
172
+ template <typename A, typename B>
173
+ void TestUnequal(const A& a, const B& b) {
174
+ EXPECT_FALSE(a == b);
175
+ EXPECT_TRUE (a != b);
176
+ EXPECT_FALSE(b == a);
177
+ EXPECT_TRUE (b != a);
178
+ }
179
+
180
+ TEST(Value, EqualtoOperator) {
181
+ Value::AllocatorType allocator;
182
+ Value x(kObjectType);
183
+ x.AddMember("hello", "world", allocator)
184
+ .AddMember("t", Value(true).Move(), allocator)
185
+ .AddMember("f", Value(false).Move(), allocator)
186
+ .AddMember("n", Value(kNullType).Move(), allocator)
187
+ .AddMember("i", 123, allocator)
188
+ .AddMember("pi", 3.14, allocator)
189
+ .AddMember("a", Value(kArrayType).Move().PushBack(1, allocator).PushBack(2, allocator).PushBack(3, allocator), allocator);
190
+
191
+ // Test templated operator==() and operator!=()
192
+ TestEqual(x["hello"], "world");
193
+ const char* cc = "world";
194
+ TestEqual(x["hello"], cc);
195
+ char* c = strdup("world");
196
+ TestEqual(x["hello"], c);
197
+ free(c);
198
+
199
+ TestEqual(x["t"], true);
200
+ TestEqual(x["f"], false);
201
+ TestEqual(x["i"], 123);
202
+ TestEqual(x["pi"], 3.14);
203
+
204
+ // Test operator==() (including different allocators)
205
+ CrtAllocator crtAllocator;
206
+ GenericValue<UTF8<>, CrtAllocator> y;
207
+ GenericDocument<UTF8<>, CrtAllocator> z(&crtAllocator);
208
+ y.CopyFrom(x, crtAllocator);
209
+ z.CopyFrom(y, z.GetAllocator());
210
+ TestEqual(x, y);
211
+ TestEqual(y, z);
212
+ TestEqual(z, x);
213
+
214
+ // Swapping member order should be fine.
215
+ EXPECT_TRUE(y.RemoveMember("t"));
216
+ TestUnequal(x, y);
217
+ TestUnequal(z, y);
218
+ EXPECT_TRUE(z.RemoveMember("t"));
219
+ TestUnequal(x, z);
220
+ TestEqual(y, z);
221
+ y.AddMember("t", false, crtAllocator);
222
+ z.AddMember("t", false, z.GetAllocator());
223
+ TestUnequal(x, y);
224
+ TestUnequal(z, x);
225
+ y["t"] = true;
226
+ z["t"] = true;
227
+ TestEqual(x, y);
228
+ TestEqual(y, z);
229
+ TestEqual(z, x);
230
+
231
+ // Swapping element order is not OK
232
+ x["a"][0].Swap(x["a"][1]);
233
+ TestUnequal(x, y);
234
+ x["a"][0].Swap(x["a"][1]);
235
+ TestEqual(x, y);
236
+
237
+ // Array of different size
238
+ x["a"].PushBack(4, allocator);
239
+ TestUnequal(x, y);
240
+ x["a"].PopBack();
241
+ TestEqual(x, y);
242
+
243
+ // Issue #129: compare Uint64
244
+ x.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF0));
245
+ y.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF));
246
+ TestUnequal(x, y);
247
+ }
248
+
249
+ template <typename Value>
250
+ void TestCopyFrom() {
251
+ typename Value::AllocatorType a;
252
+ Value v1(1234);
253
+ Value v2(v1, a); // deep copy constructor
254
+ EXPECT_TRUE(v1.GetType() == v2.GetType());
255
+ EXPECT_EQ(v1.GetInt(), v2.GetInt());
256
+
257
+ v1.SetString("foo");
258
+ v2.CopyFrom(v1, a);
259
+ EXPECT_TRUE(v1.GetType() == v2.GetType());
260
+ EXPECT_STREQ(v1.GetString(), v2.GetString());
261
+ EXPECT_EQ(v1.GetString(), v2.GetString()); // string NOT copied
262
+
263
+ v1.SetString("bar", a); // copy string
264
+ v2.CopyFrom(v1, a);
265
+ EXPECT_TRUE(v1.GetType() == v2.GetType());
266
+ EXPECT_STREQ(v1.GetString(), v2.GetString());
267
+ EXPECT_NE(v1.GetString(), v2.GetString()); // string copied
268
+
269
+
270
+ v1.SetArray().PushBack(1234, a);
271
+ v2.CopyFrom(v1, a);
272
+ EXPECT_TRUE(v2.IsArray());
273
+ EXPECT_EQ(v1.Size(), v2.Size());
274
+
275
+ v1.PushBack(Value().SetString("foo", a), a); // push string copy
276
+ EXPECT_TRUE(v1.Size() != v2.Size());
277
+ v2.CopyFrom(v1, a);
278
+ EXPECT_TRUE(v1.Size() == v2.Size());
279
+ EXPECT_STREQ(v1[1].GetString(), v2[1].GetString());
280
+ EXPECT_NE(v1[1].GetString(), v2[1].GetString()); // string got copied
281
+ }
282
+
283
+ TEST(Value, CopyFrom) {
284
+ TestCopyFrom<Value>();
285
+ TestCopyFrom<GenericValue<UTF8<>, CrtAllocator> >();
286
+ }
287
+
288
+ TEST(Value, Swap) {
289
+ Value v1(1234);
290
+ Value v2(kObjectType);
291
+
292
+ EXPECT_EQ(&v1, &v1.Swap(v2));
293
+ EXPECT_TRUE(v1.IsObject());
294
+ EXPECT_TRUE(v2.IsInt());
295
+ EXPECT_EQ(1234, v2.GetInt());
296
+
297
+ // testing std::swap compatibility
298
+ using std::swap;
299
+ swap(v1, v2);
300
+ EXPECT_TRUE(v1.IsInt());
301
+ EXPECT_TRUE(v2.IsObject());
302
+ }
303
+
304
+ TEST(Value, Null) {
305
+ // Default constructor
306
+ Value x;
307
+ EXPECT_EQ(kNullType, x.GetType());
308
+ EXPECT_TRUE(x.IsNull());
309
+
310
+ EXPECT_FALSE(x.IsTrue());
311
+ EXPECT_FALSE(x.IsFalse());
312
+ EXPECT_FALSE(x.IsNumber());
313
+ EXPECT_FALSE(x.IsString());
314
+ EXPECT_FALSE(x.IsObject());
315
+ EXPECT_FALSE(x.IsArray());
316
+
317
+ // Constructor with type
318
+ Value y(kNullType);
319
+ EXPECT_TRUE(y.IsNull());
320
+
321
+ // SetNull();
322
+ Value z(true);
323
+ z.SetNull();
324
+ EXPECT_TRUE(z.IsNull());
325
+ }
326
+
327
+ TEST(Value, True) {
328
+ // Constructor with bool
329
+ Value x(true);
330
+ EXPECT_EQ(kTrueType, x.GetType());
331
+ EXPECT_TRUE(x.GetBool());
332
+ EXPECT_TRUE(x.IsBool());
333
+ EXPECT_TRUE(x.IsTrue());
334
+
335
+ EXPECT_FALSE(x.IsNull());
336
+ EXPECT_FALSE(x.IsFalse());
337
+ EXPECT_FALSE(x.IsNumber());
338
+ EXPECT_FALSE(x.IsString());
339
+ EXPECT_FALSE(x.IsObject());
340
+ EXPECT_FALSE(x.IsArray());
341
+
342
+ // Constructor with type
343
+ Value y(kTrueType);
344
+ EXPECT_TRUE(y.IsTrue());
345
+
346
+ // SetBool()
347
+ Value z;
348
+ z.SetBool(true);
349
+ EXPECT_TRUE(z.IsTrue());
350
+
351
+ // Templated functions
352
+ EXPECT_TRUE(z.Is<bool>());
353
+ EXPECT_TRUE(z.Get<bool>());
354
+ EXPECT_FALSE(z.Set<bool>(false).Get<bool>());
355
+ EXPECT_TRUE(z.Set(true).Get<bool>());
356
+ }
357
+
358
+ TEST(Value, False) {
359
+ // Constructor with bool
360
+ Value x(false);
361
+ EXPECT_EQ(kFalseType, x.GetType());
362
+ EXPECT_TRUE(x.IsBool());
363
+ EXPECT_TRUE(x.IsFalse());
364
+
365
+ EXPECT_FALSE(x.IsNull());
366
+ EXPECT_FALSE(x.IsTrue());
367
+ EXPECT_FALSE(x.GetBool());
368
+ //EXPECT_FALSE((bool)x);
369
+ EXPECT_FALSE(x.IsNumber());
370
+ EXPECT_FALSE(x.IsString());
371
+ EXPECT_FALSE(x.IsObject());
372
+ EXPECT_FALSE(x.IsArray());
373
+
374
+ // Constructor with type
375
+ Value y(kFalseType);
376
+ EXPECT_TRUE(y.IsFalse());
377
+
378
+ // SetBool()
379
+ Value z;
380
+ z.SetBool(false);
381
+ EXPECT_TRUE(z.IsFalse());
382
+ }
383
+
384
+ TEST(Value, Int) {
385
+ // Constructor with int
386
+ Value x(1234);
387
+ EXPECT_EQ(kNumberType, x.GetType());
388
+ EXPECT_EQ(1234, x.GetInt());
389
+ EXPECT_EQ(1234u, x.GetUint());
390
+ EXPECT_EQ(1234, x.GetInt64());
391
+ EXPECT_EQ(1234u, x.GetUint64());
392
+ EXPECT_NEAR(1234.0, x.GetDouble(), 0.0);
393
+ //EXPECT_EQ(1234, (int)x);
394
+ //EXPECT_EQ(1234, (unsigned)x);
395
+ //EXPECT_EQ(1234, (int64_t)x);
396
+ //EXPECT_EQ(1234, (uint64_t)x);
397
+ //EXPECT_EQ(1234, (double)x);
398
+ EXPECT_TRUE(x.IsNumber());
399
+ EXPECT_TRUE(x.IsInt());
400
+ EXPECT_TRUE(x.IsUint());
401
+ EXPECT_TRUE(x.IsInt64());
402
+ EXPECT_TRUE(x.IsUint64());
403
+
404
+ EXPECT_FALSE(x.IsDouble());
405
+ EXPECT_FALSE(x.IsFloat());
406
+ EXPECT_FALSE(x.IsNull());
407
+ EXPECT_FALSE(x.IsBool());
408
+ EXPECT_FALSE(x.IsFalse());
409
+ EXPECT_FALSE(x.IsTrue());
410
+ EXPECT_FALSE(x.IsString());
411
+ EXPECT_FALSE(x.IsObject());
412
+ EXPECT_FALSE(x.IsArray());
413
+
414
+ Value nx(-1234);
415
+ EXPECT_EQ(-1234, nx.GetInt());
416
+ EXPECT_EQ(-1234, nx.GetInt64());
417
+ EXPECT_TRUE(nx.IsInt());
418
+ EXPECT_TRUE(nx.IsInt64());
419
+ EXPECT_FALSE(nx.IsUint());
420
+ EXPECT_FALSE(nx.IsUint64());
421
+
422
+ // Constructor with type
423
+ Value y(kNumberType);
424
+ EXPECT_TRUE(y.IsNumber());
425
+ EXPECT_TRUE(y.IsInt());
426
+ EXPECT_EQ(0, y.GetInt());
427
+
428
+ // SetInt()
429
+ Value z;
430
+ z.SetInt(1234);
431
+ EXPECT_EQ(1234, z.GetInt());
432
+
433
+ // operator=(int)
434
+ z = 5678;
435
+ EXPECT_EQ(5678, z.GetInt());
436
+
437
+ // Templated functions
438
+ EXPECT_TRUE(z.Is<int>());
439
+ EXPECT_EQ(5678, z.Get<int>());
440
+ EXPECT_EQ(5679, z.Set(5679).Get<int>());
441
+ EXPECT_EQ(5680, z.Set<int>(5680).Get<int>());
442
+
443
+ #ifdef _MSC_VER
444
+ // long as int on MSC platforms
445
+ RAPIDJSON_STATIC_ASSERT(sizeof(long) == sizeof(int));
446
+ z.SetInt(2222);
447
+ EXPECT_TRUE(z.Is<long>());
448
+ EXPECT_EQ(2222l, z.Get<long>());
449
+ EXPECT_EQ(3333l, z.Set(3333l).Get<long>());
450
+ EXPECT_EQ(4444l, z.Set<long>(4444l).Get<long>());
451
+ EXPECT_TRUE(z.IsInt());
452
+ #endif
453
+ }
454
+
455
+ TEST(Value, Uint) {
456
+ // Constructor with int
457
+ Value x(1234u);
458
+ EXPECT_EQ(kNumberType, x.GetType());
459
+ EXPECT_EQ(1234, x.GetInt());
460
+ EXPECT_EQ(1234u, x.GetUint());
461
+ EXPECT_EQ(1234, x.GetInt64());
462
+ EXPECT_EQ(1234u, x.GetUint64());
463
+ EXPECT_TRUE(x.IsNumber());
464
+ EXPECT_TRUE(x.IsInt());
465
+ EXPECT_TRUE(x.IsUint());
466
+ EXPECT_TRUE(x.IsInt64());
467
+ EXPECT_TRUE(x.IsUint64());
468
+ EXPECT_NEAR(1234.0, x.GetDouble(), 0.0); // Number can always be cast as double but !IsDouble().
469
+
470
+ EXPECT_FALSE(x.IsDouble());
471
+ EXPECT_FALSE(x.IsFloat());
472
+ EXPECT_FALSE(x.IsNull());
473
+ EXPECT_FALSE(x.IsBool());
474
+ EXPECT_FALSE(x.IsFalse());
475
+ EXPECT_FALSE(x.IsTrue());
476
+ EXPECT_FALSE(x.IsString());
477
+ EXPECT_FALSE(x.IsObject());
478
+ EXPECT_FALSE(x.IsArray());
479
+
480
+ // SetUint()
481
+ Value z;
482
+ z.SetUint(1234);
483
+ EXPECT_EQ(1234u, z.GetUint());
484
+
485
+ // operator=(unsigned)
486
+ z = 5678u;
487
+ EXPECT_EQ(5678u, z.GetUint());
488
+
489
+ z = 2147483648u; // 2^31, cannot cast as int
490
+ EXPECT_EQ(2147483648u, z.GetUint());
491
+ EXPECT_FALSE(z.IsInt());
492
+ EXPECT_TRUE(z.IsInt64()); // Issue 41: Incorrect parsing of unsigned int number types
493
+
494
+ // Templated functions
495
+ EXPECT_TRUE(z.Is<unsigned>());
496
+ EXPECT_EQ(2147483648u, z.Get<unsigned>());
497
+ EXPECT_EQ(2147483649u, z.Set(2147483649u).Get<unsigned>());
498
+ EXPECT_EQ(2147483650u, z.Set<unsigned>(2147483650u).Get<unsigned>());
499
+
500
+ #ifdef _MSC_VER
501
+ // unsigned long as unsigned on MSC platforms
502
+ RAPIDJSON_STATIC_ASSERT(sizeof(unsigned long) == sizeof(unsigned));
503
+ z.SetUint(2222);
504
+ EXPECT_TRUE(z.Is<unsigned long>());
505
+ EXPECT_EQ(2222ul, z.Get<unsigned long>());
506
+ EXPECT_EQ(3333ul, z.Set(3333ul).Get<unsigned long>());
507
+ EXPECT_EQ(4444ul, z.Set<unsigned long>(4444ul).Get<unsigned long>());
508
+ EXPECT_TRUE(x.IsUint());
509
+ #endif
510
+ }
511
+
512
+ TEST(Value, Int64) {
513
+ // Constructor with int
514
+ Value x(int64_t(1234));
515
+ EXPECT_EQ(kNumberType, x.GetType());
516
+ EXPECT_EQ(1234, x.GetInt());
517
+ EXPECT_EQ(1234u, x.GetUint());
518
+ EXPECT_EQ(1234, x.GetInt64());
519
+ EXPECT_EQ(1234u, x.GetUint64());
520
+ EXPECT_TRUE(x.IsNumber());
521
+ EXPECT_TRUE(x.IsInt());
522
+ EXPECT_TRUE(x.IsUint());
523
+ EXPECT_TRUE(x.IsInt64());
524
+ EXPECT_TRUE(x.IsUint64());
525
+
526
+ EXPECT_FALSE(x.IsDouble());
527
+ EXPECT_FALSE(x.IsFloat());
528
+ EXPECT_FALSE(x.IsNull());
529
+ EXPECT_FALSE(x.IsBool());
530
+ EXPECT_FALSE(x.IsFalse());
531
+ EXPECT_FALSE(x.IsTrue());
532
+ EXPECT_FALSE(x.IsString());
533
+ EXPECT_FALSE(x.IsObject());
534
+ EXPECT_FALSE(x.IsArray());
535
+
536
+ Value nx(int64_t(-1234));
537
+ EXPECT_EQ(-1234, nx.GetInt());
538
+ EXPECT_EQ(-1234, nx.GetInt64());
539
+ EXPECT_TRUE(nx.IsInt());
540
+ EXPECT_TRUE(nx.IsInt64());
541
+ EXPECT_FALSE(nx.IsUint());
542
+ EXPECT_FALSE(nx.IsUint64());
543
+
544
+ // SetInt64()
545
+ Value z;
546
+ z.SetInt64(1234);
547
+ EXPECT_EQ(1234, z.GetInt64());
548
+
549
+ z.SetInt64(2147483648u); // 2^31, cannot cast as int
550
+ EXPECT_FALSE(z.IsInt());
551
+ EXPECT_TRUE(z.IsUint());
552
+ EXPECT_NEAR(2147483648.0, z.GetDouble(), 0.0);
553
+
554
+ z.SetInt64(int64_t(4294967295u) + 1); // 2^32, cannot cast as uint
555
+ EXPECT_FALSE(z.IsInt());
556
+ EXPECT_FALSE(z.IsUint());
557
+ EXPECT_NEAR(4294967296.0, z.GetDouble(), 0.0);
558
+
559
+ z.SetInt64(-int64_t(2147483648u) - 1); // -2^31-1, cannot cast as int
560
+ EXPECT_FALSE(z.IsInt());
561
+ EXPECT_NEAR(-2147483649.0, z.GetDouble(), 0.0);
562
+
563
+ int64_t i = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 00000000));
564
+ z.SetInt64(i);
565
+ EXPECT_DOUBLE_EQ(-9223372036854775808.0, z.GetDouble());
566
+
567
+ // Templated functions
568
+ EXPECT_TRUE(z.Is<int64_t>());
569
+ EXPECT_EQ(i, z.Get<int64_t>());
570
+ #if 0 // signed integer underflow is undefined behaviour
571
+ EXPECT_EQ(i - 1, z.Set(i - 1).Get<int64_t>());
572
+ EXPECT_EQ(i - 2, z.Set<int64_t>(i - 2).Get<int64_t>());
573
+ #endif
574
+ }
575
+
576
+ TEST(Value, Uint64) {
577
+ // Constructor with int
578
+ Value x(uint64_t(1234));
579
+ EXPECT_EQ(kNumberType, x.GetType());
580
+ EXPECT_EQ(1234, x.GetInt());
581
+ EXPECT_EQ(1234u, x.GetUint());
582
+ EXPECT_EQ(1234, x.GetInt64());
583
+ EXPECT_EQ(1234u, x.GetUint64());
584
+ EXPECT_TRUE(x.IsNumber());
585
+ EXPECT_TRUE(x.IsInt());
586
+ EXPECT_TRUE(x.IsUint());
587
+ EXPECT_TRUE(x.IsInt64());
588
+ EXPECT_TRUE(x.IsUint64());
589
+
590
+ EXPECT_FALSE(x.IsDouble());
591
+ EXPECT_FALSE(x.IsFloat());
592
+ EXPECT_FALSE(x.IsNull());
593
+ EXPECT_FALSE(x.IsBool());
594
+ EXPECT_FALSE(x.IsFalse());
595
+ EXPECT_FALSE(x.IsTrue());
596
+ EXPECT_FALSE(x.IsString());
597
+ EXPECT_FALSE(x.IsObject());
598
+ EXPECT_FALSE(x.IsArray());
599
+
600
+ // SetUint64()
601
+ Value z;
602
+ z.SetUint64(1234);
603
+ EXPECT_EQ(1234u, z.GetUint64());
604
+
605
+ z.SetUint64(uint64_t(2147483648u)); // 2^31, cannot cast as int
606
+ EXPECT_FALSE(z.IsInt());
607
+ EXPECT_TRUE(z.IsUint());
608
+ EXPECT_TRUE(z.IsInt64());
609
+
610
+ z.SetUint64(uint64_t(4294967295u) + 1); // 2^32, cannot cast as uint
611
+ EXPECT_FALSE(z.IsInt());
612
+ EXPECT_FALSE(z.IsUint());
613
+ EXPECT_TRUE(z.IsInt64());
614
+
615
+ uint64_t u = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000);
616
+ z.SetUint64(u); // 2^63 cannot cast as int64
617
+ EXPECT_FALSE(z.IsInt64());
618
+ EXPECT_EQ(u, z.GetUint64()); // Issue 48
619
+ EXPECT_DOUBLE_EQ(9223372036854775808.0, z.GetDouble());
620
+
621
+ // Templated functions
622
+ EXPECT_TRUE(z.Is<uint64_t>());
623
+ EXPECT_EQ(u, z.Get<uint64_t>());
624
+ EXPECT_EQ(u + 1, z.Set(u + 1).Get<uint64_t>());
625
+ EXPECT_EQ(u + 2, z.Set<uint64_t>(u + 2).Get<uint64_t>());
626
+ }
627
+
628
+ TEST(Value, Double) {
629
+ // Constructor with double
630
+ Value x(12.34);
631
+ EXPECT_EQ(kNumberType, x.GetType());
632
+ EXPECT_NEAR(12.34, x.GetDouble(), 0.0);
633
+ EXPECT_TRUE(x.IsNumber());
634
+ EXPECT_TRUE(x.IsDouble());
635
+
636
+ EXPECT_FALSE(x.IsInt());
637
+ EXPECT_FALSE(x.IsNull());
638
+ EXPECT_FALSE(x.IsBool());
639
+ EXPECT_FALSE(x.IsFalse());
640
+ EXPECT_FALSE(x.IsTrue());
641
+ EXPECT_FALSE(x.IsString());
642
+ EXPECT_FALSE(x.IsObject());
643
+ EXPECT_FALSE(x.IsArray());
644
+
645
+ // SetDouble()
646
+ Value z;
647
+ z.SetDouble(12.34);
648
+ EXPECT_NEAR(12.34, z.GetDouble(), 0.0);
649
+
650
+ z = 56.78;
651
+ EXPECT_NEAR(56.78, z.GetDouble(), 0.0);
652
+
653
+ // Templated functions
654
+ EXPECT_TRUE(z.Is<double>());
655
+ EXPECT_EQ(56.78, z.Get<double>());
656
+ EXPECT_EQ(57.78, z.Set(57.78).Get<double>());
657
+ EXPECT_EQ(58.78, z.Set<double>(58.78).Get<double>());
658
+ }
659
+
660
+ TEST(Value, Float) {
661
+ // Constructor with double
662
+ Value x(12.34f);
663
+ EXPECT_EQ(kNumberType, x.GetType());
664
+ EXPECT_NEAR(12.34f, x.GetFloat(), 0.0);
665
+ EXPECT_TRUE(x.IsNumber());
666
+ EXPECT_TRUE(x.IsDouble());
667
+ EXPECT_TRUE(x.IsFloat());
668
+
669
+ EXPECT_FALSE(x.IsInt());
670
+ EXPECT_FALSE(x.IsNull());
671
+ EXPECT_FALSE(x.IsBool());
672
+ EXPECT_FALSE(x.IsFalse());
673
+ EXPECT_FALSE(x.IsTrue());
674
+ EXPECT_FALSE(x.IsString());
675
+ EXPECT_FALSE(x.IsObject());
676
+ EXPECT_FALSE(x.IsArray());
677
+
678
+ // SetFloat()
679
+ Value z;
680
+ z.SetFloat(12.34f);
681
+ EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f);
682
+
683
+ // Issue 573
684
+ z.SetInt(0);
685
+ EXPECT_EQ(0.0f, z.GetFloat());
686
+
687
+ z = 56.78f;
688
+ EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f);
689
+
690
+ // Templated functions
691
+ EXPECT_TRUE(z.Is<float>());
692
+ EXPECT_EQ(56.78f, z.Get<float>());
693
+ EXPECT_EQ(57.78f, z.Set(57.78f).Get<float>());
694
+ EXPECT_EQ(58.78f, z.Set<float>(58.78f).Get<float>());
695
+ }
696
+
697
+ TEST(Value, IsLosslessDouble) {
698
+ EXPECT_TRUE(Value(0.0).IsLosslessDouble());
699
+ EXPECT_TRUE(Value(12.34).IsLosslessDouble());
700
+ EXPECT_TRUE(Value(-123).IsLosslessDouble());
701
+ EXPECT_TRUE(Value(2147483648u).IsLosslessDouble());
702
+ EXPECT_TRUE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x40000000, 0x00000000))).IsLosslessDouble());
703
+ #if !(defined(_MSC_VER) && _MSC_VER < 1800) // VC2010 has problem
704
+ EXPECT_TRUE(Value(RAPIDJSON_UINT64_C2(0xA0000000, 0x00000000)).IsLosslessDouble());
705
+ #endif
706
+
707
+ EXPECT_FALSE(Value(static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF))).IsLosslessDouble()); // INT64_MAX
708
+ EXPECT_FALSE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF))).IsLosslessDouble()); // -INT64_MAX
709
+ EXPECT_TRUE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF)) - 1).IsLosslessDouble()); // INT64_MIN
710
+ EXPECT_FALSE(Value(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF)).IsLosslessDouble()); // UINT64_MAX
711
+
712
+ EXPECT_TRUE(Value(3.4028234e38f).IsLosslessDouble()); // FLT_MAX
713
+ EXPECT_TRUE(Value(-3.4028234e38f).IsLosslessDouble()); // -FLT_MAX
714
+ EXPECT_TRUE(Value(1.17549435e-38f).IsLosslessDouble()); // FLT_MIN
715
+ EXPECT_TRUE(Value(-1.17549435e-38f).IsLosslessDouble()); // -FLT_MIN
716
+ EXPECT_TRUE(Value(1.7976931348623157e+308).IsLosslessDouble()); // DBL_MAX
717
+ EXPECT_TRUE(Value(-1.7976931348623157e+308).IsLosslessDouble()); // -DBL_MAX
718
+ EXPECT_TRUE(Value(2.2250738585072014e-308).IsLosslessDouble()); // DBL_MIN
719
+ EXPECT_TRUE(Value(-2.2250738585072014e-308).IsLosslessDouble()); // -DBL_MIN
720
+ }
721
+
722
+ TEST(Value, IsLosslessFloat) {
723
+ EXPECT_TRUE(Value(12.25).IsLosslessFloat());
724
+ EXPECT_TRUE(Value(-123).IsLosslessFloat());
725
+ EXPECT_TRUE(Value(2147483648u).IsLosslessFloat());
726
+ EXPECT_TRUE(Value(3.4028234e38f).IsLosslessFloat());
727
+ EXPECT_TRUE(Value(-3.4028234e38f).IsLosslessFloat());
728
+ EXPECT_FALSE(Value(3.4028235e38).IsLosslessFloat());
729
+ EXPECT_FALSE(Value(0.3).IsLosslessFloat());
730
+ }
731
+
732
+ TEST(Value, String) {
733
+ // Construction with const string
734
+ Value x("Hello", 5); // literal
735
+ EXPECT_EQ(kStringType, x.GetType());
736
+ EXPECT_TRUE(x.IsString());
737
+ EXPECT_STREQ("Hello", x.GetString());
738
+ EXPECT_EQ(5u, x.GetStringLength());
739
+
740
+ EXPECT_FALSE(x.IsNumber());
741
+ EXPECT_FALSE(x.IsNull());
742
+ EXPECT_FALSE(x.IsBool());
743
+ EXPECT_FALSE(x.IsFalse());
744
+ EXPECT_FALSE(x.IsTrue());
745
+ EXPECT_FALSE(x.IsObject());
746
+ EXPECT_FALSE(x.IsArray());
747
+
748
+ static const char cstr[] = "World"; // const array
749
+ Value(cstr).Swap(x);
750
+ EXPECT_TRUE(x.IsString());
751
+ EXPECT_EQ(x.GetString(), cstr);
752
+ EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1);
753
+
754
+ static char mstr[] = "Howdy"; // non-const array
755
+ // Value(mstr).Swap(x); // should not compile
756
+ Value(StringRef(mstr)).Swap(x);
757
+ EXPECT_TRUE(x.IsString());
758
+ EXPECT_EQ(x.GetString(), mstr);
759
+ EXPECT_EQ(x.GetStringLength(), sizeof(mstr)-1);
760
+ strncpy(mstr,"Hello", sizeof(mstr));
761
+ EXPECT_STREQ(x.GetString(), "Hello");
762
+
763
+ const char* pstr = cstr;
764
+ //Value(pstr).Swap(x); // should not compile
765
+ Value(StringRef(pstr)).Swap(x);
766
+ EXPECT_TRUE(x.IsString());
767
+ EXPECT_EQ(x.GetString(), cstr);
768
+ EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1);
769
+
770
+ char* mpstr = mstr;
771
+ Value(StringRef(mpstr,sizeof(mstr)-1)).Swap(x);
772
+ EXPECT_TRUE(x.IsString());
773
+ EXPECT_EQ(x.GetString(), mstr);
774
+ EXPECT_EQ(x.GetStringLength(), 5u);
775
+ EXPECT_STREQ(x.GetString(), "Hello");
776
+
777
+ // Constructor with copy string
778
+ MemoryPoolAllocator<> allocator;
779
+ Value c(x.GetString(), x.GetStringLength(), allocator);
780
+ EXPECT_NE(x.GetString(), c.GetString());
781
+ EXPECT_EQ(x.GetStringLength(), c.GetStringLength());
782
+ EXPECT_STREQ(x.GetString(), c.GetString());
783
+ //x.SetString("World");
784
+ x.SetString("World", 5);
785
+ EXPECT_STREQ("Hello", c.GetString());
786
+ EXPECT_EQ(5u, c.GetStringLength());
787
+
788
+ // Constructor with type
789
+ Value y(kStringType);
790
+ EXPECT_TRUE(y.IsString());
791
+ EXPECT_STREQ("", y.GetString()); // Empty string should be "" instead of 0 (issue 226)
792
+ EXPECT_EQ(0u, y.GetStringLength());
793
+
794
+ // SetConsttring()
795
+ Value z;
796
+ z.SetString("Hello");
797
+ EXPECT_TRUE(x.IsString());
798
+ z.SetString("Hello", 5);
799
+ EXPECT_STREQ("Hello", z.GetString());
800
+ EXPECT_STREQ("Hello", z.GetString());
801
+ EXPECT_EQ(5u, z.GetStringLength());
802
+
803
+ z.SetString("Hello");
804
+ EXPECT_TRUE(z.IsString());
805
+ EXPECT_STREQ("Hello", z.GetString());
806
+
807
+ //z.SetString(mstr); // should not compile
808
+ //z.SetString(pstr); // should not compile
809
+ z.SetString(StringRef(mstr));
810
+ EXPECT_TRUE(z.IsString());
811
+ EXPECT_STREQ(z.GetString(), mstr);
812
+
813
+ z.SetString(cstr);
814
+ EXPECT_TRUE(z.IsString());
815
+ EXPECT_EQ(cstr, z.GetString());
816
+
817
+ z = cstr;
818
+ EXPECT_TRUE(z.IsString());
819
+ EXPECT_EQ(cstr, z.GetString());
820
+
821
+ // SetString()
822
+ char s[] = "World";
823
+ Value w;
824
+ w.SetString(s, static_cast<SizeType>(strlen(s)), allocator);
825
+ s[0] = '\0';
826
+ EXPECT_STREQ("World", w.GetString());
827
+ EXPECT_EQ(5u, w.GetStringLength());
828
+
829
+ // templated functions
830
+ EXPECT_TRUE(z.Is<const char*>());
831
+ EXPECT_STREQ(cstr, z.Get<const char*>());
832
+ EXPECT_STREQ("Apple", z.Set<const char*>("Apple").Get<const char*>());
833
+
834
+ #if RAPIDJSON_HAS_STDSTRING
835
+ {
836
+ std::string str = "Hello World";
837
+ str[5] = '\0';
838
+ EXPECT_STREQ(str.data(),"Hello"); // embedded '\0'
839
+ EXPECT_EQ(str.size(), 11u);
840
+
841
+ // no copy
842
+ Value vs0(StringRef(str));
843
+ EXPECT_TRUE(vs0.IsString());
844
+ EXPECT_EQ(vs0.GetString(), str.data());
845
+ EXPECT_EQ(vs0.GetStringLength(), str.size());
846
+ TestEqual(vs0, str);
847
+
848
+ // do copy
849
+ Value vs1(str, allocator);
850
+ EXPECT_TRUE(vs1.IsString());
851
+ EXPECT_NE(vs1.GetString(), str.data());
852
+ EXPECT_NE(vs1.GetString(), str); // not equal due to embedded '\0'
853
+ EXPECT_EQ(vs1.GetStringLength(), str.size());
854
+ TestEqual(vs1, str);
855
+
856
+ // SetString
857
+ str = "World";
858
+ vs0.SetNull().SetString(str, allocator);
859
+ EXPECT_TRUE(vs0.IsString());
860
+ EXPECT_STREQ(vs0.GetString(), str.c_str());
861
+ EXPECT_EQ(vs0.GetStringLength(), str.size());
862
+ TestEqual(str, vs0);
863
+ TestUnequal(str, vs1);
864
+
865
+ // vs1 = str; // should not compile
866
+ vs1 = StringRef(str);
867
+ TestEqual(str, vs1);
868
+ TestEqual(vs0, vs1);
869
+
870
+ // Templated function.
871
+ EXPECT_TRUE(vs0.Is<std::string>());
872
+ EXPECT_EQ(str, vs0.Get<std::string>());
873
+ vs0.Set<std::string>(std::string("Apple"), allocator);
874
+ EXPECT_EQ(std::string("Apple"), vs0.Get<std::string>());
875
+ vs0.Set(std::string("Orange"), allocator);
876
+ EXPECT_EQ(std::string("Orange"), vs0.Get<std::string>());
877
+ }
878
+ #endif // RAPIDJSON_HAS_STDSTRING
879
+ }
880
+
881
+ // Issue 226: Value of string type should not point to NULL
882
+ TEST(Value, SetStringNull) {
883
+
884
+ MemoryPoolAllocator<> allocator;
885
+ const char* nullPtr = 0;
886
+ {
887
+ // Construction with string type creates empty string
888
+ Value v(kStringType);
889
+ EXPECT_NE(v.GetString(), nullPtr); // non-null string returned
890
+ EXPECT_EQ(v.GetStringLength(), 0u);
891
+
892
+ // Construction from/setting to null without length not allowed
893
+ EXPECT_THROW(Value(StringRef(nullPtr)), AssertException);
894
+ EXPECT_THROW(Value(StringRef(nullPtr), allocator), AssertException);
895
+ EXPECT_THROW(v.SetString(nullPtr, allocator), AssertException);
896
+
897
+ // Non-empty length with null string is not allowed
898
+ EXPECT_THROW(v.SetString(nullPtr, 17u), AssertException);
899
+ EXPECT_THROW(v.SetString(nullPtr, 42u, allocator), AssertException);
900
+
901
+ // Setting to null string with empty length is allowed
902
+ v.SetString(nullPtr, 0u);
903
+ EXPECT_NE(v.GetString(), nullPtr); // non-null string returned
904
+ EXPECT_EQ(v.GetStringLength(), 0u);
905
+
906
+ v.SetNull();
907
+ v.SetString(nullPtr, 0u, allocator);
908
+ EXPECT_NE(v.GetString(), nullPtr); // non-null string returned
909
+ EXPECT_EQ(v.GetStringLength(), 0u);
910
+ }
911
+ // Construction with null string and empty length is allowed
912
+ {
913
+ Value v(nullPtr,0u);
914
+ EXPECT_NE(v.GetString(), nullPtr); // non-null string returned
915
+ EXPECT_EQ(v.GetStringLength(), 0u);
916
+ }
917
+ {
918
+ Value v(nullPtr, 0u, allocator);
919
+ EXPECT_NE(v.GetString(), nullPtr); // non-null string returned
920
+ EXPECT_EQ(v.GetStringLength(), 0u);
921
+ }
922
+ }
923
+
924
+ template <typename T, typename Allocator>
925
+ static void TestArray(T& x, Allocator& allocator) {
926
+ const T& y = x;
927
+
928
+ // PushBack()
929
+ Value v;
930
+ x.PushBack(v, allocator);
931
+ v.SetBool(true);
932
+ x.PushBack(v, allocator);
933
+ v.SetBool(false);
934
+ x.PushBack(v, allocator);
935
+ v.SetInt(123);
936
+ x.PushBack(v, allocator);
937
+ //x.PushBack((const char*)"foo", allocator); // should not compile
938
+ x.PushBack("foo", allocator);
939
+
940
+ EXPECT_FALSE(x.Empty());
941
+ EXPECT_EQ(5u, x.Size());
942
+ EXPECT_FALSE(y.Empty());
943
+ EXPECT_EQ(5u, y.Size());
944
+ EXPECT_TRUE(x[SizeType(0)].IsNull());
945
+ EXPECT_TRUE(x[1].IsTrue());
946
+ EXPECT_TRUE(x[2].IsFalse());
947
+ EXPECT_TRUE(x[3].IsInt());
948
+ EXPECT_EQ(123, x[3].GetInt());
949
+ EXPECT_TRUE(y[SizeType(0)].IsNull());
950
+ EXPECT_TRUE(y[1].IsTrue());
951
+ EXPECT_TRUE(y[2].IsFalse());
952
+ EXPECT_TRUE(y[3].IsInt());
953
+ EXPECT_EQ(123, y[3].GetInt());
954
+ EXPECT_TRUE(y[4].IsString());
955
+ EXPECT_STREQ("foo", y[4].GetString());
956
+
957
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
958
+ // PushBack(GenericValue&&, Allocator&);
959
+ {
960
+ Value y2(kArrayType);
961
+ y2.PushBack(Value(true), allocator);
962
+ y2.PushBack(std::move(Value(kArrayType).PushBack(Value(1), allocator).PushBack("foo", allocator)), allocator);
963
+ EXPECT_EQ(2u, y2.Size());
964
+ EXPECT_TRUE(y2[0].IsTrue());
965
+ EXPECT_TRUE(y2[1].IsArray());
966
+ EXPECT_EQ(2u, y2[1].Size());
967
+ EXPECT_TRUE(y2[1][0].IsInt());
968
+ EXPECT_TRUE(y2[1][1].IsString());
969
+ }
970
+ #endif
971
+
972
+ // iterator
973
+ typename T::ValueIterator itr = x.Begin();
974
+ EXPECT_TRUE(itr != x.End());
975
+ EXPECT_TRUE(itr->IsNull());
976
+ ++itr;
977
+ EXPECT_TRUE(itr != x.End());
978
+ EXPECT_TRUE(itr->IsTrue());
979
+ ++itr;
980
+ EXPECT_TRUE(itr != x.End());
981
+ EXPECT_TRUE(itr->IsFalse());
982
+ ++itr;
983
+ EXPECT_TRUE(itr != x.End());
984
+ EXPECT_TRUE(itr->IsInt());
985
+ EXPECT_EQ(123, itr->GetInt());
986
+ ++itr;
987
+ EXPECT_TRUE(itr != x.End());
988
+ EXPECT_TRUE(itr->IsString());
989
+ EXPECT_STREQ("foo", itr->GetString());
990
+
991
+ // const iterator
992
+ typename T::ConstValueIterator citr = y.Begin();
993
+ EXPECT_TRUE(citr != y.End());
994
+ EXPECT_TRUE(citr->IsNull());
995
+ ++citr;
996
+ EXPECT_TRUE(citr != y.End());
997
+ EXPECT_TRUE(citr->IsTrue());
998
+ ++citr;
999
+ EXPECT_TRUE(citr != y.End());
1000
+ EXPECT_TRUE(citr->IsFalse());
1001
+ ++citr;
1002
+ EXPECT_TRUE(citr != y.End());
1003
+ EXPECT_TRUE(citr->IsInt());
1004
+ EXPECT_EQ(123, citr->GetInt());
1005
+ ++citr;
1006
+ EXPECT_TRUE(citr != y.End());
1007
+ EXPECT_TRUE(citr->IsString());
1008
+ EXPECT_STREQ("foo", citr->GetString());
1009
+
1010
+ // PopBack()
1011
+ x.PopBack();
1012
+ EXPECT_EQ(4u, x.Size());
1013
+ EXPECT_TRUE(y[SizeType(0)].IsNull());
1014
+ EXPECT_TRUE(y[1].IsTrue());
1015
+ EXPECT_TRUE(y[2].IsFalse());
1016
+ EXPECT_TRUE(y[3].IsInt());
1017
+
1018
+ // Clear()
1019
+ x.Clear();
1020
+ EXPECT_TRUE(x.Empty());
1021
+ EXPECT_EQ(0u, x.Size());
1022
+ EXPECT_TRUE(y.Empty());
1023
+ EXPECT_EQ(0u, y.Size());
1024
+
1025
+ // Erase(ValueIterator)
1026
+
1027
+ // Use array of array to ensure removed elements' destructor is called.
1028
+ // [[0],[1],[2],...]
1029
+ for (int i = 0; i < 10; i++)
1030
+ x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);
1031
+
1032
+ // Erase the first
1033
+ itr = x.Erase(x.Begin());
1034
+ EXPECT_EQ(x.Begin(), itr);
1035
+ EXPECT_EQ(9u, x.Size());
1036
+ for (int i = 0; i < 9; i++)
1037
+ EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());
1038
+
1039
+ // Ease the last
1040
+ itr = x.Erase(x.End() - 1);
1041
+ EXPECT_EQ(x.End(), itr);
1042
+ EXPECT_EQ(8u, x.Size());
1043
+ for (int i = 0; i < 8; i++)
1044
+ EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());
1045
+
1046
+ // Erase the middle
1047
+ itr = x.Erase(x.Begin() + 4);
1048
+ EXPECT_EQ(x.Begin() + 4, itr);
1049
+ EXPECT_EQ(7u, x.Size());
1050
+ for (int i = 0; i < 4; i++)
1051
+ EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());
1052
+ for (int i = 4; i < 7; i++)
1053
+ EXPECT_EQ(i + 2, x[static_cast<SizeType>(i)][0].GetInt());
1054
+
1055
+ // Erase(ValueIterator, ValueIterator)
1056
+ // Exhaustive test with all 0 <= first < n, first <= last <= n cases
1057
+ const unsigned n = 10;
1058
+ for (unsigned first = 0; first < n; first++) {
1059
+ for (unsigned last = first; last <= n; last++) {
1060
+ x.Clear();
1061
+ for (unsigned i = 0; i < n; i++)
1062
+ x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);
1063
+
1064
+ itr = x.Erase(x.Begin() + first, x.Begin() + last);
1065
+ if (last == n)
1066
+ EXPECT_EQ(x.End(), itr);
1067
+ else
1068
+ EXPECT_EQ(x.Begin() + first, itr);
1069
+
1070
+ size_t removeCount = last - first;
1071
+ EXPECT_EQ(n - removeCount, x.Size());
1072
+ for (unsigned i = 0; i < first; i++)
1073
+ EXPECT_EQ(i, x[i][0].GetUint());
1074
+ for (unsigned i = first; i < n - removeCount; i++)
1075
+ EXPECT_EQ(i + removeCount, x[static_cast<SizeType>(i)][0].GetUint());
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ TEST(Value, Array) {
1081
+ Value x(kArrayType);
1082
+ const Value& y = x;
1083
+ Value::AllocatorType allocator;
1084
+
1085
+ EXPECT_EQ(kArrayType, x.GetType());
1086
+ EXPECT_TRUE(x.IsArray());
1087
+ EXPECT_TRUE(x.Empty());
1088
+ EXPECT_EQ(0u, x.Size());
1089
+ EXPECT_TRUE(y.IsArray());
1090
+ EXPECT_TRUE(y.Empty());
1091
+ EXPECT_EQ(0u, y.Size());
1092
+
1093
+ EXPECT_FALSE(x.IsNull());
1094
+ EXPECT_FALSE(x.IsBool());
1095
+ EXPECT_FALSE(x.IsFalse());
1096
+ EXPECT_FALSE(x.IsTrue());
1097
+ EXPECT_FALSE(x.IsString());
1098
+ EXPECT_FALSE(x.IsObject());
1099
+
1100
+ TestArray(x, allocator);
1101
+
1102
+ // Working in gcc without C++11, but VS2013 cannot compile. To be diagnosed.
1103
+ // http://en.wikipedia.org/wiki/Erase-remove_idiom
1104
+ x.Clear();
1105
+ for (int i = 0; i < 10; i++)
1106
+ if (i % 2 == 0)
1107
+ x.PushBack(i, allocator);
1108
+ else
1109
+ x.PushBack(Value(kNullType).Move(), allocator);
1110
+
1111
+ const Value null(kNullType);
1112
+ x.Erase(std::remove(x.Begin(), x.End(), null), x.End());
1113
+ EXPECT_EQ(5u, x.Size());
1114
+ for (int i = 0; i < 5; i++)
1115
+ EXPECT_EQ(i * 2, x[static_cast<SizeType>(i)]);
1116
+
1117
+ // SetArray()
1118
+ Value z;
1119
+ z.SetArray();
1120
+ EXPECT_TRUE(z.IsArray());
1121
+ EXPECT_TRUE(z.Empty());
1122
+ }
1123
+
1124
+ TEST(Value, ArrayHelper) {
1125
+ Value::AllocatorType allocator;
1126
+ {
1127
+ Value x(kArrayType);
1128
+ Value::Array a = x.GetArray();
1129
+ TestArray(a, allocator);
1130
+ }
1131
+
1132
+ {
1133
+ Value x(kArrayType);
1134
+ Value::Array a = x.GetArray();
1135
+ a.PushBack(1, allocator);
1136
+
1137
+ Value::Array a2(a); // copy constructor
1138
+ EXPECT_EQ(1u, a2.Size());
1139
+
1140
+ Value::Array a3 = a;
1141
+ EXPECT_EQ(1u, a3.Size());
1142
+
1143
+ Value::ConstArray y = static_cast<const Value&>(x).GetArray();
1144
+ (void)y;
1145
+ // y.PushBack(1, allocator); // should not compile
1146
+
1147
+ // Templated functions
1148
+ x.Clear();
1149
+ EXPECT_TRUE(x.Is<Value::Array>());
1150
+ EXPECT_TRUE(x.Is<Value::ConstArray>());
1151
+ a.PushBack(1, allocator);
1152
+ EXPECT_EQ(1, x.Get<Value::Array>()[0].GetInt());
1153
+ EXPECT_EQ(1, x.Get<Value::ConstArray>()[0].GetInt());
1154
+
1155
+ Value x2;
1156
+ x2.Set<Value::Array>(a);
1157
+ EXPECT_TRUE(x.IsArray()); // IsArray() is invariant after moving.
1158
+ EXPECT_EQ(1, x2.Get<Value::Array>()[0].GetInt());
1159
+ }
1160
+
1161
+ {
1162
+ Value y(kArrayType);
1163
+ y.PushBack(123, allocator);
1164
+
1165
+ Value x(y.GetArray()); // Construct value form array.
1166
+ EXPECT_TRUE(x.IsArray());
1167
+ EXPECT_EQ(123, x[0].GetInt());
1168
+ EXPECT_TRUE(y.IsArray()); // Invariant
1169
+ EXPECT_TRUE(y.Empty());
1170
+ }
1171
+
1172
+ {
1173
+ Value x(kArrayType);
1174
+ Value y(kArrayType);
1175
+ y.PushBack(123, allocator);
1176
+ x.PushBack(y.GetArray(), allocator); // Implicit constructor to convert Array to GenericValue
1177
+
1178
+ EXPECT_EQ(1u, x.Size());
1179
+ EXPECT_EQ(123, x[0][0].GetInt());
1180
+ EXPECT_TRUE(y.IsArray());
1181
+ EXPECT_TRUE(y.Empty());
1182
+ }
1183
+ }
1184
+
1185
+ #if RAPIDJSON_HAS_CXX11_RANGE_FOR
1186
+ TEST(Value, ArrayHelperRangeFor) {
1187
+ Value::AllocatorType allocator;
1188
+ Value x(kArrayType);
1189
+
1190
+ for (int i = 0; i < 10; i++)
1191
+ x.PushBack(i, allocator);
1192
+
1193
+ {
1194
+ int i = 0;
1195
+ for (auto& v : x.GetArray()) {
1196
+ EXPECT_EQ(i, v.GetInt());
1197
+ i++;
1198
+ }
1199
+ EXPECT_EQ(i, 10);
1200
+ }
1201
+ {
1202
+ int i = 0;
1203
+ for (const auto& v : const_cast<const Value&>(x).GetArray()) {
1204
+ EXPECT_EQ(i, v.GetInt());
1205
+ i++;
1206
+ }
1207
+ EXPECT_EQ(i, 10);
1208
+ }
1209
+
1210
+ // Array a = x.GetArray();
1211
+ // Array ca = const_cast<const Value&>(x).GetArray();
1212
+ }
1213
+ #endif
1214
+
1215
+ template <typename T, typename Allocator>
1216
+ static void TestObject(T& x, Allocator& allocator) {
1217
+ const T& y = x; // const version
1218
+
1219
+ // AddMember()
1220
+ x.AddMember("A", "Apple", allocator);
1221
+ EXPECT_FALSE(x.ObjectEmpty());
1222
+ EXPECT_EQ(1u, x.MemberCount());
1223
+
1224
+ Value value("Banana", 6);
1225
+ x.AddMember("B", "Banana", allocator);
1226
+ EXPECT_EQ(2u, x.MemberCount());
1227
+
1228
+ // AddMember<T>(StringRefType, T, Allocator)
1229
+ {
1230
+ Value o(kObjectType);
1231
+ o.AddMember("true", true, allocator);
1232
+ o.AddMember("false", false, allocator);
1233
+ o.AddMember("int", -1, allocator);
1234
+ o.AddMember("uint", 1u, allocator);
1235
+ o.AddMember("int64", int64_t(-4294967296), allocator);
1236
+ o.AddMember("uint64", uint64_t(4294967296), allocator);
1237
+ o.AddMember("double", 3.14, allocator);
1238
+ o.AddMember("string", "Jelly", allocator);
1239
+
1240
+ EXPECT_TRUE(o["true"].GetBool());
1241
+ EXPECT_FALSE(o["false"].GetBool());
1242
+ EXPECT_EQ(-1, o["int"].GetInt());
1243
+ EXPECT_EQ(1u, o["uint"].GetUint());
1244
+ EXPECT_EQ(int64_t(-4294967296), o["int64"].GetInt64());
1245
+ EXPECT_EQ(uint64_t(4294967296), o["uint64"].GetUint64());
1246
+ EXPECT_STREQ("Jelly",o["string"].GetString());
1247
+ EXPECT_EQ(8u, o.MemberCount());
1248
+ }
1249
+
1250
+ // AddMember<T>(Value&, T, Allocator)
1251
+ {
1252
+ Value o(kObjectType);
1253
+
1254
+ Value n("s");
1255
+ o.AddMember(n, "string", allocator);
1256
+ EXPECT_EQ(1u, o.MemberCount());
1257
+
1258
+ Value count("#");
1259
+ o.AddMember(count, o.MemberCount(), allocator);
1260
+ EXPECT_EQ(2u, o.MemberCount());
1261
+ }
1262
+
1263
+ #if RAPIDJSON_HAS_STDSTRING
1264
+ {
1265
+ // AddMember(StringRefType, const std::string&, Allocator)
1266
+ Value o(kObjectType);
1267
+ o.AddMember("b", std::string("Banana"), allocator);
1268
+ EXPECT_STREQ("Banana", o["b"].GetString());
1269
+
1270
+ // RemoveMember(const std::string&)
1271
+ o.RemoveMember(std::string("b"));
1272
+ EXPECT_TRUE(o.ObjectEmpty());
1273
+ }
1274
+ #endif
1275
+
1276
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1277
+ // AddMember(GenericValue&&, ...) variants
1278
+ {
1279
+ Value o(kObjectType);
1280
+ o.AddMember(Value("true"), Value(true), allocator);
1281
+ o.AddMember(Value("false"), Value(false).Move(), allocator); // value is lvalue ref
1282
+ o.AddMember(Value("int").Move(), Value(-1), allocator); // name is lvalue ref
1283
+ o.AddMember("uint", std::move(Value().SetUint(1u)), allocator); // name is literal, value is rvalue
1284
+ EXPECT_TRUE(o["true"].GetBool());
1285
+ EXPECT_FALSE(o["false"].GetBool());
1286
+ EXPECT_EQ(-1, o["int"].GetInt());
1287
+ EXPECT_EQ(1u, o["uint"].GetUint());
1288
+ EXPECT_EQ(4u, o.MemberCount());
1289
+ }
1290
+ #endif
1291
+
1292
+ // Tests a member with null character
1293
+ Value name;
1294
+ const Value C0D("C\0D", 3);
1295
+ name.SetString(C0D.GetString(), 3);
1296
+ value.SetString("CherryD", 7);
1297
+ x.AddMember(name, value, allocator);
1298
+
1299
+ // HasMember()
1300
+ EXPECT_TRUE(x.HasMember("A"));
1301
+ EXPECT_TRUE(x.HasMember("B"));
1302
+ EXPECT_TRUE(y.HasMember("A"));
1303
+ EXPECT_TRUE(y.HasMember("B"));
1304
+
1305
+ #if RAPIDJSON_HAS_STDSTRING
1306
+ EXPECT_TRUE(x.HasMember(std::string("A")));
1307
+ #endif
1308
+
1309
+ name.SetString("C\0D");
1310
+ EXPECT_TRUE(x.HasMember(name));
1311
+ EXPECT_TRUE(y.HasMember(name));
1312
+
1313
+ GenericValue<UTF8<>, CrtAllocator> othername("A");
1314
+ EXPECT_TRUE(x.HasMember(othername));
1315
+ EXPECT_TRUE(y.HasMember(othername));
1316
+ othername.SetString("C\0D");
1317
+ EXPECT_TRUE(x.HasMember(othername));
1318
+ EXPECT_TRUE(y.HasMember(othername));
1319
+
1320
+ // operator[]
1321
+ EXPECT_STREQ("Apple", x["A"].GetString());
1322
+ EXPECT_STREQ("Banana", x["B"].GetString());
1323
+ EXPECT_STREQ("CherryD", x[C0D].GetString());
1324
+ EXPECT_STREQ("CherryD", x[othername].GetString());
1325
+ EXPECT_THROW(x["nonexist"], AssertException);
1326
+
1327
+ // const operator[]
1328
+ EXPECT_STREQ("Apple", y["A"].GetString());
1329
+ EXPECT_STREQ("Banana", y["B"].GetString());
1330
+ EXPECT_STREQ("CherryD", y[C0D].GetString());
1331
+
1332
+ #if RAPIDJSON_HAS_STDSTRING
1333
+ EXPECT_STREQ("Apple", x["A"].GetString());
1334
+ EXPECT_STREQ("Apple", y[std::string("A")].GetString());
1335
+ #endif
1336
+
1337
+ // member iterator
1338
+ Value::MemberIterator itr = x.MemberBegin();
1339
+ EXPECT_TRUE(itr != x.MemberEnd());
1340
+ EXPECT_STREQ("A", itr->name.GetString());
1341
+ EXPECT_STREQ("Apple", itr->value.GetString());
1342
+ ++itr;
1343
+ EXPECT_TRUE(itr != x.MemberEnd());
1344
+ EXPECT_STREQ("B", itr->name.GetString());
1345
+ EXPECT_STREQ("Banana", itr->value.GetString());
1346
+ ++itr;
1347
+ EXPECT_TRUE(itr != x.MemberEnd());
1348
+ EXPECT_TRUE(memcmp(itr->name.GetString(), "C\0D", 4) == 0);
1349
+ EXPECT_STREQ("CherryD", itr->value.GetString());
1350
+ ++itr;
1351
+ EXPECT_FALSE(itr != x.MemberEnd());
1352
+
1353
+ // const member iterator
1354
+ Value::ConstMemberIterator citr = y.MemberBegin();
1355
+ EXPECT_TRUE(citr != y.MemberEnd());
1356
+ EXPECT_STREQ("A", citr->name.GetString());
1357
+ EXPECT_STREQ("Apple", citr->value.GetString());
1358
+ ++citr;
1359
+ EXPECT_TRUE(citr != y.MemberEnd());
1360
+ EXPECT_STREQ("B", citr->name.GetString());
1361
+ EXPECT_STREQ("Banana", citr->value.GetString());
1362
+ ++citr;
1363
+ EXPECT_TRUE(citr != y.MemberEnd());
1364
+ EXPECT_TRUE(memcmp(citr->name.GetString(), "C\0D", 4) == 0);
1365
+ EXPECT_STREQ("CherryD", citr->value.GetString());
1366
+ ++citr;
1367
+ EXPECT_FALSE(citr != y.MemberEnd());
1368
+
1369
+ // member iterator conversions/relations
1370
+ itr = x.MemberBegin();
1371
+ citr = x.MemberBegin(); // const conversion
1372
+ TestEqual(itr, citr);
1373
+ EXPECT_TRUE(itr < x.MemberEnd());
1374
+ EXPECT_FALSE(itr > y.MemberEnd());
1375
+ EXPECT_TRUE(citr < x.MemberEnd());
1376
+ EXPECT_FALSE(citr > y.MemberEnd());
1377
+ ++citr;
1378
+ TestUnequal(itr, citr);
1379
+ EXPECT_FALSE(itr < itr);
1380
+ EXPECT_TRUE(itr < citr);
1381
+ EXPECT_FALSE(itr > itr);
1382
+ EXPECT_TRUE(citr > itr);
1383
+ EXPECT_EQ(1, citr - x.MemberBegin());
1384
+ EXPECT_EQ(0, itr - y.MemberBegin());
1385
+ itr += citr - x.MemberBegin();
1386
+ EXPECT_EQ(1, itr - y.MemberBegin());
1387
+ TestEqual(citr, itr);
1388
+ EXPECT_TRUE(itr <= citr);
1389
+ EXPECT_TRUE(citr <= itr);
1390
+ itr++;
1391
+ EXPECT_TRUE(itr >= citr);
1392
+ EXPECT_FALSE(citr >= itr);
1393
+
1394
+ // RemoveMember()
1395
+ EXPECT_TRUE(x.RemoveMember("A"));
1396
+ EXPECT_FALSE(x.HasMember("A"));
1397
+
1398
+ EXPECT_TRUE(x.RemoveMember("B"));
1399
+ EXPECT_FALSE(x.HasMember("B"));
1400
+
1401
+ EXPECT_FALSE(x.RemoveMember("nonexist"));
1402
+
1403
+ EXPECT_TRUE(x.RemoveMember(othername));
1404
+ EXPECT_FALSE(x.HasMember(name));
1405
+
1406
+ EXPECT_TRUE(x.MemberBegin() == x.MemberEnd());
1407
+
1408
+ // EraseMember(ConstMemberIterator)
1409
+
1410
+ // Use array members to ensure removed elements' destructor is called.
1411
+ // { "a": [0], "b": [1],[2],...]
1412
+ const char keys[][2] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
1413
+ for (int i = 0; i < 10; i++)
1414
+ x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);
1415
+
1416
+ // MemberCount, iterator difference
1417
+ EXPECT_EQ(x.MemberCount(), SizeType(x.MemberEnd() - x.MemberBegin()));
1418
+
1419
+ // Erase the first
1420
+ itr = x.EraseMember(x.MemberBegin());
1421
+ EXPECT_FALSE(x.HasMember(keys[0]));
1422
+ EXPECT_EQ(x.MemberBegin(), itr);
1423
+ EXPECT_EQ(9u, x.MemberCount());
1424
+ for (; itr != x.MemberEnd(); ++itr) {
1425
+ size_t i = static_cast<size_t>((itr - x.MemberBegin())) + 1;
1426
+ EXPECT_STREQ(itr->name.GetString(), keys[i]);
1427
+ EXPECT_EQ(static_cast<int>(i), itr->value[0].GetInt());
1428
+ }
1429
+
1430
+ // Erase the last
1431
+ itr = x.EraseMember(x.MemberEnd() - 1);
1432
+ EXPECT_FALSE(x.HasMember(keys[9]));
1433
+ EXPECT_EQ(x.MemberEnd(), itr);
1434
+ EXPECT_EQ(8u, x.MemberCount());
1435
+ for (; itr != x.MemberEnd(); ++itr) {
1436
+ size_t i = static_cast<size_t>(itr - x.MemberBegin()) + 1;
1437
+ EXPECT_STREQ(itr->name.GetString(), keys[i]);
1438
+ EXPECT_EQ(static_cast<int>(i), itr->value[0].GetInt());
1439
+ }
1440
+
1441
+ // Erase the middle
1442
+ itr = x.EraseMember(x.MemberBegin() + 4);
1443
+ EXPECT_FALSE(x.HasMember(keys[5]));
1444
+ EXPECT_EQ(x.MemberBegin() + 4, itr);
1445
+ EXPECT_EQ(7u, x.MemberCount());
1446
+ for (; itr != x.MemberEnd(); ++itr) {
1447
+ size_t i = static_cast<size_t>(itr - x.MemberBegin());
1448
+ i += (i < 4) ? 1 : 2;
1449
+ EXPECT_STREQ(itr->name.GetString(), keys[i]);
1450
+ EXPECT_EQ(static_cast<int>(i), itr->value[0].GetInt());
1451
+ }
1452
+
1453
+ // EraseMember(ConstMemberIterator, ConstMemberIterator)
1454
+ // Exhaustive test with all 0 <= first < n, first <= last <= n cases
1455
+ const unsigned n = 10;
1456
+ for (unsigned first = 0; first < n; first++) {
1457
+ for (unsigned last = first; last <= n; last++) {
1458
+ x.RemoveAllMembers();
1459
+ for (unsigned i = 0; i < n; i++)
1460
+ x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);
1461
+
1462
+ itr = x.EraseMember(x.MemberBegin() + static_cast<int>(first), x.MemberBegin() + static_cast<int>(last));
1463
+ if (last == n)
1464
+ EXPECT_EQ(x.MemberEnd(), itr);
1465
+ else
1466
+ EXPECT_EQ(x.MemberBegin() + static_cast<int>(first), itr);
1467
+
1468
+ size_t removeCount = last - first;
1469
+ EXPECT_EQ(n - removeCount, x.MemberCount());
1470
+ for (unsigned i = 0; i < first; i++)
1471
+ EXPECT_EQ(i, x[keys[i]][0].GetUint());
1472
+ for (unsigned i = first; i < n - removeCount; i++)
1473
+ EXPECT_EQ(i + removeCount, x[keys[i+removeCount]][0].GetUint());
1474
+ }
1475
+ }
1476
+
1477
+ // RemoveAllMembers()
1478
+ x.RemoveAllMembers();
1479
+ EXPECT_TRUE(x.ObjectEmpty());
1480
+ EXPECT_EQ(0u, x.MemberCount());
1481
+ }
1482
+
1483
+ TEST(Value, Object) {
1484
+ Value x(kObjectType);
1485
+ const Value& y = x; // const version
1486
+ Value::AllocatorType allocator;
1487
+
1488
+ EXPECT_EQ(kObjectType, x.GetType());
1489
+ EXPECT_TRUE(x.IsObject());
1490
+ EXPECT_TRUE(x.ObjectEmpty());
1491
+ EXPECT_EQ(0u, x.MemberCount());
1492
+ EXPECT_EQ(kObjectType, y.GetType());
1493
+ EXPECT_TRUE(y.IsObject());
1494
+ EXPECT_TRUE(y.ObjectEmpty());
1495
+ EXPECT_EQ(0u, y.MemberCount());
1496
+
1497
+ TestObject(x, allocator);
1498
+
1499
+ // SetObject()
1500
+ Value z;
1501
+ z.SetObject();
1502
+ EXPECT_TRUE(z.IsObject());
1503
+ }
1504
+
1505
+ TEST(Value, ObjectHelper) {
1506
+ Value::AllocatorType allocator;
1507
+ {
1508
+ Value x(kObjectType);
1509
+ Value::Object o = x.GetObject();
1510
+ TestObject(o, allocator);
1511
+ }
1512
+
1513
+ {
1514
+ Value x(kObjectType);
1515
+ Value::Object o = x.GetObject();
1516
+ o.AddMember("1", 1, allocator);
1517
+
1518
+ Value::Object o2(o); // copy constructor
1519
+ EXPECT_EQ(1u, o2.MemberCount());
1520
+
1521
+ Value::Object o3 = o;
1522
+ EXPECT_EQ(1u, o3.MemberCount());
1523
+
1524
+ Value::ConstObject y = static_cast<const Value&>(x).GetObject();
1525
+ (void)y;
1526
+ // y.AddMember("1", 1, allocator); // should not compile
1527
+
1528
+ // Templated functions
1529
+ x.RemoveAllMembers();
1530
+ EXPECT_TRUE(x.Is<Value::Object>());
1531
+ EXPECT_TRUE(x.Is<Value::ConstObject>());
1532
+ o.AddMember("1", 1, allocator);
1533
+ EXPECT_EQ(1, x.Get<Value::Object>()["1"].GetInt());
1534
+ EXPECT_EQ(1, x.Get<Value::ConstObject>()["1"].GetInt());
1535
+
1536
+ Value x2;
1537
+ x2.Set<Value::Object>(o);
1538
+ EXPECT_TRUE(x.IsObject()); // IsObject() is invariant after moving
1539
+ EXPECT_EQ(1, x2.Get<Value::Object>()["1"].GetInt());
1540
+ }
1541
+
1542
+ {
1543
+ Value x(kObjectType);
1544
+ x.AddMember("a", "apple", allocator);
1545
+ Value y(x.GetObject());
1546
+ EXPECT_STREQ("apple", y["a"].GetString());
1547
+ EXPECT_TRUE(x.IsObject()); // Invariant
1548
+ }
1549
+
1550
+ {
1551
+ Value x(kObjectType);
1552
+ x.AddMember("a", "apple", allocator);
1553
+ Value y(kObjectType);
1554
+ y.AddMember("fruits", x.GetObject(), allocator);
1555
+ EXPECT_STREQ("apple", y["fruits"]["a"].GetString());
1556
+ EXPECT_TRUE(x.IsObject()); // Invariant
1557
+ }
1558
+ }
1559
+
1560
+ #if RAPIDJSON_HAS_CXX11_RANGE_FOR
1561
+ TEST(Value, ObjectHelperRangeFor) {
1562
+ Value::AllocatorType allocator;
1563
+ Value x(kObjectType);
1564
+
1565
+ for (int i = 0; i < 10; i++) {
1566
+ char name[10];
1567
+ Value n(name, static_cast<SizeType>(sprintf(name, "%d", i)), allocator);
1568
+ x.AddMember(n, i, allocator);
1569
+ }
1570
+
1571
+ {
1572
+ int i = 0;
1573
+ for (auto& m : x.GetObject()) {
1574
+ char name[10];
1575
+ sprintf(name, "%d", i);
1576
+ EXPECT_STREQ(name, m.name.GetString());
1577
+ EXPECT_EQ(i, m.value.GetInt());
1578
+ i++;
1579
+ }
1580
+ EXPECT_EQ(i, 10);
1581
+ }
1582
+ {
1583
+ int i = 0;
1584
+ for (const auto& m : const_cast<const Value&>(x).GetObject()) {
1585
+ char name[10];
1586
+ sprintf(name, "%d", i);
1587
+ EXPECT_STREQ(name, m.name.GetString());
1588
+ EXPECT_EQ(i, m.value.GetInt());
1589
+ i++;
1590
+ }
1591
+ EXPECT_EQ(i, 10);
1592
+ }
1593
+
1594
+ // Object a = x.GetObject();
1595
+ // Object ca = const_cast<const Value&>(x).GetObject();
1596
+ }
1597
+ #endif
1598
+
1599
+ TEST(Value, EraseMember_String) {
1600
+ Value::AllocatorType allocator;
1601
+ Value x(kObjectType);
1602
+ x.AddMember("A", "Apple", allocator);
1603
+ x.AddMember("B", "Banana", allocator);
1604
+
1605
+ EXPECT_TRUE(x.EraseMember("B"));
1606
+ EXPECT_FALSE(x.HasMember("B"));
1607
+
1608
+ EXPECT_FALSE(x.EraseMember("nonexist"));
1609
+
1610
+ GenericValue<UTF8<>, CrtAllocator> othername("A");
1611
+ EXPECT_TRUE(x.EraseMember(othername));
1612
+ EXPECT_FALSE(x.HasMember("A"));
1613
+
1614
+ EXPECT_TRUE(x.MemberBegin() == x.MemberEnd());
1615
+ }
1616
+
1617
+ TEST(Value, BigNestedArray) {
1618
+ MemoryPoolAllocator<> allocator;
1619
+ Value x(kArrayType);
1620
+ static const SizeType n = 200;
1621
+
1622
+ for (SizeType i = 0; i < n; i++) {
1623
+ Value y(kArrayType);
1624
+ for (SizeType j = 0; j < n; j++) {
1625
+ Value number(static_cast<int>(i * n + j));
1626
+ y.PushBack(number, allocator);
1627
+ }
1628
+ x.PushBack(y, allocator);
1629
+ }
1630
+
1631
+ for (SizeType i = 0; i < n; i++)
1632
+ for (SizeType j = 0; j < n; j++) {
1633
+ EXPECT_TRUE(x[i][j].IsInt());
1634
+ EXPECT_EQ(static_cast<int>(i * n + j), x[i][j].GetInt());
1635
+ }
1636
+ }
1637
+
1638
+ TEST(Value, BigNestedObject) {
1639
+ MemoryPoolAllocator<> allocator;
1640
+ Value x(kObjectType);
1641
+ static const SizeType n = 200;
1642
+
1643
+ for (SizeType i = 0; i < n; i++) {
1644
+ char name1[10];
1645
+ sprintf(name1, "%d", i);
1646
+
1647
+ // Value name(name1); // should not compile
1648
+ Value name(name1, static_cast<SizeType>(strlen(name1)), allocator);
1649
+ Value object(kObjectType);
1650
+
1651
+ for (SizeType j = 0; j < n; j++) {
1652
+ char name2[10];
1653
+ sprintf(name2, "%d", j);
1654
+
1655
+ Value name3(name2, static_cast<SizeType>(strlen(name2)), allocator);
1656
+ Value number(static_cast<int>(i * n + j));
1657
+ object.AddMember(name3, number, allocator);
1658
+ }
1659
+
1660
+ // x.AddMember(name1, object, allocator); // should not compile
1661
+ x.AddMember(name, object, allocator);
1662
+ }
1663
+
1664
+ for (SizeType i = 0; i < n; i++) {
1665
+ char name1[10];
1666
+ sprintf(name1, "%d", i);
1667
+
1668
+ for (SizeType j = 0; j < n; j++) {
1669
+ char name2[10];
1670
+ sprintf(name2, "%d", j);
1671
+ x[name1];
1672
+ EXPECT_EQ(static_cast<int>(i * n + j), x[name1][name2].GetInt());
1673
+ }
1674
+ }
1675
+ }
1676
+
1677
+ // Issue 18: Error removing last element of object
1678
+ // http://code.google.com/p/rapidjson/issues/detail?id=18
1679
+ TEST(Value, RemoveLastElement) {
1680
+ rapidjson::Document doc;
1681
+ rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();
1682
+ rapidjson::Value objVal(rapidjson::kObjectType);
1683
+ objVal.AddMember("var1", 123, allocator);
1684
+ objVal.AddMember("var2", "444", allocator);
1685
+ objVal.AddMember("var3", 555, allocator);
1686
+ EXPECT_TRUE(objVal.HasMember("var3"));
1687
+ objVal.RemoveMember("var3"); // Assertion here in r61
1688
+ EXPECT_FALSE(objVal.HasMember("var3"));
1689
+ }
1690
+
1691
+ // Issue 38: Segmentation fault with CrtAllocator
1692
+ TEST(Document, CrtAllocator) {
1693
+ typedef GenericValue<UTF8<>, CrtAllocator> V;
1694
+
1695
+ V::AllocatorType allocator;
1696
+ V o(kObjectType);
1697
+ o.AddMember("x", 1, allocator); // Should not call destructor on uninitialized name/value of newly allocated members.
1698
+
1699
+ V a(kArrayType);
1700
+ a.PushBack(1, allocator); // Should not call destructor on uninitialized Value of newly allocated elements.
1701
+ }
1702
+
1703
+ static void TestShortStringOptimization(const char* str) {
1704
+ const rapidjson::SizeType len = static_cast<rapidjson::SizeType>(strlen(str));
1705
+
1706
+ rapidjson::Document doc;
1707
+ rapidjson::Value val;
1708
+ val.SetString(str, len, doc.GetAllocator());
1709
+
1710
+ EXPECT_EQ(val.GetStringLength(), len);
1711
+ EXPECT_STREQ(val.GetString(), str);
1712
+ }
1713
+
1714
+ TEST(Value, AllocateShortString) {
1715
+ TestShortStringOptimization(""); // edge case: empty string
1716
+ TestShortStringOptimization("12345678"); // regular case for short strings: 8 chars
1717
+ TestShortStringOptimization("12345678901"); // edge case: 11 chars in 32-bit mode (=> short string)
1718
+ TestShortStringOptimization("123456789012"); // edge case: 12 chars in 32-bit mode (=> regular string)
1719
+ TestShortStringOptimization("123456789012345"); // edge case: 15 chars in 64-bit mode (=> short string)
1720
+ TestShortStringOptimization("1234567890123456"); // edge case: 16 chars in 64-bit mode (=> regular string)
1721
+ }
1722
+
1723
+ template <int e>
1724
+ struct TerminateHandler {
1725
+ bool Null() { return e != 0; }
1726
+ bool Bool(bool) { return e != 1; }
1727
+ bool Int(int) { return e != 2; }
1728
+ bool Uint(unsigned) { return e != 3; }
1729
+ bool Int64(int64_t) { return e != 4; }
1730
+ bool Uint64(uint64_t) { return e != 5; }
1731
+ bool Double(double) { return e != 6; }
1732
+ bool RawNumber(const char*, SizeType, bool) { return e != 7; }
1733
+ bool String(const char*, SizeType, bool) { return e != 8; }
1734
+ bool StartObject() { return e != 9; }
1735
+ bool Key(const char*, SizeType, bool) { return e != 10; }
1736
+ bool EndObject(SizeType) { return e != 11; }
1737
+ bool StartArray() { return e != 12; }
1738
+ bool EndArray(SizeType) { return e != 13; }
1739
+ };
1740
+
1741
+ #define TEST_TERMINATION(e, json)\
1742
+ {\
1743
+ Document d; \
1744
+ EXPECT_FALSE(d.Parse(json).HasParseError()); \
1745
+ Reader reader; \
1746
+ TerminateHandler<e> h;\
1747
+ EXPECT_FALSE(d.Accept(h));\
1748
+ }
1749
+
1750
+ TEST(Value, AcceptTerminationByHandler) {
1751
+ TEST_TERMINATION(0, "[null]");
1752
+ TEST_TERMINATION(1, "[true]");
1753
+ TEST_TERMINATION(1, "[false]");
1754
+ TEST_TERMINATION(2, "[-1]");
1755
+ TEST_TERMINATION(3, "[2147483648]");
1756
+ TEST_TERMINATION(4, "[-1234567890123456789]");
1757
+ TEST_TERMINATION(5, "[9223372036854775808]");
1758
+ TEST_TERMINATION(6, "[0.5]");
1759
+ // RawNumber() is never called
1760
+ TEST_TERMINATION(8, "[\"a\"]");
1761
+ TEST_TERMINATION(9, "[{}]");
1762
+ TEST_TERMINATION(10, "[{\"a\":1}]");
1763
+ TEST_TERMINATION(11, "[{}]");
1764
+ TEST_TERMINATION(12, "{\"a\":[]}");
1765
+ TEST_TERMINATION(13, "{\"a\":[]}");
1766
+ }
1767
+
1768
+ struct ValueIntComparer {
1769
+ bool operator()(const Value& lhs, const Value& rhs) const {
1770
+ return lhs.GetInt() < rhs.GetInt();
1771
+ }
1772
+ };
1773
+
1774
+ #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1775
+ TEST(Value, Sorting) {
1776
+ Value::AllocatorType allocator;
1777
+ Value a(kArrayType);
1778
+ a.PushBack(5, allocator);
1779
+ a.PushBack(1, allocator);
1780
+ a.PushBack(3, allocator);
1781
+ std::sort(a.Begin(), a.End(), ValueIntComparer());
1782
+ EXPECT_EQ(1, a[0].GetInt());
1783
+ EXPECT_EQ(3, a[1].GetInt());
1784
+ EXPECT_EQ(5, a[2].GetInt());
1785
+ }
1786
+ #endif
1787
+
1788
+ // http://stackoverflow.com/questions/35222230/
1789
+
1790
+ static void MergeDuplicateKey(Value& v, Value::AllocatorType& a) {
1791
+ if (v.IsObject()) {
1792
+ // Convert all key:value into key:[value]
1793
+ for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
1794
+ itr->value = Value(kArrayType).Move().PushBack(itr->value, a);
1795
+
1796
+ // Merge arrays if key is duplicated
1797
+ for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd();) {
1798
+ Value::MemberIterator itr2 = v.FindMember(itr->name);
1799
+ if (itr != itr2) {
1800
+ itr2->value.PushBack(itr->value[0], a);
1801
+ itr = v.EraseMember(itr);
1802
+ }
1803
+ else
1804
+ ++itr;
1805
+ }
1806
+
1807
+ // Convert key:[values] back to key:value if there is only one value
1808
+ for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr) {
1809
+ if (itr->value.Size() == 1)
1810
+ itr->value = itr->value[0];
1811
+ MergeDuplicateKey(itr->value, a); // Recursion on the value
1812
+ }
1813
+ }
1814
+ else if (v.IsArray())
1815
+ for (Value::ValueIterator itr = v.Begin(); itr != v.End(); ++itr)
1816
+ MergeDuplicateKey(*itr, a);
1817
+ }
1818
+
1819
+ TEST(Value, MergeDuplicateKey) {
1820
+ Document d;
1821
+ d.Parse(
1822
+ "{"
1823
+ " \"key1\": {"
1824
+ " \"a\": \"asdf\","
1825
+ " \"b\": \"foo\","
1826
+ " \"b\": \"bar\","
1827
+ " \"c\": \"fdas\""
1828
+ " }"
1829
+ "}");
1830
+
1831
+ Document d2;
1832
+ d2.Parse(
1833
+ "{"
1834
+ " \"key1\": {"
1835
+ " \"a\": \"asdf\","
1836
+ " \"b\": ["
1837
+ " \"foo\","
1838
+ " \"bar\""
1839
+ " ],"
1840
+ " \"c\": \"fdas\""
1841
+ " }"
1842
+ "}");
1843
+
1844
+ EXPECT_NE(d2, d);
1845
+ MergeDuplicateKey(d, d.GetAllocator());
1846
+ EXPECT_EQ(d2, d);
1847
+ }
1848
+
1849
+ #ifdef __clang__
1850
+ RAPIDJSON_DIAG_POP
1851
+ #endif