rj_schema 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. checksums.yaml +4 -4
  2. data/ext/rj_schema/rapidjson/CMakeLists.txt +9 -4
  3. data/ext/rj_schema/rapidjson/RapidJSONConfig.cmake.in +10 -0
  4. data/ext/rj_schema/rapidjson/appveyor.yml +22 -9
  5. data/ext/rj_schema/rapidjson/bin/data/abcde.txt +1 -0
  6. data/ext/rj_schema/rapidjson/bin/unittestschema/address.json +139 -0
  7. data/ext/rj_schema/rapidjson/bin/unittestschema/allOf_address.json +7 -0
  8. data/ext/rj_schema/rapidjson/bin/unittestschema/anyOf_address.json +7 -0
  9. data/ext/rj_schema/rapidjson/bin/unittestschema/oneOf_address.json +7 -0
  10. data/ext/rj_schema/rapidjson/contrib/natvis/rapidjson.natvis +2 -2
  11. data/ext/rj_schema/rapidjson/doc/dom.md +1 -0
  12. data/ext/rj_schema/rapidjson/doc/dom.zh-cn.md +1 -0
  13. data/ext/rj_schema/rapidjson/doc/faq.md +3 -3
  14. data/ext/rj_schema/rapidjson/doc/faq.zh-cn.md +8 -8
  15. data/ext/rj_schema/rapidjson/doc/internals.md +1 -1
  16. data/ext/rj_schema/rapidjson/doc/internals.zh-cn.md +2 -2
  17. data/ext/rj_schema/rapidjson/doc/pointer.zh-cn.md +1 -1
  18. data/ext/rj_schema/rapidjson/doc/sax.md +1 -1
  19. data/ext/rj_schema/rapidjson/doc/sax.zh-cn.md +2 -2
  20. data/ext/rj_schema/rapidjson/doc/stream.md +1 -1
  21. data/ext/rj_schema/rapidjson/doc/tutorial.md +1 -1
  22. data/ext/rj_schema/rapidjson/doc/tutorial.zh-cn.md +7 -6
  23. data/ext/rj_schema/rapidjson/example/CMakeLists.txt +1 -0
  24. data/ext/rj_schema/rapidjson/example/schemavalidator/schemavalidator.cpp +118 -0
  25. data/ext/rj_schema/rapidjson/example/sortkeys/sortkeys.cpp +62 -0
  26. data/ext/rj_schema/rapidjson/example/tutorial/tutorial.cpp +1 -1
  27. data/ext/rj_schema/rapidjson/include/rapidjson/allocators.h +6 -6
  28. data/ext/rj_schema/rapidjson/include/rapidjson/cursorstreamwrapper.h +1 -1
  29. data/ext/rj_schema/rapidjson/include/rapidjson/document.h +124 -35
  30. data/ext/rj_schema/rapidjson/include/rapidjson/encodedstream.h +1 -1
  31. data/ext/rj_schema/rapidjson/include/rapidjson/encodings.h +1 -1
  32. data/ext/rj_schema/rapidjson/include/rapidjson/error/en.h +49 -1
  33. data/ext/rj_schema/rapidjson/include/rapidjson/error/error.h +56 -1
  34. data/ext/rj_schema/rapidjson/include/rapidjson/filereadstream.h +2 -2
  35. data/ext/rj_schema/rapidjson/include/rapidjson/filewritestream.h +1 -1
  36. data/ext/rj_schema/rapidjson/include/rapidjson/fwd.h +2 -2
  37. data/ext/rj_schema/rapidjson/include/rapidjson/internal/biginteger.h +2 -2
  38. data/ext/rj_schema/rapidjson/include/rapidjson/internal/clzll.h +71 -0
  39. data/ext/rj_schema/rapidjson/include/rapidjson/internal/diyfp.h +3 -17
  40. data/ext/rj_schema/rapidjson/include/rapidjson/internal/dtoa.h +1 -1
  41. data/ext/rj_schema/rapidjson/include/rapidjson/internal/ieee754.h +1 -1
  42. data/ext/rj_schema/rapidjson/include/rapidjson/internal/itoa.h +1 -1
  43. data/ext/rj_schema/rapidjson/include/rapidjson/internal/meta.h +1 -1
  44. data/ext/rj_schema/rapidjson/include/rapidjson/internal/pow10.h +1 -1
  45. data/ext/rj_schema/rapidjson/include/rapidjson/internal/regex.h +20 -13
  46. data/ext/rj_schema/rapidjson/include/rapidjson/internal/stack.h +4 -3
  47. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strfunc.h +1 -1
  48. data/ext/rj_schema/rapidjson/include/rapidjson/internal/strtod.h +1 -1
  49. data/ext/rj_schema/rapidjson/include/rapidjson/internal/swap.h +1 -1
  50. data/ext/rj_schema/rapidjson/include/rapidjson/istreamwrapper.h +50 -35
  51. data/ext/rj_schema/rapidjson/include/rapidjson/memorybuffer.h +1 -1
  52. data/ext/rj_schema/rapidjson/include/rapidjson/memorystream.h +1 -1
  53. data/ext/rj_schema/rapidjson/include/rapidjson/ostreamwrapper.h +1 -1
  54. data/ext/rj_schema/rapidjson/include/rapidjson/pointer.h +63 -5
  55. data/ext/rj_schema/rapidjson/include/rapidjson/prettywriter.h +2 -2
  56. data/ext/rj_schema/rapidjson/include/rapidjson/rapidjson.h +63 -1
  57. data/ext/rj_schema/rapidjson/include/rapidjson/reader.h +67 -53
  58. data/ext/rj_schema/rapidjson/include/rapidjson/schema.h +318 -164
  59. data/ext/rj_schema/rapidjson/include/rapidjson/stream.h +1 -1
  60. data/ext/rj_schema/rapidjson/include/rapidjson/stringbuffer.h +1 -1
  61. data/ext/rj_schema/rapidjson/include/rapidjson/writer.h +10 -10
  62. data/ext/rj_schema/rapidjson/readme.md +51 -1
  63. data/ext/rj_schema/rapidjson/readme.zh-cn.md +2 -2
  64. data/ext/rj_schema/rapidjson/test/perftest/misctest.cpp +1 -1
  65. data/ext/rj_schema/rapidjson/test/perftest/perftest.cpp +1 -1
  66. data/ext/rj_schema/rapidjson/test/perftest/perftest.h +1 -1
  67. data/ext/rj_schema/rapidjson/test/perftest/platformtest.cpp +2 -2
  68. data/ext/rj_schema/rapidjson/test/perftest/rapidjsontest.cpp +75 -1
  69. data/ext/rj_schema/rapidjson/test/unittest/CMakeLists.txt +1 -0
  70. data/ext/rj_schema/rapidjson/test/unittest/allocatorstest.cpp +1 -1
  71. data/ext/rj_schema/rapidjson/test/unittest/bigintegertest.cpp +1 -1
  72. data/ext/rj_schema/rapidjson/test/unittest/clzlltest.cpp +34 -0
  73. data/ext/rj_schema/rapidjson/test/unittest/cursorstreamwrappertest.cpp +19 -19
  74. data/ext/rj_schema/rapidjson/test/unittest/documenttest.cpp +1 -1
  75. data/ext/rj_schema/rapidjson/test/unittest/dtoatest.cpp +1 -1
  76. data/ext/rj_schema/rapidjson/test/unittest/encodedstreamtest.cpp +1 -1
  77. data/ext/rj_schema/rapidjson/test/unittest/encodingstest.cpp +1 -1
  78. data/ext/rj_schema/rapidjson/test/unittest/filestreamtest.cpp +45 -2
  79. data/ext/rj_schema/rapidjson/test/unittest/fwdtest.cpp +1 -1
  80. data/ext/rj_schema/rapidjson/test/unittest/istreamwrappertest.cpp +10 -10
  81. data/ext/rj_schema/rapidjson/test/unittest/itoatest.cpp +8 -8
  82. data/ext/rj_schema/rapidjson/test/unittest/jsoncheckertest.cpp +1 -1
  83. data/ext/rj_schema/rapidjson/test/unittest/namespacetest.cpp +1 -1
  84. data/ext/rj_schema/rapidjson/test/unittest/ostreamwrappertest.cpp +1 -1
  85. data/ext/rj_schema/rapidjson/test/unittest/pointertest.cpp +157 -16
  86. data/ext/rj_schema/rapidjson/test/unittest/prettywritertest.cpp +1 -1
  87. data/ext/rj_schema/rapidjson/test/unittest/readertest.cpp +113 -75
  88. data/ext/rj_schema/rapidjson/test/unittest/regextest.cpp +2 -1
  89. data/ext/rj_schema/rapidjson/test/unittest/schematest.cpp +593 -78
  90. data/ext/rj_schema/rapidjson/test/unittest/simdtest.cpp +1 -1
  91. data/ext/rj_schema/rapidjson/test/unittest/strfunctest.cpp +1 -1
  92. data/ext/rj_schema/rapidjson/test/unittest/stringbuffertest.cpp +5 -5
  93. data/ext/rj_schema/rapidjson/test/unittest/strtodtest.cpp +1 -1
  94. data/ext/rj_schema/rapidjson/test/unittest/unittest.cpp +1 -1
  95. data/ext/rj_schema/rapidjson/test/unittest/unittest.h +4 -1
  96. data/ext/rj_schema/rapidjson/test/unittest/valuetest.cpp +12 -12
  97. data/ext/rj_schema/rapidjson/test/unittest/writertest.cpp +1 -1
  98. data/ext/rj_schema/rapidjson/thirdparty/gtest/BUILD.bazel +175 -0
  99. data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +18 -1
  100. data/ext/rj_schema/rapidjson/thirdparty/gtest/CONTRIBUTING.md +160 -0
  101. data/ext/rj_schema/rapidjson/thirdparty/gtest/LICENSE +28 -0
  102. data/ext/rj_schema/rapidjson/thirdparty/gtest/Makefile.am +14 -0
  103. data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +16 -35
  104. data/ext/rj_schema/rapidjson/thirdparty/gtest/WORKSPACE +8 -0
  105. data/ext/rj_schema/rapidjson/thirdparty/gtest/appveyor.yml +104 -0
  106. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-autotools.sh +44 -0
  107. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/build-linux-bazel.sh +36 -0
  108. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-linux.sh +41 -0
  109. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/env-osx.sh +40 -0
  110. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/get-nprocessors.sh +48 -0
  111. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-linux.sh +49 -0
  112. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/install-osx.sh +39 -0
  113. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/log-config.sh +51 -0
  114. data/ext/rj_schema/rapidjson/thirdparty/gtest/ci/travis.sh +44 -0
  115. data/ext/rj_schema/rapidjson/thirdparty/gtest/configure.ac +16 -0
  116. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +1 -1
  117. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +72 -32
  118. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +53 -42
  119. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock.pc.in +9 -0
  120. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/cmake/gmock_main.pc.in +9 -0
  121. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +4 -4
  122. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +6 -4
  123. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +117 -132
  124. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +7 -4
  125. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +20 -12
  126. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +1 -2
  127. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +83 -26
  128. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +262 -68
  129. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +45 -6
  130. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +650 -366
  131. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +76 -20
  132. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +308 -229
  133. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +18 -15
  134. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +87 -26
  135. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +33 -16
  136. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +1209 -353
  137. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +33 -0
  138. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +159 -88
  139. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +2 -1
  140. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +1 -1
  141. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +3 -4
  142. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +16 -9
  143. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +71 -8
  144. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +7 -11
  145. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +14 -0
  146. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +69 -6
  147. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +2 -2
  148. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +69 -6
  149. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +83 -8
  150. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +14 -0
  151. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +63 -2
  152. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +63 -2
  153. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +76 -3
  154. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +1 -1
  155. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +4 -5
  156. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +3 -3
  157. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +1 -1
  158. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +36 -6
  159. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +210 -135
  160. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +108 -48
  161. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +23 -1
  162. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/BUILD.bazel +123 -0
  163. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +166 -2
  164. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +1 -1
  165. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +64 -62
  166. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +43 -18
  167. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +11 -9
  168. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +91 -36
  169. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +33 -14
  170. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +1286 -167
  171. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +85 -83
  172. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +102 -15
  173. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +136 -9
  174. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +1 -1
  175. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +1 -1
  176. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +24 -2
  177. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +8 -5
  178. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +20 -1
  179. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +8 -1
  180. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +3 -2
  181. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +44 -2
  182. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +5 -7
  183. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +40 -14
  184. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +60 -31
  185. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +232 -171
  186. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest.pc.in +9 -0
  187. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/gtest_main.pc.in +10 -0
  188. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +54 -16
  189. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +1 -1
  190. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Pkgconfig.md +146 -0
  191. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +2 -2
  192. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +6 -6
  193. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{AdvancedGuide.md → advanced.md} +260 -26
  194. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{FAQ.md → faq.md} +62 -57
  195. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Primer.md → primer.md} +43 -9
  196. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/{Samples.md → samples.md} +0 -0
  197. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +53 -5
  198. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +1 -2
  199. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +30 -36
  200. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +8 -17
  201. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +140 -51
  202. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +2 -3
  203. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +4 -3
  204. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +126 -30
  205. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +6 -7
  206. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +8 -5
  207. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +6 -5
  208. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +4 -0
  209. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +13 -57
  210. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +1 -2
  211. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +98 -59
  212. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +34 -41
  213. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +3 -10
  214. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +9 -17
  215. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +8 -1
  216. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +232 -99
  217. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +3 -3
  218. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +17 -1
  219. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +17 -1
  220. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.sln +55 -0
  221. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj +149 -0
  222. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest-md.vcxproj.filters +18 -0
  223. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.sln +55 -0
  224. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj +149 -0
  225. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest.vcxproj.filters +18 -0
  226. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj +154 -0
  227. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main-md.vcxproj.filters +18 -0
  228. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj +162 -0
  229. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_main.vcxproj.filters +18 -0
  230. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj +199 -0
  231. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test-md.vcxproj.filters +26 -0
  232. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj +191 -0
  233. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_prod_test.vcxproj.filters +26 -0
  234. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj +188 -0
  235. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest-md.vcxproj.filters +18 -0
  236. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj +180 -0
  237. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/2010/gtest_unittest.vcxproj.filters +18 -0
  238. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +6 -2
  239. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +1 -1
  240. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +0 -4
  241. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +2 -1
  242. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +2 -1
  243. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +7 -6
  244. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +5 -1
  245. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +3 -3
  246. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +2 -1
  247. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +10 -22
  248. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +2 -1
  249. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +0 -3
  250. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +1 -1
  251. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +10 -10
  252. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1 -1
  253. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +1 -1
  254. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +226 -32
  255. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +5 -7
  256. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +21 -29
  257. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +85 -67
  258. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +93 -8
  259. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +1 -9
  260. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +1 -0
  261. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +622 -164
  262. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +1 -1
  263. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/BUILD.bazel +396 -0
  264. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +12 -15
  265. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +2 -12
  266. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +1 -1
  267. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +6 -8
  268. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +1 -5
  269. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +84 -29
  270. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +1 -5
  271. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +11 -12
  272. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +165 -63
  273. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +1 -1
  274. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +1 -1
  275. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +1 -1
  276. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +13 -13
  277. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_assert_by_exception_test.cc +119 -0
  278. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +1 -3
  279. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +1 -2
  280. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +0 -2
  281. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +1 -1
  282. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +1 -2
  283. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +0 -8
  284. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +6 -4
  285. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +0 -2
  286. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +0 -3
  287. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +20 -18
  288. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +0 -2
  289. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +1 -1
  290. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_outfiles_test.py +162 -0
  291. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_output_unittest.py +611 -0
  292. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_json_test_utils.py +60 -0
  293. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +4 -4
  294. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +2 -2
  295. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +11 -7
  296. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +17 -12
  297. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +104 -66
  298. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +1 -1
  299. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +2 -2
  300. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +2 -19
  301. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +0 -6
  302. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +12 -14
  303. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test.py +65 -0
  304. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_testbridge_test_.cc +44 -0
  305. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +1 -1
  306. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +4 -5
  307. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +2 -2
  308. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +240 -149
  309. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +0 -1
  310. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +0 -1
  311. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +15 -7
  312. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +100 -30
  313. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +0 -2
  314. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +25 -23
  315. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +1 -1
  316. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +1 -1
  317. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +4 -4
  318. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +47 -0
  319. data/ext/rj_schema/rapidjson/travis-doxygen.sh +13 -6
  320. data/ext/rj_schema/rj_schema.cpp +161 -17
  321. data/lib/rj_schema.rb +1 -1
  322. metadata +63 -58
  323. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DevGuide.md +0 -132
  324. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CheatSheet.md +0 -525
  325. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CookBook.md +0 -3250
  326. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/Documentation.md +0 -11
  327. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/ForDummies.md +0 -439
  328. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/FrequentlyAskedQuestions.md +0 -624
  329. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CheatSheet.md +0 -534
  330. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CookBook.md +0 -3342
  331. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/Documentation.md +0 -12
  332. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/ForDummies.md +0 -439
  333. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/FrequentlyAskedQuestions.md +0 -628
  334. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CheatSheet.md +0 -556
  335. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CookBook.md +0 -3432
  336. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/Documentation.md +0 -12
  337. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/ForDummies.md +0 -439
  338. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/FrequentlyAskedQuestions.md +0 -628
  339. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/DevGuide.md +0 -126
  340. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Documentation.md +0 -14
  341. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_AdvancedGuide.md +0 -2096
  342. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Documentation.md +0 -12
  343. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_FAQ.md +0 -886
  344. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Primer.md +0 -497
  345. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_PumpManual.md +0 -177
  346. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_XcodeGuide.md +0 -93
  347. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_AdvancedGuide.md +0 -2178
  348. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Documentation.md +0 -14
  349. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_FAQ.md +0 -1038
  350. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Primer.md +0 -501
  351. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_PumpManual.md +0 -177
  352. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Samples.md +0 -14
  353. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_XcodeGuide.md +0 -93
  354. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_AdvancedGuide.md +0 -2181
  355. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Documentation.md +0 -14
  356. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_FAQ.md +0 -1082
  357. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Primer.md +0 -501
  358. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_PumpManual.md +0 -177
  359. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Samples.md +0 -14
  360. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_XcodeGuide.md +0 -93
  361. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.sln +0 -45
  362. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.vcproj +0 -126
  363. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.sln +0 -45
  364. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.vcproj +0 -126
  365. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main-md.vcproj +0 -129
  366. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main.vcproj +0 -129
  367. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test-md.vcproj +0 -164
  368. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test.vcproj +0 -164
  369. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest-md.vcproj +0 -147
  370. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest.vcproj +0 -147
  371. data/ext/rj_schema/rapidjson/thirdparty/gtest/travis.sh +0 -15
