rj_schema 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +18 -0
  3. data/ext/rj_schema/extconf.rb +7 -0
  4. data/ext/rj_schema/rapidjson/CHANGELOG.md +158 -0
  5. data/ext/rj_schema/rapidjson/CMakeLists.txt +221 -0
  6. data/ext/rj_schema/rapidjson/CMakeModules/FindGTestSrc.cmake +30 -0
  7. data/ext/rj_schema/rapidjson/RapidJSON.pc.in +7 -0
  8. data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +15 -0
  9. data/ext/rj_schema/rapidjson/RapidJSONConfigVersion.cmake.in +10 -0
  10. data/ext/rj_schema/rapidjson/appveyor.yml +41 -0
  11. data/ext/rj_schema/rapidjson/bin/data/glossary.json +22 -0
  12. data/ext/rj_schema/rapidjson/bin/data/menu.json +27 -0
  13. data/ext/rj_schema/rapidjson/bin/data/readme.txt +1 -0
  14. data/ext/rj_schema/rapidjson/bin/data/sample.json +3315 -0
  15. data/ext/rj_schema/rapidjson/bin/data/webapp.json +88 -0
  16. data/ext/rj_schema/rapidjson/bin/data/widget.json +26 -0
  17. data/ext/rj_schema/rapidjson/bin/draft-04/schema +150 -0
  18. data/ext/rj_schema/rapidjson/bin/encodings/utf16be.json +0 -0
  19. data/ext/rj_schema/rapidjson/bin/encodings/utf16bebom.json +0 -0
  20. data/ext/rj_schema/rapidjson/bin/encodings/utf16le.json +0 -0
  21. data/ext/rj_schema/rapidjson/bin/encodings/utf16lebom.json +0 -0
  22. data/ext/rj_schema/rapidjson/bin/encodings/utf32be.json +0 -0
  23. data/ext/rj_schema/rapidjson/bin/encodings/utf32bebom.json +0 -0
  24. data/ext/rj_schema/rapidjson/bin/encodings/utf32le.json +0 -0
  25. data/ext/rj_schema/rapidjson/bin/encodings/utf32lebom.json +0 -0
  26. data/ext/rj_schema/rapidjson/bin/encodings/utf8.json +7 -0
  27. data/ext/rj_schema/rapidjson/bin/encodings/utf8bom.json +7 -0
  28. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail1.json +1 -0
  29. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail10.json +1 -0
  30. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail11.json +1 -0
  31. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail12.json +1 -0
  32. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail13.json +1 -0
  33. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail14.json +1 -0
  34. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail15.json +1 -0
  35. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail16.json +1 -0
  36. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail17.json +1 -0
  37. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail18.json +1 -0
  38. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail19.json +1 -0
  39. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail2.json +1 -0
  40. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail20.json +1 -0
  41. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail21.json +1 -0
  42. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail22.json +1 -0
  43. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail23.json +1 -0
  44. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail24.json +1 -0
  45. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail25.json +1 -0
  46. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail26.json +1 -0
  47. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail27.json +2 -0
  48. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail28.json +2 -0
  49. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail29.json +1 -0
  50. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail3.json +1 -0
  51. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail30.json +1 -0
  52. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail31.json +1 -0
  53. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail32.json +1 -0
  54. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail33.json +1 -0
  55. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail4.json +1 -0
  56. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail5.json +1 -0
  57. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail6.json +1 -0
  58. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail7.json +1 -0
  59. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail8.json +1 -0
  60. data/ext/rj_schema/rapidjson/bin/jsonchecker/fail9.json +1 -0
  61. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass1.json +58 -0
  62. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass2.json +1 -0
  63. data/ext/rj_schema/rapidjson/bin/jsonchecker/pass3.json +6 -0
  64. data/ext/rj_schema/rapidjson/bin/jsonchecker/readme.txt +3 -0
  65. data/ext/rj_schema/rapidjson/bin/jsonschema/LICENSE +19 -0
  66. data/ext/rj_schema/rapidjson/bin/jsonschema/README.md +148 -0
  67. data/ext/rj_schema/rapidjson/bin/jsonschema/bin/jsonschema_suite +283 -0
  68. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/folder/folderInteger.json +3 -0
  69. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/integer.json +3 -0
  70. data/ext/rj_schema/rapidjson/bin/jsonschema/remotes/subSchemas.json +8 -0
  71. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalItems.json +82 -0
  72. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/additionalProperties.json +88 -0
  73. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/default.json +49 -0
  74. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/dependencies.json +108 -0
  75. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/disallow.json +80 -0
  76. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/divisibleBy.json +60 -0
  77. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/enum.json +71 -0
  78. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/extends.json +94 -0
  79. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/items.json +46 -0
  80. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxItems.json +28 -0
  81. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maxLength.json +33 -0
  82. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/maximum.json +42 -0
  83. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minItems.json +28 -0
  84. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minLength.json +33 -0
  85. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/minimum.json +42 -0
  86. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/bignum.json +107 -0
  87. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/format.json +222 -0
  88. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/jsregex.json +18 -0
  89. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/optional/zeroTerminatedFloats.json +15 -0
  90. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/pattern.json +34 -0
  91. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/patternProperties.json +110 -0
  92. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/properties.json +92 -0
  93. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/ref.json +159 -0
  94. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/refRemote.json +74 -0
  95. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/required.json +53 -0
  96. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/type.json +474 -0
  97. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft3/uniqueItems.json +79 -0
  98. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalItems.json +82 -0
  99. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/additionalProperties.json +88 -0
  100. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/allOf.json +112 -0
  101. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/anyOf.json +68 -0
  102. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/default.json +49 -0
  103. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/definitions.json +32 -0
  104. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/dependencies.json +113 -0
  105. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/enum.json +72 -0
  106. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/items.json +46 -0
  107. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxItems.json +28 -0
  108. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxLength.json +33 -0
  109. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maxProperties.json +28 -0
  110. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/maximum.json +42 -0
  111. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minItems.json +28 -0
  112. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minLength.json +33 -0
  113. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minProperties.json +28 -0
  114. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/minimum.json +42 -0
  115. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/multipleOf.json +60 -0
  116. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/not.json +96 -0
  117. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/oneOf.json +68 -0
  118. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/bignum.json +107 -0
  119. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/format.json +148 -0
  120. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/optional/zeroTerminatedFloats.json +15 -0
  121. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/pattern.json +34 -0
  122. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/patternProperties.json +110 -0
  123. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/properties.json +92 -0
  124. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/ref.json +159 -0
  125. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/refRemote.json +74 -0
  126. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/required.json +39 -0
  127. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/type.json +330 -0
  128. data/ext/rj_schema/rapidjson/bin/jsonschema/tests/draft4/uniqueItems.json +79 -0
  129. data/ext/rj_schema/rapidjson/bin/jsonschema/tox.ini +8 -0
  130. data/ext/rj_schema/rapidjson/bin/types/booleans.json +102 -0
  131. data/ext/rj_schema/rapidjson/bin/types/floats.json +102 -0
  132. data/ext/rj_schema/rapidjson/bin/types/guids.json +102 -0
  133. data/ext/rj_schema/rapidjson/bin/types/integers.json +102 -0
  134. data/ext/rj_schema/rapidjson/bin/types/mixed.json +592 -0
  135. data/ext/rj_schema/rapidjson/bin/types/nulls.json +102 -0
  136. data/ext/rj_schema/rapidjson/bin/types/paragraphs.json +102 -0
  137. data/ext/rj_schema/rapidjson/bin/types/readme.txt +1 -0
  138. data/ext/rj_schema/rapidjson/contrib/natvis/LICENSE +45 -0
  139. data/ext/rj_schema/rapidjson/contrib/natvis/README.md +7 -0
  140. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +38 -0
  141. data/ext/rj_schema/rapidjson/doc/CMakeLists.txt +27 -0
  142. data/ext/rj_schema/rapidjson/doc/Doxyfile.in +2369 -0
  143. data/ext/rj_schema/rapidjson/doc/Doxyfile.zh-cn.in +2369 -0
  144. data/ext/rj_schema/rapidjson/doc/diagram/architecture.dot +50 -0
  145. data/ext/rj_schema/rapidjson/doc/diagram/architecture.png +0 -0
  146. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.dot +65 -0
  147. data/ext/rj_schema/rapidjson/doc/diagram/insituparsing.png +0 -0
  148. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.dot +62 -0
  149. data/ext/rj_schema/rapidjson/doc/diagram/iterative-parser-states-diagram.png +0 -0
  150. data/ext/rj_schema/rapidjson/doc/diagram/makefile +8 -0
  151. data/ext/rj_schema/rapidjson/doc/diagram/move1.dot +47 -0
  152. data/ext/rj_schema/rapidjson/doc/diagram/move1.png +0 -0
  153. data/ext/rj_schema/rapidjson/doc/diagram/move2.dot +62 -0
  154. data/ext/rj_schema/rapidjson/doc/diagram/move2.png +0 -0
  155. data/ext/rj_schema/rapidjson/doc/diagram/move3.dot +60 -0
  156. data/ext/rj_schema/rapidjson/doc/diagram/move3.png +0 -0
  157. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.dot +56 -0
  158. data/ext/rj_schema/rapidjson/doc/diagram/normalparsing.png +0 -0
  159. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.dot +54 -0
  160. data/ext/rj_schema/rapidjson/doc/diagram/simpledom.png +0 -0
  161. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.dot +58 -0
  162. data/ext/rj_schema/rapidjson/doc/diagram/tutorial.png +0 -0
  163. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.dot +73 -0
  164. data/ext/rj_schema/rapidjson/doc/diagram/utilityclass.png +0 -0
  165. data/ext/rj_schema/rapidjson/doc/dom.md +280 -0
  166. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +284 -0
  167. data/ext/rj_schema/rapidjson/doc/encoding.md +146 -0
  168. data/ext/rj_schema/rapidjson/doc/encoding.zh-cn.md +152 -0
  169. data/ext/rj_schema/rapidjson/doc/faq.md +289 -0
  170. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +290 -0
  171. data/ext/rj_schema/rapidjson/doc/features.md +104 -0
  172. data/ext/rj_schema/rapidjson/doc/features.zh-cn.md +103 -0
  173. data/ext/rj_schema/rapidjson/doc/internals.md +368 -0
  174. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +363 -0
  175. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.png +0 -0
  176. data/ext/rj_schema/rapidjson/doc/logo/rapidjson.svg +119 -0
  177. data/ext/rj_schema/rapidjson/doc/misc/DoxygenLayout.xml +194 -0
  178. data/ext/rj_schema/rapidjson/doc/misc/doxygenextra.css +274 -0
  179. data/ext/rj_schema/rapidjson/doc/misc/footer.html +11 -0
  180. data/ext/rj_schema/rapidjson/doc/misc/header.html +24 -0
  181. data/ext/rj_schema/rapidjson/doc/npm.md +31 -0
  182. data/ext/rj_schema/rapidjson/doc/performance.md +26 -0
  183. data/ext/rj_schema/rapidjson/doc/performance.zh-cn.md +26 -0
  184. data/ext/rj_schema/rapidjson/doc/pointer.md +234 -0
  185. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +234 -0
  186. data/ext/rj_schema/rapidjson/doc/sax.md +509 -0
  187. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +487 -0
  188. data/ext/rj_schema/rapidjson/doc/schema.md +505 -0
  189. data/ext/rj_schema/rapidjson/doc/schema.zh-cn.md +237 -0
  190. data/ext/rj_schema/rapidjson/doc/stream.md +426 -0
  191. data/ext/rj_schema/rapidjson/doc/stream.zh-cn.md +426 -0
  192. data/ext/rj_schema/rapidjson/doc/tutorial.md +536 -0
  193. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +534 -0
  194. data/ext/rj_schema/rapidjson/docker/debian/Dockerfile +8 -0
  195. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +45 -0
  196. data/ext/rj_schema/rapidjson/example/archiver/archiver.cpp +292 -0
  197. data/ext/rj_schema/rapidjson/example/archiver/archiver.h +145 -0
  198. data/ext/rj_schema/rapidjson/example/archiver/archivertest.cpp +287 -0
  199. data/ext/rj_schema/rapidjson/example/capitalize/capitalize.cpp +67 -0
  200. data/ext/rj_schema/rapidjson/example/condense/condense.cpp +32 -0
  201. data/ext/rj_schema/rapidjson/example/filterkey/filterkey.cpp +135 -0
  202. data/ext/rj_schema/rapidjson/example/filterkeydom/filterkeydom.cpp +170 -0
  203. data/ext/rj_schema/rapidjson/example/jsonx/jsonx.cpp +207 -0
  204. data/ext/rj_schema/rapidjson/example/lookaheadparser/lookaheadparser.cpp +350 -0
  205. data/ext/rj_schema/rapidjson/example/messagereader/messagereader.cpp +105 -0
  206. data/ext/rj_schema/rapidjson/example/parsebyparts/parsebyparts.cpp +176 -0
  207. data/ext/rj_schema/rapidjson/example/pretty/pretty.cpp +30 -0
  208. data/ext/rj_schema/rapidjson/example/prettyauto/prettyauto.cpp +56 -0
  209. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +78 -0
  210. data/ext/rj_schema/rapidjson/example/serialize/serialize.cpp +173 -0
  211. data/ext/rj_schema/rapidjson/example/simpledom/simpledom.cpp +29 -0
  212. data/ext/rj_schema/rapidjson/example/simplepullreader/simplepullreader.cpp +53 -0
  213. data/ext/rj_schema/rapidjson/example/simplereader/simplereader.cpp +42 -0
  214. data/ext/rj_schema/rapidjson/example/simplewriter/simplewriter.cpp +36 -0
  215. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +151 -0
  216. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +271 -0
  217. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +78 -0
  218. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +2630 -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/diyfp.h +258 -0
  228. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +245 -0
  229. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +78 -0
  230. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +304 -0
  231. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +181 -0
  232. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +55 -0
  233. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +734 -0
  234. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +231 -0
  235. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +69 -0
  236. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +269 -0
  237. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +46 -0
  238. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +115 -0
  239. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +70 -0
  240. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +71 -0
  241. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/inttypes.h +316 -0
  242. data/ext/rj_schema/rapidjson/include/rapidjson/msinttypes/stdint.h +300 -0
  243. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +81 -0
  244. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +1363 -0
  245. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +277 -0
  246. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +628 -0
  247. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +2222 -0
  248. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +2479 -0
  249. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +223 -0
  250. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +121 -0
  251. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +716 -0
  252. data/ext/rj_schema/rapidjson/include_dirs.js +2 -0
  253. data/ext/rj_schema/rapidjson/library.json +15 -0
  254. data/ext/rj_schema/rapidjson/license.txt +57 -0
  255. data/ext/rj_schema/rapidjson/package.json +24 -0
  256. data/ext/rj_schema/rapidjson/rapidjson.autopkg +77 -0
  257. data/ext/rj_schema/rapidjson/readme.md +160 -0
  258. data/ext/rj_schema/rapidjson/readme.zh-cn.md +152 -0
  259. data/ext/rj_schema/rapidjson/test/CMakeLists.txt +20 -0
  260. data/ext/rj_schema/rapidjson/test/perftest/CMakeLists.txt +28 -0
  261. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +974 -0
  262. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +24 -0
  263. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +185 -0
  264. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +166 -0
  265. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +472 -0
  266. data/ext/rj_schema/rapidjson/test/perftest/schematest.cpp +216 -0
  267. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +92 -0
  268. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +102 -0
  269. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +133 -0
  270. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +115 -0
  271. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +672 -0
  272. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +98 -0
  273. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +313 -0
  274. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +451 -0
  275. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +112 -0
  276. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +230 -0
  277. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +181 -0
  278. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +160 -0
  279. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +143 -0
  280. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +70 -0
  281. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +92 -0
  282. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +1529 -0
  283. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +344 -0
  284. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +1895 -0
  285. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +638 -0
  286. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +2009 -0
  287. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +219 -0
  288. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +30 -0
  289. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +192 -0
  290. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +132 -0
  291. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +51 -0
  292. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +140 -0
  293. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +1829 -0
  294. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +598 -0
  295. data/ext/rj_schema/rapidjson/test/valgrind.supp +17 -0
  296. data/ext/rj_schema/rapidjson/travis-doxygen.sh +121 -0
  297. data/ext/rj_schema/rj_schema.cpp +136 -0
  298. data/lib/rj_schema.rb +7 -0
  299. metadata +371 -0
@@ -0,0 +1,216 @@
1
+ #include "perftest.h"
2
+
3
+ #if TEST_RAPIDJSON
4
+
5
+ #include "rapidjson/schema.h"
6
+ #include <ctime>
7
+ #include <string>
8
+ #include <vector>
9
+
10
+ #define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
11
+
12
+ using namespace rapidjson;
13
+
14
+ template <typename Allocator>
15
+ static char* ReadFile(const char* filename, Allocator& allocator) {
16
+ const char *paths[] = {
17
+ "",
18
+ "bin/",
19
+ "../bin/",
20
+ "../../bin/",
21
+ "../../../bin/"
22
+ };
23
+ char buffer[1024];
24
+ FILE *fp = 0;
25
+ for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
26
+ sprintf(buffer, "%s%s", paths[i], filename);
27
+ fp = fopen(buffer, "rb");
28
+ if (fp)
29
+ break;
30
+ }
31
+
32
+ if (!fp)
33
+ return 0;
34
+
35
+ fseek(fp, 0, SEEK_END);
36
+ size_t length = static_cast<size_t>(ftell(fp));
37
+ fseek(fp, 0, SEEK_SET);
38
+ char* json = reinterpret_cast<char*>(allocator.Malloc(length + 1));
39
+ size_t readLength = fread(json, 1, length, fp);
40
+ json[readLength] = '\0';
41
+ fclose(fp);
42
+ return json;
43
+ }
44
+
45
+ class Schema : public PerfTest {
46
+ public:
47
+ Schema() {}
48
+
49
+ virtual void SetUp() {
50
+ PerfTest::SetUp();
51
+
52
+ const char* filenames[] = {
53
+ "additionalItems.json",
54
+ "additionalProperties.json",
55
+ "allOf.json",
56
+ "anyOf.json",
57
+ "default.json",
58
+ "definitions.json",
59
+ "dependencies.json",
60
+ "enum.json",
61
+ "items.json",
62
+ "maximum.json",
63
+ "maxItems.json",
64
+ "maxLength.json",
65
+ "maxProperties.json",
66
+ "minimum.json",
67
+ "minItems.json",
68
+ "minLength.json",
69
+ "minProperties.json",
70
+ "multipleOf.json",
71
+ "not.json",
72
+ "oneOf.json",
73
+ "pattern.json",
74
+ "patternProperties.json",
75
+ "properties.json",
76
+ "ref.json",
77
+ "refRemote.json",
78
+ "required.json",
79
+ "type.json",
80
+ "uniqueItems.json"
81
+ };
82
+
83
+ char jsonBuffer[65536];
84
+ MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));
85
+
86
+ for (size_t i = 0; i < ARRAY_SIZE(filenames); i++) {
87
+ char filename[FILENAME_MAX];
88
+ sprintf(filename, "jsonschema/tests/draft4/%s", filenames[i]);
89
+ char* json = ReadFile(filename, jsonAllocator);
90
+ if (!json) {
91
+ printf("json test suite file %s not found", filename);
92
+ return;
93
+ }
94
+
95
+ Document d;
96
+ d.Parse(json);
97
+ if (d.HasParseError()) {
98
+ printf("json test suite file %s has parse error", filename);
99
+ return;
100
+ }
101
+
102
+ for (Value::ConstValueIterator schemaItr = d.Begin(); schemaItr != d.End(); ++schemaItr) {
103
+ std::string schemaDescription = (*schemaItr)["description"].GetString();
104
+ if (IsExcludeTestSuite(schemaDescription))
105
+ continue;
106
+
107
+ TestSuite* ts = new TestSuite;
108
+ ts->schema = new SchemaDocument((*schemaItr)["schema"]);
109
+
110
+ const Value& tests = (*schemaItr)["tests"];
111
+ for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {
112
+ if (IsExcludeTest(schemaDescription + ", " + (*testItr)["description"].GetString()))
113
+ continue;
114
+
115
+ Document* d2 = new Document;
116
+ d2->CopyFrom((*testItr)["data"], d2->GetAllocator());
117
+ ts->tests.push_back(d2);
118
+ }
119
+ testSuites.push_back(ts);
120
+ }
121
+ }
122
+ }
123
+
124
+ virtual void TearDown() {
125
+ PerfTest::TearDown();
126
+ for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr)
127
+ delete *itr;
128
+ testSuites.clear();
129
+ }
130
+
131
+ private:
132
+ // Using the same exclusion in https://github.com/json-schema/JSON-Schema-Test-Suite
133
+ static bool IsExcludeTestSuite(const std::string& description) {
134
+ const char* excludeTestSuites[] = {
135
+ //lost failing these tests
136
+ "remote ref",
137
+ "remote ref, containing refs itself",
138
+ "fragment within remote ref",
139
+ "ref within remote ref",
140
+ "change resolution scope",
141
+ // these below were added to get jsck in the benchmarks)
142
+ "uniqueItems validation",
143
+ "valid definition",
144
+ "invalid definition"
145
+ };
146
+
147
+ for (size_t i = 0; i < ARRAY_SIZE(excludeTestSuites); i++)
148
+ if (excludeTestSuites[i] == description)
149
+ return true;
150
+ return false;
151
+ }
152
+
153
+ // Using the same exclusion in https://github.com/json-schema/JSON-Schema-Test-Suite
154
+ static bool IsExcludeTest(const std::string& description) {
155
+ const char* excludeTests[] = {
156
+ //lots of validators fail these
157
+ "invalid definition, invalid definition schema",
158
+ "maxLength validation, two supplementary Unicode code points is long enough",
159
+ "minLength validation, one supplementary Unicode code point is not long enough",
160
+ //this is to get tv4 in the benchmarks
161
+ "heterogeneous enum validation, something else is invalid"
162
+ };
163
+
164
+ for (size_t i = 0; i < ARRAY_SIZE(excludeTests); i++)
165
+ if (excludeTests[i] == description)
166
+ return true;
167
+ return false;
168
+ }
169
+
170
+ Schema(const Schema&);
171
+ Schema& operator=(const Schema&);
172
+
173
+ protected:
174
+ typedef std::vector<Document*> DocumentList;
175
+
176
+ struct TestSuite {
177
+ TestSuite() : schema() {}
178
+ ~TestSuite() {
179
+ delete schema;
180
+ for (DocumentList::iterator itr = tests.begin(); itr != tests.end(); ++itr)
181
+ delete *itr;
182
+ }
183
+ SchemaDocument* schema;
184
+ DocumentList tests;
185
+ };
186
+
187
+ typedef std::vector<TestSuite* > TestSuiteList;
188
+ TestSuiteList testSuites;
189
+ };
190
+
191
+ TEST_F(Schema, TestSuite) {
192
+ char validatorBuffer[65536];
193
+ MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer));
194
+
195
+ const int trialCount = 100000;
196
+ int testCount = 0;
197
+ clock_t start = clock();
198
+ for (int i = 0; i < trialCount; i++) {
199
+ for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {
200
+ const TestSuite& ts = **itr;
201
+ GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(*ts.schema, &validatorAllocator);
202
+ for (DocumentList::const_iterator testItr = ts.tests.begin(); testItr != ts.tests.end(); ++testItr) {
203
+ validator.Reset();
204
+ (*testItr)->Accept(validator);
205
+ testCount++;
206
+ }
207
+ validatorAllocator.Clear();
208
+ }
209
+ }
210
+ clock_t end = clock();
211
+ double duration = double(end - start) / CLOCKS_PER_SEC;
212
+ printf("%d trials in %f s -> %f trials per sec\n", trialCount, duration, trialCount / duration);
213
+ printf("%d tests per trial\n", testCount / trialCount);
214
+ }
215
+
216
+ #endif
@@ -0,0 +1,92 @@
1
+ include(CheckCXXCompilerFlag)
2
+
3
+ set(UNITTEST_SOURCES
4
+ allocatorstest.cpp
5
+ bigintegertest.cpp
6
+ cursorstreamwrappertest.cpp
7
+ documenttest.cpp
8
+ dtoatest.cpp
9
+ encodedstreamtest.cpp
10
+ encodingstest.cpp
11
+ fwdtest.cpp
12
+ filestreamtest.cpp
13
+ itoatest.cpp
14
+ istreamwrappertest.cpp
15
+ jsoncheckertest.cpp
16
+ namespacetest.cpp
17
+ pointertest.cpp
18
+ prettywritertest.cpp
19
+ ostreamwrappertest.cpp
20
+ readertest.cpp
21
+ regextest.cpp
22
+ schematest.cpp
23
+ simdtest.cpp
24
+ strfunctest.cpp
25
+ stringbuffertest.cpp
26
+ strtodtest.cpp
27
+ unittest.cpp
28
+ valuetest.cpp
29
+ writertest.cpp)
30
+
31
+ find_program(CCACHE_FOUND ccache)
32
+ if(CCACHE_FOUND)
33
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
34
+ set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
35
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
36
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
37
+ endif()
38
+ endif(CCACHE_FOUND)
39
+
40
+ set_property(DIRECTORY PROPERTY COMPILE_OPTIONS ${EXTRA_CXX_FLAGS})
41
+
42
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
43
+ # If the user is running a newer version of Clang that includes the
44
+ # -Wdouble-promotion, we will ignore that warning.
45
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.7)
46
+ CHECK_CXX_COMPILER_FLAG("-Wno-double-promotion" HAS_NO_DOUBLE_PROMOTION)
47
+ if (HAS_NO_DOUBLE_PROMOTION)
48
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-double-promotion")
49
+ endif()
50
+ endif()
51
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
52
+ # Force to always compile with /W4
53
+ if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
54
+ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
55
+ else()
56
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
57
+ endif()
58
+
59
+ # Force to always compile with /WX
60
+ if(CMAKE_CXX_FLAGS MATCHES "/WX-")
61
+ string(REGEX REPLACE "/WX-" "/WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
62
+ else()
63
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
64
+ endif()
65
+ endif()
66
+
67
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1")
68
+
69
+ add_library(namespacetest STATIC namespacetest.cpp)
70
+
71
+ add_executable(unittest ${UNITTEST_SOURCES})
72
+ target_link_libraries(unittest ${TEST_LIBRARIES} namespacetest)
73
+
74
+ add_dependencies(tests unittest)
75
+
76
+ add_test(NAME unittest
77
+ COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest
78
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
79
+
80
+ if(NOT MSVC)
81
+ # Not running SIMD.* unit test cases for Valgrind
82
+ add_test(NAME valgrind_unittest
83
+ COMMAND valgrind --suppressions=${CMAKE_SOURCE_DIR}/test/valgrind.supp --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest --gtest_filter=-SIMD.*
84
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
85
+
86
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
87
+ add_test(NAME symbol_check
88
+ COMMAND sh -c "objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0"
89
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
90
+ endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
91
+
92
+ endif(NOT MSVC)
@@ -0,0 +1,102 @@
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
+
17
+ #include "rapidjson/allocators.h"
18
+
19
+ using namespace rapidjson;
20
+
21
+ template <typename Allocator>
22
+ void TestAllocator(Allocator& a) {
23
+ EXPECT_TRUE(a.Malloc(0) == 0);
24
+
25
+ uint8_t* p = static_cast<uint8_t*>(a.Malloc(100));
26
+ EXPECT_TRUE(p != 0);
27
+ for (size_t i = 0; i < 100; i++)
28
+ p[i] = static_cast<uint8_t>(i);
29
+
30
+ // Expand
31
+ uint8_t* q = static_cast<uint8_t*>(a.Realloc(p, 100, 200));
32
+ EXPECT_TRUE(q != 0);
33
+ for (size_t i = 0; i < 100; i++)
34
+ EXPECT_EQ(i, q[i]);
35
+ for (size_t i = 100; i < 200; i++)
36
+ q[i] = static_cast<uint8_t>(i);
37
+
38
+ // Shrink
39
+ uint8_t *r = static_cast<uint8_t*>(a.Realloc(q, 200, 150));
40
+ EXPECT_TRUE(r != 0);
41
+ for (size_t i = 0; i < 150; i++)
42
+ EXPECT_EQ(i, r[i]);
43
+
44
+ Allocator::Free(r);
45
+
46
+ // Realloc to zero size
47
+ EXPECT_TRUE(a.Realloc(a.Malloc(1), 1, 0) == 0);
48
+ }
49
+
50
+ TEST(Allocator, CrtAllocator) {
51
+ CrtAllocator a;
52
+ TestAllocator(a);
53
+ }
54
+
55
+ TEST(Allocator, MemoryPoolAllocator) {
56
+ MemoryPoolAllocator<> a;
57
+ TestAllocator(a);
58
+
59
+ for (size_t i = 1; i < 1000; i++) {
60
+ EXPECT_TRUE(a.Malloc(i) != 0);
61
+ EXPECT_LE(a.Size(), a.Capacity());
62
+ }
63
+ }
64
+
65
+ TEST(Allocator, Alignment) {
66
+ #if RAPIDJSON_64BIT == 1
67
+ EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000000), RAPIDJSON_ALIGN(0));
68
+ for (uint64_t i = 1; i < 8; i++) {
69
+ EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000008), RAPIDJSON_ALIGN(i));
70
+ EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000010), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0x00000000, 0x00000008) + i));
71
+ EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000001, 0x00000000), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0x00000000, 0xFFFFFFF8) + i));
72
+ EXPECT_EQ(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF8), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF0) + i));
73
+ }
74
+ #else
75
+ EXPECT_EQ(0u, RAPIDJSON_ALIGN(0u));
76
+ for (uint32_t i = 1; i < 4; i++) {
77
+ EXPECT_EQ(4u, RAPIDJSON_ALIGN(i));
78
+ EXPECT_EQ(8u, RAPIDJSON_ALIGN(4u + i));
79
+ EXPECT_EQ(0xFFFFFFF8u, RAPIDJSON_ALIGN(0xFFFFFFF4u + i));
80
+ EXPECT_EQ(0xFFFFFFFCu, RAPIDJSON_ALIGN(0xFFFFFFF8u + i));
81
+ }
82
+ #endif
83
+ }
84
+
85
+ TEST(Allocator, Issue399) {
86
+ MemoryPoolAllocator<> a;
87
+ void* p = a.Malloc(100);
88
+ void* q = a.Realloc(p, 100, 200);
89
+ EXPECT_EQ(p, q);
90
+
91
+ // exhuasive testing
92
+ for (size_t j = 1; j < 32; j++) {
93
+ a.Clear();
94
+ a.Malloc(j); // some unaligned size
95
+ p = a.Malloc(1);
96
+ for (size_t i = 1; i < 1024; i++) {
97
+ q = a.Realloc(p, i, i + 1);
98
+ EXPECT_EQ(p, q);
99
+ p = q;
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,133 @@
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
+
17
+ #include "rapidjson/internal/biginteger.h"
18
+
19
+ using namespace rapidjson::internal;
20
+
21
+ #define BIGINTEGER_LITERAL(s) BigInteger(s, sizeof(s) - 1)
22
+
23
+ static const BigInteger kZero(0);
24
+ static const BigInteger kOne(1);
25
+ static const BigInteger kUint64Max = BIGINTEGER_LITERAL("18446744073709551615");
26
+ static const BigInteger kTwo64 = BIGINTEGER_LITERAL("18446744073709551616");
27
+
28
+ TEST(BigInteger, Constructor) {
29
+ EXPECT_TRUE(kZero.IsZero());
30
+ EXPECT_TRUE(kZero == kZero);
31
+ EXPECT_TRUE(kZero == BIGINTEGER_LITERAL("0"));
32
+ EXPECT_TRUE(kZero == BIGINTEGER_LITERAL("00"));
33
+
34
+ const BigInteger a(123);
35
+ EXPECT_TRUE(a == a);
36
+ EXPECT_TRUE(a == BIGINTEGER_LITERAL("123"));
37
+ EXPECT_TRUE(a == BIGINTEGER_LITERAL("0123"));
38
+
39
+ EXPECT_EQ(2u, kTwo64.GetCount());
40
+ EXPECT_EQ(0u, kTwo64.GetDigit(0));
41
+ EXPECT_EQ(1u, kTwo64.GetDigit(1));
42
+ }
43
+
44
+ TEST(BigInteger, AddUint64) {
45
+ BigInteger a = kZero;
46
+ a += 0u;
47
+ EXPECT_TRUE(kZero == a);
48
+
49
+ a += 1u;
50
+ EXPECT_TRUE(kOne == a);
51
+
52
+ a += 1u;
53
+ EXPECT_TRUE(BigInteger(2) == a);
54
+
55
+ EXPECT_TRUE(BigInteger(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF)) == kUint64Max);
56
+ BigInteger b = kUint64Max;
57
+ b += 1u;
58
+ EXPECT_TRUE(kTwo64 == b);
59
+ b += RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);
60
+ EXPECT_TRUE(BIGINTEGER_LITERAL("36893488147419103231") == b);
61
+ }
62
+
63
+ TEST(BigInteger, MultiplyUint64) {
64
+ BigInteger a = kZero;
65
+ a *= static_cast <uint64_t>(0);
66
+ EXPECT_TRUE(kZero == a);
67
+ a *= static_cast <uint64_t>(123);
68
+ EXPECT_TRUE(kZero == a);
69
+
70
+ BigInteger b = kOne;
71
+ b *= static_cast<uint64_t>(1);
72
+ EXPECT_TRUE(kOne == b);
73
+ b *= static_cast<uint64_t>(0);
74
+ EXPECT_TRUE(kZero == b);
75
+
76
+ BigInteger c(123);
77
+ c *= static_cast<uint64_t>(456u);
78
+ EXPECT_TRUE(BigInteger(123u * 456u) == c);
79
+ c *= RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);
80
+ EXPECT_TRUE(BIGINTEGER_LITERAL("1034640981606221330982120") == c);
81
+ c *= RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);
82
+ EXPECT_TRUE(BIGINTEGER_LITERAL("19085757395861596536664473018420572782123800") == c);
83
+ }
84
+
85
+ TEST(BigInteger, MultiplyUint32) {
86
+ BigInteger a = kZero;
87
+ a *= static_cast <uint32_t>(0);
88
+ EXPECT_TRUE(kZero == a);
89
+ a *= static_cast <uint32_t>(123);
90
+ EXPECT_TRUE(kZero == a);
91
+
92
+ BigInteger b = kOne;
93
+ b *= static_cast<uint32_t>(1);
94
+ EXPECT_TRUE(kOne == b);
95
+ b *= static_cast<uint32_t>(0);
96
+ EXPECT_TRUE(kZero == b);
97
+
98
+ BigInteger c(123);
99
+ c *= static_cast<uint32_t>(456u);
100
+ EXPECT_TRUE(BigInteger(123u * 456u) == c);
101
+ c *= 0xFFFFFFFFu;
102
+ EXPECT_TRUE(BIGINTEGER_LITERAL("240896125641960") == c);
103
+ c *= 0xFFFFFFFFu;
104
+ EXPECT_TRUE(BIGINTEGER_LITERAL("1034640981124429079698200") == c);
105
+ }
106
+
107
+ TEST(BigInteger, LeftShift) {
108
+ BigInteger a = kZero;
109
+ a <<= 1;
110
+ EXPECT_TRUE(kZero == a);
111
+ a <<= 64;
112
+ EXPECT_TRUE(kZero == a);
113
+
114
+ a = BigInteger(123);
115
+ a <<= 0;
116
+ EXPECT_TRUE(BigInteger(123) == a);
117
+ a <<= 1;
118
+ EXPECT_TRUE(BigInteger(246) == a);
119
+ a <<= 64;
120
+ EXPECT_TRUE(BIGINTEGER_LITERAL("4537899042132549697536") == a);
121
+ a <<= 99;
122
+ EXPECT_TRUE(BIGINTEGER_LITERAL("2876235222267216943024851750785644982682875244576768") == a);
123
+ }
124
+
125
+ TEST(BigInteger, Compare) {
126
+ EXPECT_EQ(0, kZero.Compare(kZero));
127
+ EXPECT_EQ(1, kOne.Compare(kZero));
128
+ EXPECT_EQ(-1, kZero.Compare(kOne));
129
+ EXPECT_EQ(0, kUint64Max.Compare(kUint64Max));
130
+ EXPECT_EQ(0, kTwo64.Compare(kTwo64));
131
+ EXPECT_EQ(-1, kUint64Max.Compare(kTwo64));
132
+ EXPECT_EQ(1, kTwo64.Compare(kUint64Max));
133
+ }