@@ -29,7 +29,7 @@
29
29
  //
30
30
  // Author: wan@google.com (Zhanyong Wan)
31
31
 
32
- // Google Test - The Google C++ Testing Framework
32
+ // Google Test - The Google C++ Testing and Mocking Framework
33
33
  //
34
34
  // This file implements a universal value printer that can print a
35
35
  // value of any type T:
@@ -43,12 +43,13 @@
43
43
  // defines Foo.
44
44
 
45
45
  #include "gtest/gtest-printers.h"
46
- #include <ctype.h>
47
46
  #include <stdio.h>
47
+ #include <cctype>
48
48
  #include <cwchar>
49
49
  #include <ostream> // NOLINT
50
50
  #include <string>
51
51
  #include "gtest/internal/gtest-port.h"
52
+ #include "src/gtest-internal-inl.h"
52
53
 
53
54
  namespace testing {
54
55
 
@@ -123,7 +124,7 @@ namespace internal {
123
124
  // Depending on the value of a char (or wchar_t), we print it in one
124
125
  // of three formats:
125
126
  // - as is if it's a printable ASCII (e.g. 'a', '2', ' '),
126
- // - as a hexidecimal escape sequence (e.g. '\x7F'), or
127
+ // - as a hexadecimal escape sequence (e.g. '\x7F'), or
127
128
  // - as a special escape sequence (e.g. '\r', '\n').
128
129
  enum CharFormat {
129
130
  kAsIs,
@@ -180,7 +181,10 @@ static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {
180
181
  *os << static_cast<char>(c);
181
182
  return kAsIs;
182
183
  } else {
183
- *os << "\\x" + String::FormatHexInt(static_cast<UnsignedChar>(c));
184
+ ostream::fmtflags flags = os->flags();
185
+ *os << "\\x" << std::hex << std::uppercase
186
+ << static_cast<int>(static_cast<UnsignedChar>(c));
187
+ os->flags(flags);
184
188
  return kHexEscape;
185
189
  }
186
190
  }
@@ -227,7 +231,7 @@ void PrintCharAndCodeTo(Char c, ostream* os) {
227
231
  return;
228
232
  *os << " (" << static_cast<int>(c);
229
233
 
230
- // For more convenience, we print c's code again in hexidecimal,
234
+ // For more convenience, we print c's code again in hexadecimal,
231
235
  // unless c was already printed in the form '\x##' or the code is in
232
236
  // [1, 9].
233
237
  if (format == kHexEscape || (1 <= c && c <= 9)) {
@@ -259,11 +263,12 @@ template <typename CharType>
259
263
  GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
260
264
  GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
261
265
  GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
262
- static void PrintCharsAsStringTo(
266
+ static CharFormat PrintCharsAsStringTo(
263
267
  const CharType* begin, size_t len, ostream* os) {
264
268
  const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
265
269
  *os << kQuoteBegin;
266
270
  bool is_previous_hex = false;
271
+ CharFormat print_format = kAsIs;
267
272
  for (size_t index = 0; index < len; ++index) {
268
273
  const CharType cur = begin[index];
269
274
  if (is_previous_hex && IsXDigit(cur)) {
@@ -273,8 +278,13 @@ static void PrintCharsAsStringTo(
273
278
  *os << "\" " << kQuoteBegin;
274
279
  }
275
280
  is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
281
+ // Remember if any characters required hex escaping.
282
+ if (is_previous_hex) {
283
+ print_format = kHexEscape;
284
+ }
276
285
  }
277
286
  *os << "\"";
287
+ return print_format;
278
288
  }
279
289
 
280
290
  // Prints a (const) char/wchar_t array of 'len' elements, starting at address
@@ -344,15 +354,90 @@ void PrintTo(const wchar_t* s, ostream* os) {
344
354
  }
345
355
  #endif // wchar_t is native
346
356
 
357
+ namespace {
358
+
359
+ bool ContainsUnprintableControlCodes(const char* str, size_t length) {
360
+ const unsigned char *s = reinterpret_cast<const unsigned char *>(str);
361
+
362
+ for (size_t i = 0; i < length; i++) {
363
+ unsigned char ch = *s++;
364
+ if (std::iscntrl(ch)) {
365
+ switch (ch) {
366
+ case '\t':
367
+ case '\n':
368
+ case '\r':
369
+ break;
370
+ default:
371
+ return true;
372
+ }
373
+ }
374
+ }
375
+ return false;
376
+ }
377
+
378
+ bool IsUTF8TrailByte(unsigned char t) { return 0x80 <= t && t<= 0xbf; }
379
+
380
+ bool IsValidUTF8(const char* str, size_t length) {
381
+ const unsigned char *s = reinterpret_cast<const unsigned char *>(str);
382
+
383
+ for (size_t i = 0; i < length;) {
384
+ unsigned char lead = s[i++];
385
+
386
+ if (lead <= 0x7f) {
387
+ continue; // single-byte character (ASCII) 0..7F
388
+ }
389
+ if (lead < 0xc2) {
390
+ return false; // trail byte or non-shortest form
391
+ } else if (lead <= 0xdf && (i + 1) <= length && IsUTF8TrailByte(s[i])) {
392
+ ++i; // 2-byte character
393
+ } else if (0xe0 <= lead && lead <= 0xef && (i + 2) <= length &&
394
+ IsUTF8TrailByte(s[i]) &&
395
+ IsUTF8TrailByte(s[i + 1]) &&
396
+ // check for non-shortest form and surrogate
397
+ (lead != 0xe0 || s[i] >= 0xa0) &&
398
+ (lead != 0xed || s[i] < 0xa0)) {
399
+ i += 2; // 3-byte character
400
+ } else if (0xf0 <= lead && lead <= 0xf4 && (i + 3) <= length &&
401
+ IsUTF8TrailByte(s[i]) &&
402
+ IsUTF8TrailByte(s[i + 1]) &&
403
+ IsUTF8TrailByte(s[i + 2]) &&
404
+ // check for non-shortest form
405
+ (lead != 0xf0 || s[i] >= 0x90) &&
406
+ (lead != 0xf4 || s[i] < 0x90)) {
407
+ i += 3; // 4-byte character
408
+ } else {
409
+ return false;
410
+ }
411
+ }
412
+ return true;
413
+ }
414
+
415
+ void ConditionalPrintAsText(const char* str, size_t length, ostream* os) {
416
+ if (!ContainsUnprintableControlCodes(str, length) &&
417
+ IsValidUTF8(str, length)) {
418
+ *os << "\n As Text: \"" << str << "\"";
419
+ }
420
+ }
421
+
422
+ } // anonymous namespace
423
+
347
424
  // Prints a ::string object.
348
425
  #if GTEST_HAS_GLOBAL_STRING
349
426
  void PrintStringTo(const ::string& s, ostream* os) {
350
- PrintCharsAsStringTo(s.data(), s.size(), os);
427
+ if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
428
+ if (GTEST_FLAG(print_utf8)) {
429
+ ConditionalPrintAsText(s.data(), s.size(), os);
430
+ }
431
+ }
351
432
  }
352
433
  #endif // GTEST_HAS_GLOBAL_STRING
353
434
 
354
435
  void PrintStringTo(const ::std::string& s, ostream* os) {
355
- PrintCharsAsStringTo(s.data(), s.size(), os);
436
+ if (PrintCharsAsStringTo(s.data(), s.size(), os) == kHexEscape) {
437
+ if (GTEST_FLAG(print_utf8)) {
438
+ ConditionalPrintAsText(s.data(), s.size(), os);
439
+ }
440
+ }
356
441
  }
357
442
 
358
443
  // Prints a ::wstring object.
@@ -29,18 +29,10 @@
29
29
  //
30
30
  // Author: mheule@google.com (Markus Heule)
31
31
  //
32
- // The Google C++ Testing Framework (Google Test)
32
+ // The Google C++ Testing and Mocking Framework (Google Test)
33
33
 
34
34
  #include "gtest/gtest-test-part.h"
35
-
36
- // Indicates that this translation unit is part of Google Test's
37
- // implementation. It must come before gtest-internal-inl.h is
38
- // included, or there will be a compiler error. This trick exists to
39
- // prevent the accidental inclusion of gtest-internal-inl.h in the
40
- // user's code.
41
- #define GTEST_IMPLEMENTATION_ 1
42
35
  #include "src/gtest-internal-inl.h"
43
- #undef GTEST_IMPLEMENTATION_
44
36
 
45
37
  namespace testing {
46
38
 
@@ -30,6 +30,7 @@
30
30
  // Author: wan@google.com (Zhanyong Wan)
31
31
 
32
32
  #include "gtest/gtest-typed-test.h"
33
+
33
34
  #include "gtest/gtest.h"
34
35
 
35
36
  namespace testing {
@@ -29,7 +29,7 @@
29
29
  //
30
30
  // Author: wan@google.com (Zhanyong Wan)
31
31
  //
32
- // The Google C++ Testing Framework (Google Test)
32
+ // The Google C++ Testing and Mocking Framework (Google Test)
33
33
 
34
34
  #include "gtest/gtest.h"
35
35
  #include "gtest/internal/custom/gtest.h"
@@ -133,14 +133,7 @@
133
133
  # include <sys/types.h> // NOLINT
134
134
  #endif
135
135
 
136
- // Indicates that this translation unit is part of Google Test's
137
- // implementation. It must come before gtest-internal-inl.h is
138
- // included, or there will be a compiler error. This trick is to
139
- // prevent a user from accidentally including gtest-internal-inl.h in
140
- // his code.
141
- #define GTEST_IMPLEMENTATION_ 1
142
136
  #include "src/gtest-internal-inl.h"
143
- #undef GTEST_IMPLEMENTATION_
144
137
 
145
138
  #if GTEST_OS_WINDOWS
146
139
  # define vsnprintf _vsnprintf
@@ -167,8 +160,10 @@ static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
167
160
  // A test filter that matches everything.
168
161
  static const char kUniversalFilter[] = "*";
169
162
 
170
- // The default output file for XML output.
171
- static const char kDefaultOutputFile[] = "test_detail.xml";
163
+ // The default output format.
164
+ static const char kDefaultOutputFormat[] = "xml";
165
+ // The default output file.
166
+ static const char kDefaultOutputFile[] = "test_detail";
172
167
 
173
168
  // The environment variable name for the test shard index.
174
169
  static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
@@ -189,13 +184,14 @@ bool g_help_flag = false;
189
184
 
190
185
  } // namespace internal
191
186
 
187
+ // Bazel passes in the argument to '--test_filter' via the TESTBRIDGE_TEST_ONLY
188
+ // environment variable.
192
189
  static const char* GetDefaultFilter() {
193
- #ifdef GTEST_TEST_FILTER_ENV_VAR_
194
- const char* const testbridge_test_only = getenv(GTEST_TEST_FILTER_ENV_VAR_);
190
+ const char* const testbridge_test_only =
191
+ internal::posix::GetEnv("TESTBRIDGE_TEST_ONLY");
195
192
  if (testbridge_test_only != NULL) {
196
193
  return testbridge_test_only;
197
194
  }
198
- #endif // GTEST_TEST_FILTER_ENV_VAR_
199
195
  return kUniversalFilter;
200
196
  }
201
197
 
@@ -235,12 +231,18 @@ GTEST_DEFINE_string_(
235
231
  GTEST_DEFINE_bool_(list_tests, false,
236
232
  "List all tests without running them.");
237
233
 
234
+ // The net priority order after flag processing is thus:
235
+ // --gtest_output command line flag
236
+ // GTEST_OUTPUT environment variable
237
+ // XML_OUTPUT_FILE environment variable
238
+ // ''
238
239
  GTEST_DEFINE_string_(
239
240
  output,
240
- internal::StringFromGTestEnv("output", ""),
241
- "A format (currently must be \"xml\"), optionally followed "
242
- "by a colon and an output file name or directory. A directory "
243
- "is indicated by a trailing pathname separator. "
241
+ internal::StringFromGTestEnv("output",
242
+ internal::OutputFlagAlsoCheckEnvVar().c_str()),
243
+ "A format (defaults to \"xml\" but can be specified to be \"json\"), "
244
+ "optionally followed by a colon and an output file name or directory. "
245
+ "A directory is indicated by a trailing pathname separator. "
244
246
  "Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
245
247
  "If a directory is specified, output files will be created "
246
248
  "within that directory, with file-names based on the test "
@@ -253,6 +255,12 @@ GTEST_DEFINE_bool_(
253
255
  "True iff " GTEST_NAME_
254
256
  " should display elapsed time in text output.");
255
257
 
258
+ GTEST_DEFINE_bool_(
259
+ print_utf8,
260
+ internal::BoolFromGTestEnv("print_utf8", true),
261
+ "True iff " GTEST_NAME_
262
+ " prints UTF8 characters as text.");
263
+
256
264
  GTEST_DEFINE_int32_(
257
265
  random_seed,
258
266
  internal::Int32FromGTestEnv("random_seed", 0),
@@ -294,7 +302,7 @@ GTEST_DEFINE_bool_(
294
302
  internal::BoolFromGTestEnv("throw_on_failure", false),
295
303
  "When this flag is specified, a failed assertion will throw an exception "
296
304
  "if exceptions are enabled or exit the program with a non-zero code "
297
- "otherwise.");
305
+ "otherwise. For use with an external test framework.");
298
306
 
299
307
  #if GTEST_USE_OWN_FLAGFILE_FLAG_
300
308
  GTEST_DEFINE_string_(
@@ -310,7 +318,8 @@ namespace internal {
310
318
  // than kMaxRange.
311
319
  UInt32 Random::Generate(UInt32 range) {
312
320
  // These constants are the same as are used in glibc's rand(3).
313
- state_ = (1103515245U*state_ + 12345U) % kMaxRange;
321
+ // Use wider types than necessary to prevent unsigned overflow diagnostics.
322
+ state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange;
314
323
 
315
324
  GTEST_CHECK_(range > 0)
316
325
  << "Cannot generate a number in the range [0, 0).";
@@ -384,12 +393,15 @@ void AssertHelper::operator=(const Message& message) const {
384
393
  GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
385
394
 
386
395
  // A copy of all command line arguments. Set by InitGoogleTest().
387
- ::std::vector<testing::internal::string> g_argvs;
396
+ ::std::vector<std::string> g_argvs;
388
397
 
389
- const ::std::vector<testing::internal::string>& GetArgvs() {
398
+ ::std::vector<std::string> GetArgvs() {
390
399
  #if defined(GTEST_CUSTOM_GET_ARGVS_)
391
- return GTEST_CUSTOM_GET_ARGVS_();
392
- #else // defined(GTEST_CUSTOM_GET_ARGVS_)
400
+ // GTEST_CUSTOM_GET_ARGVS_() may return a container of std::string or
401
+ // ::string. This code converts it to the appropriate type.
402
+ const auto& custom = GTEST_CUSTOM_GET_ARGVS_();
403
+ return ::std::vector<std::string>(custom.begin(), custom.end());
404
+ #else // defined(GTEST_CUSTOM_GET_ARGVS_)
393
405
  return g_argvs;
394
406
  #endif // defined(GTEST_CUSTOM_GET_ARGVS_)
395
407
  }
@@ -428,12 +440,17 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
428
440
  if (gtest_output_flag == NULL)
429
441
  return "";
430
442
 
443
+ std::string format = GetOutputFormat();
444
+ if (format.empty())
445
+ format = std::string(kDefaultOutputFormat);
446
+
431
447
  const char* const colon = strchr(gtest_output_flag, ':');
432
448
  if (colon == NULL)
433
- return internal::FilePath::ConcatPaths(
449
+ return internal::FilePath::MakeFileName(
434
450
  internal::FilePath(
435
451
  UnitTest::GetInstance()->original_working_dir()),
436
- internal::FilePath(kDefaultOutputFile)).string();
452
+ internal::FilePath(kDefaultOutputFile), 0,
453
+ format.c_str()).string();
437
454
 
438
455
  internal::FilePath output_name(colon + 1);
439
456
  if (!output_name.IsAbsolutePath())
@@ -628,12 +645,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
628
645
  // This predicate-formatter checks that 'results' contains a test part
629
646
  // failure of the given type and that the failure message contains the
630
647
  // given substring.
631
- AssertionResult HasOneFailure(const char* /* results_expr */,
632
- const char* /* type_expr */,
633
- const char* /* substr_expr */,
634
- const TestPartResultArray& results,
635
- TestPartResult::Type type,
636
- const string& substr) {
648
+ static AssertionResult HasOneFailure(const char* /* results_expr */,
649
+ const char* /* type_expr */,
650
+ const char* /* substr_expr */,
651
+ const TestPartResultArray& results,
652
+ TestPartResult::Type type,
653
+ const std::string& substr) {
637
654
  const std::string expected(type == TestPartResult::kFatalFailure ?
638
655
  "1 fatal failure" :
639
656
  "1 non-fatal failure");
@@ -667,13 +684,10 @@ AssertionResult HasOneFailure(const char* /* results_expr */,
667
684
  // The constructor of SingleFailureChecker remembers where to look up
668
685
  // test part results, what type of failure we expect, and what
669
686
  // substring the failure message should contain.
670
- SingleFailureChecker:: SingleFailureChecker(
671
- const TestPartResultArray* results,
672
- TestPartResult::Type type,
673
- const string& substr)
674
- : results_(results),
675
- type_(type),
676
- substr_(substr) {}
687
+ SingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results,
688
+ TestPartResult::Type type,
689
+ const std::string& substr)
690
+ : results_(results), type_(type), substr_(substr) {}
677
691
 
678
692
  // The destructor of SingleFailureChecker verifies that the given
679
693
  // TestPartResultArray contains exactly one failure that has the given
@@ -1171,7 +1185,7 @@ class Hunk {
1171
1185
  // Print a unified diff header for one hunk.
1172
1186
  // The format is
1173
1187
  // "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
1174
- // where the left/right parts are ommitted if unnecessary.
1188
+ // where the left/right parts are omitted if unnecessary.
1175
1189
  void PrintHeader(std::ostream* ss) const {
1176
1190
  *ss << "@@ ";
1177
1191
  if (removes_) {
@@ -1315,13 +1329,14 @@ AssertionResult EqFailure(const char* lhs_expression,
1315
1329
  const std::string& rhs_value,
1316
1330
  bool ignoring_case) {
1317
1331
  Message msg;
1318
- msg << " Expected: " << lhs_expression;
1332
+ msg << "Expected equality of these values:";
1333
+ msg << "\n " << lhs_expression;
1319
1334
  if (lhs_value != lhs_expression) {
1320
- msg << "\n Which is: " << lhs_value;
1335
+ msg << "\n Which is: " << lhs_value;
1321
1336
  }
1322
- msg << "\nTo be equal to: " << rhs_expression;
1337
+ msg << "\n " << rhs_expression;
1323
1338
  if (rhs_value != rhs_expression) {
1324
- msg << "\n Which is: " << rhs_value;
1339
+ msg << "\n Which is: " << rhs_value;
1325
1340
  }
1326
1341
 
1327
1342
  if (ignoring_case) {
@@ -1663,7 +1678,7 @@ namespace {
1663
1678
  AssertionResult HRESULTFailureHelper(const char* expr,
1664
1679
  const char* expected,
1665
1680
  long hr) { // NOLINT
1666
- # if GTEST_OS_WINDOWS_MOBILE
1681
+ # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE
1667
1682
 
1668
1683
  // Windows CE doesn't support FormatMessage.
1669
1684
  const char error_text[] = "";
@@ -1720,7 +1735,7 @@ AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT
1720
1735
  // Utility functions for encoding Unicode text (wide strings) in
1721
1736
  // UTF-8.
1722
1737
 
1723
- // A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
1738
+ // A Unicode code-point can have up to 21 bits, and is encoded in UTF-8
1724
1739
  // like this:
1725
1740
  //
1726
1741
  // Code-point length Encoding
@@ -1784,7 +1799,7 @@ std::string CodePointToUtf8(UInt32 code_point) {
1784
1799
  return str;
1785
1800
  }
1786
1801
 
1787
- // The following two functions only make sense if the the system
1802
+ // The following two functions only make sense if the system
1788
1803
  // uses UTF-16 for wide string encoding. All supported systems
1789
1804
  // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
1790
1805
 
@@ -2138,8 +2153,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) {
2138
2153
  return word_list.GetString();
2139
2154
  }
2140
2155
 
2141
- bool ValidateTestPropertyName(const std::string& property_name,
2142
- const std::vector<std::string>& reserved_names) {
2156
+ static bool ValidateTestPropertyName(
2157
+ const std::string& property_name,
2158
+ const std::vector<std::string>& reserved_names) {
2143
2159
  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
2144
2160
  reserved_names.end()) {
2145
2161
  ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name
@@ -2436,6 +2452,8 @@ Result HandleExceptionsInMethodIfSupported(
2436
2452
  #if GTEST_HAS_EXCEPTIONS
2437
2453
  try {
2438
2454
  return HandleSehExceptionsInMethodIfSupported(object, method, location);
2455
+ } catch (const AssertionException&) { // NOLINT
2456
+ // This failure was reported already.
2439
2457
  } catch (const internal::GoogleTestFailureException&) { // NOLINT
2440
2458
  // This exception type can only be thrown by a failed Google
2441
2459
  // Test assertion with the intention of letting another testing
@@ -2557,7 +2575,6 @@ TestInfo* MakeAndRegisterTestInfo(
2557
2575
  return test_info;
2558
2576
  }
2559
2577
 
2560
- #if GTEST_HAS_PARAM_TEST
2561
2578
  void ReportInvalidTestCaseType(const char* test_case_name,
2562
2579
  CodeLocation code_location) {
2563
2580
  Message errors;
@@ -2571,13 +2588,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
2571
2588
  << "probably rename one of the classes to put the tests into different\n"
2572
2589
  << "test cases.";
2573
2590
 
2574
- fprintf(stderr, "%s %s",
2575
- FormatFileLocation(code_location.file.c_str(),
2576
- code_location.line).c_str(),
2577
- errors.GetString().c_str());
2591
+ GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(),
2592
+ code_location.line)
2593
+ << " " << errors.GetString();
2578
2594
  }
2579
- #endif // GTEST_HAS_PARAM_TEST
2580
-
2581
2595
  } // namespace internal
2582
2596
 
2583
2597
  namespace {
@@ -2615,12 +2629,10 @@ namespace internal {
2615
2629
  // and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
2616
2630
  // This will be done just once during the program runtime.
2617
2631
  void UnitTestImpl::RegisterParameterizedTests() {
2618
- #if GTEST_HAS_PARAM_TEST
2619
2632
  if (!parameterized_tests_registered_) {
2620
2633
  parameterized_test_registry_.RegisterTests();
2621
2634
  parameterized_tests_registered_ = true;
2622
2635
  }
2623
- #endif
2624
2636
  }
2625
2637
 
2626
2638
  } // namespace internal
@@ -2885,10 +2897,10 @@ enum GTestColor {
2885
2897
  };
2886
2898
 
2887
2899
  #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
2888
- !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
2900
+ !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
2889
2901
 
2890
2902
  // Returns the character attribute for the given color.
2891
- WORD GetColorAttribute(GTestColor color) {
2903
+ static WORD GetColorAttribute(GTestColor color) {
2892
2904
  switch (color) {
2893
2905
  case COLOR_RED: return FOREGROUND_RED;
2894
2906
  case COLOR_GREEN: return FOREGROUND_GREEN;
@@ -2897,11 +2909,42 @@ WORD GetColorAttribute(GTestColor color) {
2897
2909
  }
2898
2910
  }
2899
2911
 
2912
+ static int GetBitOffset(WORD color_mask) {
2913
+ if (color_mask == 0) return 0;
2914
+
2915
+ int bitOffset = 0;
2916
+ while ((color_mask & 1) == 0) {
2917
+ color_mask >>= 1;
2918
+ ++bitOffset;
2919
+ }
2920
+ return bitOffset;
2921
+ }
2922
+
2923
+ static WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
2924
+ // Let's reuse the BG
2925
+ static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |
2926
+ BACKGROUND_RED | BACKGROUND_INTENSITY;
2927
+ static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |
2928
+ FOREGROUND_RED | FOREGROUND_INTENSITY;
2929
+ const WORD existing_bg = old_color_attrs & background_mask;
2930
+
2931
+ WORD new_color =
2932
+ GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
2933
+ static const int bg_bitOffset = GetBitOffset(background_mask);
2934
+ static const int fg_bitOffset = GetBitOffset(foreground_mask);
2935
+
2936
+ if (((new_color & background_mask) >> bg_bitOffset) ==
2937
+ ((new_color & foreground_mask) >> fg_bitOffset)) {
2938
+ new_color ^= FOREGROUND_INTENSITY; // invert intensity
2939
+ }
2940
+ return new_color;
2941
+ }
2942
+
2900
2943
  #else
2901
2944
 
2902
2945
  // Returns the ANSI color code for the given color. COLOR_DEFAULT is
2903
2946
  // an invalid input.
2904
- const char* GetAnsiColorCode(GTestColor color) {
2947
+ static const char* GetAnsiColorCode(GTestColor color) {
2905
2948
  switch (color) {
2906
2949
  case COLOR_RED: return "1";
2907
2950
  case COLOR_GREEN: return "2";
@@ -2917,7 +2960,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
2917
2960
  const char* const gtest_color = GTEST_FLAG(color).c_str();
2918
2961
 
2919
2962
  if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
2920
- #if GTEST_OS_WINDOWS
2963
+ #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
2921
2964
  // On Windows the TERM variable is usually not set, but the
2922
2965
  // console there does support colors.
2923
2966
  return stdout_is_tty;
@@ -2953,7 +2996,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
2953
2996
  // cannot simply emit special characters and have the terminal change colors.
2954
2997
  // This routine must actually emit the characters rather than return a string
2955
2998
  // that would be colored when printed, as can be done on Linux.
2956
- void ColoredPrintf(GTestColor color, const char* fmt, ...) {
2999
+ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
2957
3000
  va_list args;
2958
3001
  va_start(args, fmt);
2959
3002
 
@@ -2974,20 +3017,21 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
2974
3017
  }
2975
3018
 
2976
3019
  #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
2977
- !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
3020
+ !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
2978
3021
  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
2979
3022
 
2980
3023
  // Gets the current text color.
2981
3024
  CONSOLE_SCREEN_BUFFER_INFO buffer_info;
2982
3025
  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
2983
3026
  const WORD old_color_attrs = buffer_info.wAttributes;
3027
+ const WORD new_color = GetNewColor(color, old_color_attrs);
2984
3028
 
2985
3029
  // We need to flush the stream buffers into the console before each
2986
3030
  // SetConsoleTextAttribute call lest it affect the text that is already
2987
3031
  // printed but has not yet reached the console.
2988
3032
  fflush(stdout);
2989
- SetConsoleTextAttribute(stdout_handle,
2990
- GetColorAttribute(color) | FOREGROUND_INTENSITY);
3033
+ SetConsoleTextAttribute(stdout_handle, new_color);
3034
+
2991
3035
  vprintf(fmt, args);
2992
3036
 
2993
3037
  fflush(stdout);
@@ -3001,12 +3045,12 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
3001
3045
  va_end(args);
3002
3046
  }
3003
3047
 
3004
- // Text printed in Google Test's text output and --gunit_list_tests
3048
+ // Text printed in Google Test's text output and --gtest_list_tests
3005
3049
  // output to label the type parameter and value parameter for a test.
3006
3050
  static const char kTypeParamLabel[] = "TypeParam";
3007
3051
  static const char kValueParamLabel[] = "GetParam()";
3008
3052
 
3009
- void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
3053
+ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
3010
3054
  const char* const type_param = test_info.type_param();
3011
3055
  const char* const value_param = test_info.value_param();
3012
3056
 
@@ -3080,7 +3124,6 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
3080
3124
  "Note: Randomizing tests' orders with a seed of %d .\n",
3081
3125
  unit_test.random_seed());
3082
3126
  }
3083
-
3084
3127
  ColoredPrintf(COLOR_GREEN, "[==========] ");
3085
3128
  printf("Running %s from %s.\n",
3086
3129
  FormatTestCount(unit_test.test_to_run_count()).c_str(),
@@ -3412,6 +3455,11 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
3412
3455
  // to delimit this attribute from prior attributes.
3413
3456
  static std::string TestPropertiesAsXmlAttributes(const TestResult& result);
3414
3457
 
3458
+ // Streams an XML representation of the test properties of a TestResult
3459
+ // object.
3460
+ static void OutputXmlTestProperties(std::ostream* stream,
3461
+ const TestResult& result);
3462
+
3415
3463
  // The output file.
3416
3464
  const std::string output_file_;
3417
3465
 
@@ -3422,9 +3470,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
3422
3470
  XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
3423
3471
  : output_file_(output_file) {
3424
3472
  if (output_file_.c_str() == NULL || output_file_.empty()) {
3425
- fprintf(stderr, "XML output file may not be null\n");
3426
- fflush(stderr);
3427
- exit(EXIT_FAILURE);
3473
+ GTEST_LOG_(FATAL) << "XML output file may not be null";
3428
3474
  }
3429
3475
  }
3430
3476
 
@@ -3449,11 +3495,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
3449
3495
  // 3. To interpret the meaning of errno in a thread-safe way,
3450
3496
  // we need the strerror_r() function, which is not available on
3451
3497
  // Windows.
3452
- fprintf(stderr,
3453
- "Unable to open file \"%s\"\n",
3454
- output_file_.c_str());
3455
- fflush(stderr);
3456
- exit(EXIT_FAILURE);
3498
+
3499
+ GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file_ << "\"";
3457
3500
  }
3458
3501
  std::stringstream stream;
3459
3502
  PrintXmlUnitTest(&stream, unit_test);
@@ -3628,6 +3671,10 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
3628
3671
  const TestResult& result = *test_info.result();
3629
3672
  const std::string kTestcase = "testcase";
3630
3673
 
3674
+ if (test_info.is_in_another_shard()) {
3675
+ return;
3676
+ }
3677
+
3631
3678
  *stream << " <testcase";
3632
3679
  OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
3633
3680
 
@@ -3644,7 +3691,6 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
3644
3691
  OutputXmlAttribute(stream, kTestcase, "time",
3645
3692
  FormatTimeInMillisAsSeconds(result.elapsed_time()));
3646
3693
  OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
3647
- *stream << TestPropertiesAsXmlAttributes(result);
3648
3694
 
3649
3695
  int failures = 0;
3650
3696
  for (int i = 0; i < result.total_part_count(); ++i) {
@@ -3653,22 +3699,28 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
3653
3699
  if (++failures == 1) {
3654
3700
  *stream << ">\n";
3655
3701
  }
3656
- const string location = internal::FormatCompilerIndependentFileLocation(
3657
- part.file_name(), part.line_number());
3658
- const string summary = location + "\n" + part.summary();
3702
+ const std::string location =
3703
+ internal::FormatCompilerIndependentFileLocation(part.file_name(),
3704
+ part.line_number());
3705
+ const std::string summary = location + "\n" + part.summary();
3659
3706
  *stream << " <failure message=\""
3660
3707
  << EscapeXmlAttribute(summary.c_str())
3661
3708
  << "\" type=\"\">";
3662
- const string detail = location + "\n" + part.message();
3709
+ const std::string detail = location + "\n" + part.message();
3663
3710
  OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
3664
3711
  *stream << "</failure>\n";
3665
3712
  }
3666
3713
  }
3667
3714
 
3668
- if (failures == 0)
3715
+ if (failures == 0 && result.test_property_count() == 0) {
3669
3716
  *stream << " />\n";
3670
- else
3717
+ } else {
3718
+ if (failures == 0) {
3719
+ *stream << ">\n";
3720
+ }
3721
+ OutputXmlTestProperties(stream, result);
3671
3722
  *stream << " </testcase>\n";
3723
+ }
3672
3724
  }
3673
3725
 
3674
3726
  // Prints an XML representation of a TestCase object
@@ -3723,7 +3775,6 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
3723
3775
  OutputXmlAttribute(stream, kTestsuites, "random_seed",
3724
3776
  StreamableToString(unit_test.random_seed()));
3725
3777
  }
3726
-
3727
3778
  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
3728
3779
 
3729
3780
  OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
@@ -3749,8 +3800,374 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
3749
3800
  return attributes.GetString();
3750
3801
  }
3751
3802
 
3803
+ void XmlUnitTestResultPrinter::OutputXmlTestProperties(
3804
+ std::ostream* stream, const TestResult& result) {
3805
+ const std::string kProperties = "properties";
3806
+ const std::string kProperty = "property";
3807
+
3808
+ if (result.test_property_count() <= 0) {
3809
+ return;
3810
+ }
3811
+
3812
+ *stream << "<" << kProperties << ">\n";
3813
+ for (int i = 0; i < result.test_property_count(); ++i) {
3814
+ const TestProperty& property = result.GetTestProperty(i);
3815
+ *stream << "<" << kProperty;
3816
+ *stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
3817
+ *stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
3818
+ *stream << "/>\n";
3819
+ }
3820
+ *stream << "</" << kProperties << ">\n";
3821
+ }
3822
+
3752
3823
  // End XmlUnitTestResultPrinter
3753
3824
 
3825
+
3826
+ // This class generates an JSON output file.
3827
+ class JsonUnitTestResultPrinter : public EmptyTestEventListener {
3828
+ public:
3829
+ explicit JsonUnitTestResultPrinter(const char* output_file);
3830
+
3831
+ virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
3832
+
3833
+ private:
3834
+ // Returns an JSON-escaped copy of the input string str.
3835
+ static std::string EscapeJson(const std::string& str);
3836
+
3837
+ //// Verifies that the given attribute belongs to the given element and
3838
+ //// streams the attribute as JSON.
3839
+ static void OutputJsonKey(std::ostream* stream,
3840
+ const std::string& element_name,
3841
+ const std::string& name,
3842
+ const std::string& value,
3843
+ const std::string& indent,
3844
+ bool comma = true);
3845
+ static void OutputJsonKey(std::ostream* stream,
3846
+ const std::string& element_name,
3847
+ const std::string& name,
3848
+ int value,
3849
+ const std::string& indent,
3850
+ bool comma = true);
3851
+
3852
+ // Streams a JSON representation of a TestInfo object.
3853
+ static void OutputJsonTestInfo(::std::ostream* stream,
3854
+ const char* test_case_name,
3855
+ const TestInfo& test_info);
3856
+
3857
+ // Prints a JSON representation of a TestCase object
3858
+ static void PrintJsonTestCase(::std::ostream* stream,
3859
+ const TestCase& test_case);
3860
+
3861
+ // Prints a JSON summary of unit_test to output stream out.
3862
+ static void PrintJsonUnitTest(::std::ostream* stream,
3863
+ const UnitTest& unit_test);
3864
+
3865
+ // Produces a string representing the test properties in a result as
3866
+ // a JSON dictionary.
3867
+ static std::string TestPropertiesAsJson(const TestResult& result,
3868
+ const std::string& indent);
3869
+
3870
+ // The output file.
3871
+ const std::string output_file_;
3872
+
3873
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter);
3874
+ };
3875
+
3876
+ // Creates a new JsonUnitTestResultPrinter.
3877
+ JsonUnitTestResultPrinter::JsonUnitTestResultPrinter(const char* output_file)
3878
+ : output_file_(output_file) {
3879
+ if (output_file_.empty()) {
3880
+ GTEST_LOG_(FATAL) << "JSON output file may not be null";
3881
+ }
3882
+ }
3883
+
3884
+ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
3885
+ int /*iteration*/) {
3886
+ FILE* jsonout = NULL;
3887
+ FilePath output_file(output_file_);
3888
+ FilePath output_dir(output_file.RemoveFileName());
3889
+
3890
+ if (output_dir.CreateDirectoriesRecursively()) {
3891
+ jsonout = posix::FOpen(output_file_.c_str(), "w");
3892
+ }
3893
+ if (jsonout == NULL) {
3894
+ // TODO(phosek): report the reason of the failure.
3895
+ //
3896
+ // We don't do it for now as:
3897
+ //
3898
+ // 1. There is no urgent need for it.
3899
+ // 2. It's a bit involved to make the errno variable thread-safe on
3900
+ // all three operating systems (Linux, Windows, and Mac OS).
3901
+ // 3. To interpret the meaning of errno in a thread-safe way,
3902
+ // we need the strerror_r() function, which is not available on
3903
+ // Windows.
3904
+ GTEST_LOG_(FATAL) << "Unable to open file \""
3905
+ << output_file_ << "\"";
3906
+ }
3907
+ std::stringstream stream;
3908
+ PrintJsonUnitTest(&stream, unit_test);
3909
+ fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
3910
+ fclose(jsonout);
3911
+ }
3912
+
3913
+ // Returns an JSON-escaped copy of the input string str.
3914
+ std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {
3915
+ Message m;
3916
+
3917
+ for (size_t i = 0; i < str.size(); ++i) {
3918
+ const char ch = str[i];
3919
+ switch (ch) {
3920
+ case '\\':
3921
+ case '"':
3922
+ case '/':
3923
+ m << '\\' << ch;
3924
+ break;
3925
+ case '\b':
3926
+ m << "\\b";
3927
+ break;
3928
+ case '\t':
3929
+ m << "\\t";
3930
+ break;
3931
+ case '\n':
3932
+ m << "\\n";
3933
+ break;
3934
+ case '\f':
3935
+ m << "\\f";
3936
+ break;
3937
+ case '\r':
3938
+ m << "\\r";
3939
+ break;
3940
+ default:
3941
+ if (ch < ' ') {
3942
+ m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
3943
+ } else {
3944
+ m << ch;
3945
+ }
3946
+ break;
3947
+ }
3948
+ }
3949
+
3950
+ return m.GetString();
3951
+ }
3952
+
3953
+ // The following routines generate an JSON representation of a UnitTest
3954
+ // object.
3955
+
3956
+ // Formats the given time in milliseconds as seconds.
3957
+ static std::string FormatTimeInMillisAsDuration(TimeInMillis ms) {
3958
+ ::std::stringstream ss;
3959
+ ss << (static_cast<double>(ms) * 1e-3) << "s";
3960
+ return ss.str();
3961
+ }
3962
+
3963
+ // Converts the given epoch time in milliseconds to a date string in the
3964
+ // RFC3339 format, without the timezone information.
3965
+ static std::string FormatEpochTimeInMillisAsRFC3339(TimeInMillis ms) {
3966
+ struct tm time_struct;
3967
+ if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
3968
+ return "";
3969
+ // YYYY-MM-DDThh:mm:ss
3970
+ return StreamableToString(time_struct.tm_year + 1900) + "-" +
3971
+ String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
3972
+ String::FormatIntWidth2(time_struct.tm_mday) + "T" +
3973
+ String::FormatIntWidth2(time_struct.tm_hour) + ":" +
3974
+ String::FormatIntWidth2(time_struct.tm_min) + ":" +
3975
+ String::FormatIntWidth2(time_struct.tm_sec) + "Z";
3976
+ }
3977
+
3978
+ static inline std::string Indent(int width) {
3979
+ return std::string(width, ' ');
3980
+ }
3981
+
3982
+ void JsonUnitTestResultPrinter::OutputJsonKey(
3983
+ std::ostream* stream,
3984
+ const std::string& element_name,
3985
+ const std::string& name,
3986
+ const std::string& value,
3987
+ const std::string& indent,
3988
+ bool comma) {
3989
+ const std::vector<std::string>& allowed_names =
3990
+ GetReservedAttributesForElement(element_name);
3991
+
3992
+ GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
3993
+ allowed_names.end())
3994
+ << "Key \"" << name << "\" is not allowed for value \"" << element_name
3995
+ << "\".";
3996
+
3997
+ *stream << indent << "\"" << name << "\": \"" << EscapeJson(value) << "\"";
3998
+ if (comma)
3999
+ *stream << ",\n";
4000
+ }
4001
+
4002
+ void JsonUnitTestResultPrinter::OutputJsonKey(
4003
+ std::ostream* stream,
4004
+ const std::string& element_name,
4005
+ const std::string& name,
4006
+ int value,
4007
+ const std::string& indent,
4008
+ bool comma) {
4009
+ const std::vector<std::string>& allowed_names =
4010
+ GetReservedAttributesForElement(element_name);
4011
+
4012
+ GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
4013
+ allowed_names.end())
4014
+ << "Key \"" << name << "\" is not allowed for value \"" << element_name
4015
+ << "\".";
4016
+
4017
+ *stream << indent << "\"" << name << "\": " << StreamableToString(value);
4018
+ if (comma)
4019
+ *stream << ",\n";
4020
+ }
4021
+
4022
+ // Prints a JSON representation of a TestInfo object.
4023
+ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream,
4024
+ const char* test_case_name,
4025
+ const TestInfo& test_info) {
4026
+ const TestResult& result = *test_info.result();
4027
+ const std::string kTestcase = "testcase";
4028
+ const std::string kIndent = Indent(10);
4029
+
4030
+ *stream << Indent(8) << "{\n";
4031
+ OutputJsonKey(stream, kTestcase, "name", test_info.name(), kIndent);
4032
+
4033
+ if (test_info.value_param() != NULL) {
4034
+ OutputJsonKey(stream, kTestcase, "value_param",
4035
+ test_info.value_param(), kIndent);
4036
+ }
4037
+ if (test_info.type_param() != NULL) {
4038
+ OutputJsonKey(stream, kTestcase, "type_param", test_info.type_param(),
4039
+ kIndent);
4040
+ }
4041
+
4042
+ OutputJsonKey(stream, kTestcase, "status",
4043
+ test_info.should_run() ? "RUN" : "NOTRUN", kIndent);
4044
+ OutputJsonKey(stream, kTestcase, "time",
4045
+ FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent);
4046
+ OutputJsonKey(stream, kTestcase, "classname", test_case_name, kIndent, false);
4047
+ *stream << TestPropertiesAsJson(result, kIndent);
4048
+
4049
+ int failures = 0;
4050
+ for (int i = 0; i < result.total_part_count(); ++i) {
4051
+ const TestPartResult& part = result.GetTestPartResult(i);
4052
+ if (part.failed()) {
4053
+ *stream << ",\n";
4054
+ if (++failures == 1) {
4055
+ *stream << kIndent << "\"" << "failures" << "\": [\n";
4056
+ }
4057
+ const std::string location =
4058
+ internal::FormatCompilerIndependentFileLocation(part.file_name(),
4059
+ part.line_number());
4060
+ const std::string message = EscapeJson(location + "\n" + part.message());
4061
+ *stream << kIndent << " {\n"
4062
+ << kIndent << " \"failure\": \"" << message << "\",\n"
4063
+ << kIndent << " \"type\": \"\"\n"
4064
+ << kIndent << " }";
4065
+ }
4066
+ }
4067
+
4068
+ if (failures > 0)
4069
+ *stream << "\n" << kIndent << "]";
4070
+ *stream << "\n" << Indent(8) << "}";
4071
+ }
4072
+
4073
+ // Prints an JSON representation of a TestCase object
4074
+ void JsonUnitTestResultPrinter::PrintJsonTestCase(std::ostream* stream,
4075
+ const TestCase& test_case) {
4076
+ const std::string kTestsuite = "testsuite";
4077
+ const std::string kIndent = Indent(6);
4078
+
4079
+ *stream << Indent(4) << "{\n";
4080
+ OutputJsonKey(stream, kTestsuite, "name", test_case.name(), kIndent);
4081
+ OutputJsonKey(stream, kTestsuite, "tests", test_case.reportable_test_count(),
4082
+ kIndent);
4083
+ OutputJsonKey(stream, kTestsuite, "failures", test_case.failed_test_count(),
4084
+ kIndent);
4085
+ OutputJsonKey(stream, kTestsuite, "disabled",
4086
+ test_case.reportable_disabled_test_count(), kIndent);
4087
+ OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent);
4088
+ OutputJsonKey(stream, kTestsuite, "time",
4089
+ FormatTimeInMillisAsDuration(test_case.elapsed_time()), kIndent,
4090
+ false);
4091
+ *stream << TestPropertiesAsJson(test_case.ad_hoc_test_result(), kIndent)
4092
+ << ",\n";
4093
+
4094
+ *stream << kIndent << "\"" << kTestsuite << "\": [\n";
4095
+
4096
+ bool comma = false;
4097
+ for (int i = 0; i < test_case.total_test_count(); ++i) {
4098
+ if (test_case.GetTestInfo(i)->is_reportable()) {
4099
+ if (comma) {
4100
+ *stream << ",\n";
4101
+ } else {
4102
+ comma = true;
4103
+ }
4104
+ OutputJsonTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));
4105
+ }
4106
+ }
4107
+ *stream << "\n" << kIndent << "]\n" << Indent(4) << "}";
4108
+ }
4109
+
4110
+ // Prints a JSON summary of unit_test to output stream out.
4111
+ void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream,
4112
+ const UnitTest& unit_test) {
4113
+ const std::string kTestsuites = "testsuites";
4114
+ const std::string kIndent = Indent(2);
4115
+ *stream << "{\n";
4116
+
4117
+ OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(),
4118
+ kIndent);
4119
+ OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(),
4120
+ kIndent);
4121
+ OutputJsonKey(stream, kTestsuites, "disabled",
4122
+ unit_test.reportable_disabled_test_count(), kIndent);
4123
+ OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent);
4124
+ if (GTEST_FLAG(shuffle)) {
4125
+ OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
4126
+ kIndent);
4127
+ }
4128
+ OutputJsonKey(stream, kTestsuites, "timestamp",
4129
+ FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()),
4130
+ kIndent);
4131
+ OutputJsonKey(stream, kTestsuites, "time",
4132
+ FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent,
4133
+ false);
4134
+
4135
+ *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent)
4136
+ << ",\n";
4137
+
4138
+ OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent);
4139
+ *stream << kIndent << "\"" << kTestsuites << "\": [\n";
4140
+
4141
+ bool comma = false;
4142
+ for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
4143
+ if (unit_test.GetTestCase(i)->reportable_test_count() > 0) {
4144
+ if (comma) {
4145
+ *stream << ",\n";
4146
+ } else {
4147
+ comma = true;
4148
+ }
4149
+ PrintJsonTestCase(stream, *unit_test.GetTestCase(i));
4150
+ }
4151
+ }
4152
+
4153
+ *stream << "\n" << kIndent << "]\n" << "}\n";
4154
+ }
4155
+
4156
+ // Produces a string representing the test properties in a result as
4157
+ // a JSON dictionary.
4158
+ std::string JsonUnitTestResultPrinter::TestPropertiesAsJson(
4159
+ const TestResult& result, const std::string& indent) {
4160
+ Message attributes;
4161
+ for (int i = 0; i < result.test_property_count(); ++i) {
4162
+ const TestProperty& property = result.GetTestProperty(i);
4163
+ attributes << ",\n" << indent << "\"" << property.key() << "\": "
4164
+ << "\"" << EscapeJson(property.value()) << "\"";
4165
+ }
4166
+ return attributes.GetString();
4167
+ }
4168
+
4169
+ // End JsonUnitTestResultPrinter
4170
+
3754
4171
  #if GTEST_CAN_STREAM_RESULTS_
3755
4172
 
3756
4173
  // Checks if str contains '=', '&', '%' or '\n' characters. If yes,
@@ -3758,8 +4175,8 @@ std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
3758
4175
  // example, replaces "=" with "%3D". This algorithm is O(strlen(str))
3759
4176
  // in both time and space -- important as the input str may contain an
3760
4177
  // arbitrarily long test failure message and stack trace.
3761
- string StreamingListener::UrlEncode(const char* str) {
3762
- string result;
4178
+ std::string StreamingListener::UrlEncode(const char* str) {
4179
+ std::string result;
3763
4180
  result.reserve(strlen(str) + 1);
3764
4181
  for (char ch = *str; ch != '\0'; ch = *++str) {
3765
4182
  switch (ch) {
@@ -3821,34 +4238,13 @@ void StreamingListener::SocketWriter::MakeConnection() {
3821
4238
  // End of class Streaming Listener
3822
4239
  #endif // GTEST_CAN_STREAM_RESULTS__
3823
4240
 
3824
- // Class ScopedTrace
3825
-
3826
- // Pushes the given source file location and message onto a per-thread
3827
- // trace stack maintained by Google Test.
3828
- ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
3829
- GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
3830
- TraceInfo trace;
3831
- trace.file = file;
3832
- trace.line = line;
3833
- trace.message = message.GetString();
3834
-
3835
- UnitTest::GetInstance()->PushGTestTrace(trace);
3836
- }
3837
-
3838
- // Pops the info pushed by the c'tor.
3839
- ScopedTrace::~ScopedTrace()
3840
- GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
3841
- UnitTest::GetInstance()->PopGTestTrace();
3842
- }
3843
-
3844
-
3845
4241
  // class OsStackTraceGetter
3846
4242
 
3847
4243
  const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
3848
4244
  "... " GTEST_NAME_ " internal frames ...";
3849
4245
 
3850
- string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/,
3851
- int /*skip_count*/) {
4246
+ std::string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/,
4247
+ int /*skip_count*/) {
3852
4248
  return "";
3853
4249
  }
3854
4250
 
@@ -3859,9 +4255,10 @@ void OsStackTraceGetter::UponLeavingGTest() {}
3859
4255
  class ScopedPrematureExitFile {
3860
4256
  public:
3861
4257
  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
3862
- : premature_exit_filepath_(premature_exit_filepath) {
4258
+ : premature_exit_filepath_(premature_exit_filepath ?
4259
+ premature_exit_filepath : "") {
3863
4260
  // If a path to the premature-exit file is specified...
3864
- if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
4261
+ if (!premature_exit_filepath_.empty()) {
3865
4262
  // create the file with a single "0" character in it. I/O
3866
4263
  // errors are ignored as there's nothing better we can do and we
3867
4264
  // don't want to fail the test because of this.
@@ -3872,13 +4269,18 @@ class ScopedPrematureExitFile {
3872
4269
  }
3873
4270
 
3874
4271
  ~ScopedPrematureExitFile() {
3875
- if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
3876
- remove(premature_exit_filepath_);
4272
+ if (!premature_exit_filepath_.empty()) {
4273
+ int retval = remove(premature_exit_filepath_.c_str());
4274
+ if (retval) {
4275
+ GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
4276
+ << premature_exit_filepath_ << "\" with error "
4277
+ << retval;
4278
+ }
3877
4279
  }
3878
4280
  }
3879
4281
 
3880
4282
  private:
3881
- const char* const premature_exit_filepath_;
4283
+ const std::string premature_exit_filepath_;
3882
4284
 
3883
4285
  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
3884
4286
  };
@@ -4148,6 +4550,11 @@ void UnitTest::AddTestPartResult(
4148
4550
  // when a failure happens and both the --gtest_break_on_failure and
4149
4551
  // the --gtest_catch_exceptions flags are specified.
4150
4552
  DebugBreak();
4553
+ #elif (!defined(__native_client__)) && \
4554
+ ((defined(__clang__) || defined(__GNUC__)) && \
4555
+ (defined(__x86_64__) || defined(__i386__)))
4556
+ // with clang/gcc we can achieve the same effect on x86 by invoking int3
4557
+ asm("int3");
4151
4558
  #else
4152
4559
  // Dereference NULL through a volatile pointer to prevent the compiler
4153
4560
  // from removing. We use this rather than abort() or __builtin_trap() for
@@ -4285,7 +4692,6 @@ const TestInfo* UnitTest::current_test_info() const
4285
4692
  // Returns the random seed used at the start of the current test run.
4286
4693
  int UnitTest::random_seed() const { return impl_->random_seed(); }
4287
4694
 
4288
- #if GTEST_HAS_PARAM_TEST
4289
4695
  // Returns ParameterizedTestCaseRegistry object used to keep track of
4290
4696
  // value-parameterized tests and instantiate and register them.
4291
4697
  internal::ParameterizedTestCaseRegistry&
@@ -4293,7 +4699,6 @@ internal::ParameterizedTestCaseRegistry&
4293
4699
  GTEST_LOCK_EXCLUDED_(mutex_) {
4294
4700
  return impl_->parameterized_test_registry();
4295
4701
  }
4296
- #endif // GTEST_HAS_PARAM_TEST
4297
4702
 
4298
4703
  // Creates an empty UnitTest.
4299
4704
  UnitTest::UnitTest() {
@@ -4332,10 +4737,8 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent)
4332
4737
  &default_global_test_part_result_reporter_),
4333
4738
  per_thread_test_part_result_reporter_(
4334
4739
  &default_per_thread_test_part_result_reporter_),
4335
- #if GTEST_HAS_PARAM_TEST
4336
4740
  parameterized_test_registry_(),
4337
4741
  parameterized_tests_registered_(false),
4338
- #endif // GTEST_HAS_PARAM_TEST
4339
4742
  last_death_test_case_(-1),
4340
4743
  current_test_case_(NULL),
4341
4744
  current_test_info_(NULL),
@@ -4402,10 +4805,12 @@ void UnitTestImpl::ConfigureXmlOutput() {
4402
4805
  if (output_format == "xml") {
4403
4806
  listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
4404
4807
  UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
4808
+ } else if (output_format == "json") {
4809
+ listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
4810
+ UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
4405
4811
  } else if (output_format != "") {
4406
- printf("WARNING: unrecognized output format \"%s\" ignored.\n",
4407
- output_format.c_str());
4408
- fflush(stdout);
4812
+ GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
4813
+ << output_format << "\" ignored.";
4409
4814
  }
4410
4815
  }
4411
4816
 
@@ -4420,9 +4825,8 @@ void UnitTestImpl::ConfigureStreamingOutput() {
4420
4825
  listeners()->Append(new StreamingListener(target.substr(0, pos),
4421
4826
  target.substr(pos+1)));
4422
4827
  } else {
4423
- printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
4424
- target.c_str());
4425
- fflush(stdout);
4828
+ GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
4829
+ << "\" ignored.";
4426
4830
  }
4427
4831
  }
4428
4832
  }
@@ -4504,11 +4908,11 @@ TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
4504
4908
  Test::SetUpTestCaseFunc set_up_tc,
4505
4909
  Test::TearDownTestCaseFunc tear_down_tc) {
4506
4910
  // Can we find a TestCase with the given name?
4507
- const std::vector<TestCase*>::const_iterator test_case =
4508
- std::find_if(test_cases_.begin(), test_cases_.end(),
4911
+ const std::vector<TestCase*>::const_reverse_iterator test_case =
4912
+ std::find_if(test_cases_.rbegin(), test_cases_.rend(),
4509
4913
  TestCaseNameIs(test_case_name));
4510
4914
 
4511
- if (test_case != test_cases_.end())
4915
+ if (test_case != test_cases_.rend())
4512
4916
  return *test_case;
4513
4917
 
4514
4918
  // No. Let's create one.
@@ -4549,13 +4953,8 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
4549
4953
  // All other functions called from RunAllTests() may safely assume that
4550
4954
  // parameterized tests are ready to be counted and run.
4551
4955
  bool UnitTestImpl::RunAllTests() {
4552
- // Makes sure InitGoogleTest() was called.
4553
- if (!GTestIsInitialized()) {
4554
- printf("%s",
4555
- "\nThis test program did NOT call ::testing::InitGoogleTest "
4556
- "before calling RUN_ALL_TESTS(). Please fix it.\n");
4557
- return false;
4558
- }
4956
+ // True iff Google Test is initialized before RUN_ALL_TESTS() is called.
4957
+ const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
4559
4958
 
4560
4959
  // Do not run any test if the --help flag was specified.
4561
4960
  if (g_help_flag)
@@ -4683,6 +5082,20 @@ bool UnitTestImpl::RunAllTests() {
4683
5082
 
4684
5083
  repeater->OnTestProgramEnd(*parent_);
4685
5084
 
5085
+ if (!gtest_is_initialized_before_run_all_tests) {
5086
+ ColoredPrintf(
5087
+ COLOR_RED,
5088
+ "\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
5089
+ "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
5090
+ "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
5091
+ " will start to enforce the valid usage. "
5092
+ "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
5093
+ #if GTEST_FOR_GOOGLE_
5094
+ ColoredPrintf(COLOR_RED,
5095
+ "For more details, see http://wiki/Main/ValidGUnitMain.\n");
5096
+ #endif // GTEST_FOR_GOOGLE_
5097
+ }
5098
+
4686
5099
  return !failed;
4687
5100
  }
4688
5101
 
@@ -4784,8 +5197,8 @@ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
4784
5197
  // each TestCase and TestInfo object.
4785
5198
  // If shard_tests == true, further filters tests based on sharding
4786
5199
  // variables in the environment - see
4787
- // http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.
4788
- // Returns the number of tests that should run.
5200
+ // https://github.com/google/googletest/blob/master/googletest/docs/advanced.md
5201
+ // . Returns the number of tests that should run.
4789
5202
  int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
4790
5203
  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
4791
5204
  Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
@@ -4824,10 +5237,11 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
4824
5237
  (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
4825
5238
  matches_filter;
4826
5239
 
4827
- const bool is_selected = is_runnable &&
4828
- (shard_tests == IGNORE_SHARDING_PROTOCOL ||
4829
- ShouldRunTestOnShard(total_shards, shard_index,
4830
- num_runnable_tests));
5240
+ const bool is_in_another_shard =
5241
+ shard_tests != IGNORE_SHARDING_PROTOCOL &&
5242
+ !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
5243
+ test_info->is_in_another_shard_ = is_in_another_shard;
5244
+ const bool is_selected = is_runnable && !is_in_another_shard;
4831
5245
 
4832
5246
  num_runnable_tests += is_runnable;
4833
5247
  num_selected_tests += is_selected;
@@ -4927,11 +5341,15 @@ OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
4927
5341
  return os_stack_trace_getter_;
4928
5342
  }
4929
5343
 
4930
- // Returns the TestResult for the test that's currently running, or
4931
- // the TestResult for the ad hoc test if no test is running.
5344
+ // Returns the most specific TestResult currently running.
4932
5345
  TestResult* UnitTestImpl::current_test_result() {
4933
- return current_test_info_ ?
4934
- &(current_test_info_->result_) : &ad_hoc_test_result_;
5346
+ if (current_test_info_ != NULL) {
5347
+ return &current_test_info_->result_;
5348
+ }
5349
+ if (current_test_case_ != NULL) {
5350
+ return &current_test_case_->ad_hoc_test_result_;
5351
+ }
5352
+ return &ad_hoc_test_result_;
4935
5353
  }
4936
5354
 
4937
5355
  // Shuffles all test cases, and the tests within each test case,
@@ -5012,9 +5430,8 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
5012
5430
  // part can be omitted.
5013
5431
  //
5014
5432
  // Returns the value of the flag, or NULL if the parsing failed.
5015
- const char* ParseFlagValue(const char* str,
5016
- const char* flag,
5017
- bool def_optional) {
5433
+ static const char* ParseFlagValue(const char* str, const char* flag,
5434
+ bool def_optional) {
5018
5435
  // str and flag must not be NULL.
5019
5436
  if (str == NULL || flag == NULL) return NULL;
5020
5437
 
@@ -5050,7 +5467,7 @@ const char* ParseFlagValue(const char* str,
5050
5467
  //
5051
5468
  // On success, stores the value of the flag in *value, and returns
5052
5469
  // true. On failure, returns false without changing *value.
5053
- bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
5470
+ static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
5054
5471
  // Gets the value of the flag as a string.
5055
5472
  const char* const value_str = ParseFlagValue(str, flag, true);
5056
5473
 
@@ -5084,7 +5501,8 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
5084
5501
  //
5085
5502
  // On success, stores the value of the flag in *value, and returns
5086
5503
  // true. On failure, returns false without changing *value.
5087
- bool ParseStringFlag(const char* str, const char* flag, std::string* value) {
5504
+ template <typename String>
5505
+ static bool ParseStringFlag(const char* str, const char* flag, String* value) {
5088
5506
  // Gets the value of the flag as a string.
5089
5507
  const char* const value_str = ParseFlagValue(str, flag, false);
5090
5508
 
@@ -5186,24 +5604,25 @@ static const char kColorEncodedHelpMessage[] =
5186
5604
  " Enable/disable colored output. The default is @Gauto@D.\n"
5187
5605
  " -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
5188
5606
  " Don't print the elapsed time of each test.\n"
5189
- " @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G"
5607
+ " @G--" GTEST_FLAG_PREFIX_ "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G"
5190
5608
  GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
5191
- " Generate an XML report in the given directory or with the given file\n"
5192
- " name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n"
5193
- #if GTEST_CAN_STREAM_RESULTS_
5609
+ " Generate a JSON or XML report in the given directory or with the given\n"
5610
+ " file name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n"
5611
+ # if GTEST_CAN_STREAM_RESULTS_
5194
5612
  " @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n"
5195
5613
  " Stream test results to the given server.\n"
5196
- #endif // GTEST_CAN_STREAM_RESULTS_
5614
+ # endif // GTEST_CAN_STREAM_RESULTS_
5197
5615
  "\n"
5198
5616
  "Assertion Behavior:\n"
5199
- #if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
5617
+ # if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
5200
5618
  " @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n"
5201
5619
  " Set the default death test style.\n"
5202
- #endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
5620
+ # endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
5203
5621
  " @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n"
5204
5622
  " Turn assertion failures into debugger break-points.\n"
5205
5623
  " @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n"
5206
- " Turn assertion failures into C++ exceptions.\n"
5624
+ " Turn assertion failures into C++ exceptions for use by an external\n"
5625
+ " test framework.\n"
5207
5626
  " @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n"
5208
5627
  " Do not report exceptions as test failures. Instead, allow them\n"
5209
5628
  " to crash the program or throw a pop-up (on Windows).\n"
@@ -5220,7 +5639,7 @@ static const char kColorEncodedHelpMessage[] =
5220
5639
  "(not one in your own code or tests), please report it to\n"
5221
5640
  "@G<" GTEST_DEV_EMAIL_ ">@D.\n";
5222
5641
 
5223
- bool ParseGoogleTestFlag(const char* const arg) {
5642
+ static bool ParseGoogleTestFlag(const char* const arg) {
5224
5643
  return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
5225
5644
  &GTEST_FLAG(also_run_disabled_tests)) ||
5226
5645
  ParseBoolFlag(arg, kBreakOnFailureFlag,
@@ -5238,6 +5657,7 @@ bool ParseGoogleTestFlag(const char* const arg) {
5238
5657
  ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||
5239
5658
  ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||
5240
5659
  ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||
5660
+ ParseBoolFlag(arg, kPrintUTF8Flag, &GTEST_FLAG(print_utf8)) ||
5241
5661
  ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||
5242
5662
  ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||
5243
5663
  ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||
@@ -5250,14 +5670,11 @@ bool ParseGoogleTestFlag(const char* const arg) {
5250
5670
  }
5251
5671
 
5252
5672
  #if GTEST_USE_OWN_FLAGFILE_FLAG_
5253
- void LoadFlagsFromFile(const std::string& path) {
5673
+ static void LoadFlagsFromFile(const std::string& path) {
5254
5674
  FILE* flagfile = posix::FOpen(path.c_str(), "r");
5255
5675
  if (!flagfile) {
5256
- fprintf(stderr,
5257
- "Unable to open file \"%s\"\n",
5258
- GTEST_FLAG(flagfile).c_str());
5259
- fflush(stderr);
5260
- exit(EXIT_FAILURE);
5676
+ GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
5677
+ << "\"";
5261
5678
  }
5262
5679
  std::string contents(ReadEntireFile(flagfile));
5263
5680
  posix::FClose(flagfile);
@@ -5385,4 +5802,45 @@ void InitGoogleTest(int* argc, wchar_t** argv) {
5385
5802
  #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
5386
5803
  }
5387
5804
 
5805
+ std::string TempDir() {
5806
+ #if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
5807
+ return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
5808
+ #endif
5809
+
5810
+ #if GTEST_OS_WINDOWS_MOBILE
5811
+ return "\\temp\\";
5812
+ #elif GTEST_OS_WINDOWS
5813
+ const char* temp_dir = internal::posix::GetEnv("TEMP");
5814
+ if (temp_dir == NULL || temp_dir[0] == '\0')
5815
+ return "\\temp\\";
5816
+ else if (temp_dir[strlen(temp_dir) - 1] == '\\')
5817
+ return temp_dir;
5818
+ else
5819
+ return std::string(temp_dir) + "\\";
5820
+ #elif GTEST_OS_LINUX_ANDROID
5821
+ return "/sdcard/";
5822
+ #else
5823
+ return "/tmp/";
5824
+ #endif // GTEST_OS_WINDOWS_MOBILE
5825
+ }
5826
+
5827
+ // Class ScopedTrace
5828
+
5829
+ // Pushes the given source file location and message onto a per-thread
5830
+ // trace stack maintained by Google Test.
5831
+ void ScopedTrace::PushTrace(const char* file, int line, std::string message) {
5832
+ internal::TraceInfo trace;
5833
+ trace.file = file;
5834
+ trace.line = line;
5835
+ trace.message.swap(message);
5836
+
5837
+ UnitTest::GetInstance()->PushGTestTrace(trace);
5838
+ }
5839
+
5840
+ // Pops the info pushed by the c'tor.
5841
+ ScopedTrace::~ScopedTrace()
5842
+ GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
5843
+ UnitTest::GetInstance()->PopGTestTrace();
5844
+ }
5845
+
5388
5846
  } // namespace testing