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
@@ -49,7 +49,7 @@
49
49
  // implementation. It must come before gtest-internal-inl.h is
50
50
  // included, or there will be a compiler error. This trick is to
51
51
  // prevent a user from accidentally including gtest-internal-inl.h in
52
- // his code.
52
+ // their code.
53
53
  #define GTEST_IMPLEMENTATION_ 1
54
54
  #include "src/gtest-internal-inl.h"
55
55
  #undef GTEST_IMPLEMENTATION_
@@ -69,6 +69,26 @@ namespace internal {
69
69
 
70
70
  namespace {
71
71
 
72
+ TEST(JoinAsTupleTest, JoinsEmptyTuple) {
73
+ EXPECT_EQ("", JoinAsTuple(Strings()));
74
+ }
75
+
76
+ TEST(JoinAsTupleTest, JoinsOneTuple) {
77
+ const char* fields[] = {"1"};
78
+ EXPECT_EQ("1", JoinAsTuple(Strings(fields, fields + 1)));
79
+ }
80
+
81
+ TEST(JoinAsTupleTest, JoinsTwoTuple) {
82
+ const char* fields[] = {"1", "a"};
83
+ EXPECT_EQ("(1, a)", JoinAsTuple(Strings(fields, fields + 2)));
84
+ }
85
+
86
+ TEST(JoinAsTupleTest, JoinsTenTuple) {
87
+ const char* fields[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
88
+ EXPECT_EQ("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)",
89
+ JoinAsTuple(Strings(fields, fields + 10)));
90
+ }
91
+
72
92
  TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsNoWord) {
73
93
  EXPECT_EQ("", ConvertIdentifierNameToWords(""));
74
94
  EXPECT_EQ("", ConvertIdentifierNameToWords("_"));
@@ -319,11 +339,10 @@ TEST(TupleMatchesTest, WorksForSize2) {
319
339
 
320
340
  TEST(TupleMatchesTest, WorksForSize5) {
321
341
  tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<long>, // NOLINT
322
- Matcher<string> >
342
+ Matcher<std::string> >
323
343
  matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
324
- tuple<int, char, bool, long, string> // NOLINT
325
- values1(1, 'a', true, 2L, "hi"),
326
- values2(1, 'a', true, 2L, "hello"),
344
+ tuple<int, char, bool, long, std::string> // NOLINT
345
+ values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"),
327
346
  values3(2, 'a', true, 2L, "hi");
328
347
 
329
348
  EXPECT_TRUE(TupleMatches(matchers, values1));
@@ -375,7 +394,7 @@ class LogIsVisibleTest : public ::testing::Test {
375
394
 
376
395
  virtual void TearDown() { GMOCK_FLAG(verbose) = original_verbose_; }
377
396
 
378
- string original_verbose_;
397
+ std::string original_verbose_;
379
398
  };
380
399
 
381
400
  TEST_F(LogIsVisibleTest, AlwaysReturnsTrueIfVerbosityIsInfo) {
@@ -402,9 +421,9 @@ TEST_F(LogIsVisibleTest, WorksWhenVerbosityIsWarning) {
402
421
 
403
422
  // Verifies that Log() behaves correctly for the given verbosity level
404
423
  // and log severity.
405
- void TestLogWithSeverity(const string& verbosity, LogSeverity severity,
424
+ void TestLogWithSeverity(const std::string& verbosity, LogSeverity severity,
406
425
  bool should_print) {
407
- const string old_flag = GMOCK_FLAG(verbose);
426
+ const std::string old_flag = GMOCK_FLAG(verbose);
408
427
  GMOCK_FLAG(verbose) = verbosity;
409
428
  CaptureStdout();
410
429
  Log(severity, "Test log.\n", 0);
@@ -423,7 +442,7 @@ void TestLogWithSeverity(const string& verbosity, LogSeverity severity,
423
442
  // Tests that when the stack_frames_to_skip parameter is negative,
424
443
  // Log() doesn't include the stack trace in the output.
425
444
  TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
426
- const string saved_flag = GMOCK_FLAG(verbose);
445
+ const std::string saved_flag = GMOCK_FLAG(verbose);
427
446
  GMOCK_FLAG(verbose) = kInfoVerbosity;
428
447
  CaptureStdout();
429
448
  Log(kInfo, "Test log.\n", -1);
@@ -432,7 +451,7 @@ TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
432
451
  }
433
452
 
434
453
  struct MockStackTraceGetter : testing::internal::OsStackTraceGetterInterface {
435
- virtual string CurrentStackTrace(int max_depth, int skip_count) {
454
+ virtual std::string CurrentStackTrace(int max_depth, int skip_count) {
436
455
  return (testing::Message() << max_depth << "::" << skip_count << "\n")
437
456
  .GetString();
438
457
  }
@@ -447,11 +466,11 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
447
466
 
448
467
  CaptureStdout();
449
468
  Log(kWarning, "Test log.\n", 100);
450
- const string log = GetCapturedStdout();
469
+ const std::string log = GetCapturedStdout();
451
470
 
452
- string expected_trace =
471
+ std::string expected_trace =
453
472
  (testing::Message() << GTEST_FLAG(stack_trace_depth) << "::").GetString();
454
- string expected_message =
473
+ std::string expected_message =
455
474
  "\nGMOCK WARNING:\n"
456
475
  "Test log.\n"
457
476
  "Stack trace:\n" +
@@ -547,7 +566,7 @@ TEST(TypeTraitsTest, remove_reference) {
547
566
  // Verifies that Log() behaves correctly for the given verbosity level
548
567
  // and log severity.
549
568
  std::string GrabOutput(void(*logger)(), const char* verbosity) {
550
- const string saved_flag = GMOCK_FLAG(verbose);
569
+ const std::string saved_flag = GMOCK_FLAG(verbose);
551
570
  GMOCK_FLAG(verbose) = verbosity;
552
571
  CaptureStdout();
553
572
  logger();
@@ -45,6 +45,7 @@
45
45
  #include <limits>
46
46
  #include <list>
47
47
  #include <map>
48
+ #include <memory>
48
49
  #include <set>
49
50
  #include <sstream>
50
51
  #include <string>
@@ -58,12 +59,11 @@
58
59
  # include <forward_list> // NOLINT
59
60
  #endif
60
61
 
61
- namespace testing {
62
-
63
- namespace internal {
64
- GTEST_API_ string JoinAsTuple(const Strings& fields);
65
- } // namespace internal
62
+ #if GTEST_LANG_CXX11
63
+ # include <type_traits>
64
+ #endif
66
65
 
66
+ namespace testing {
67
67
  namespace gmock_matchers_test {
68
68
 
69
69
  using std::greater;
@@ -145,7 +145,6 @@ using testing::internal::ExplainMatchFailureTupleTo;
145
145
  using testing::internal::FloatingEqMatcher;
146
146
  using testing::internal::FormatMatcherDescription;
147
147
  using testing::internal::IsReadableTypeName;
148
- using testing::internal::JoinAsTuple;
149
148
  using testing::internal::linked_ptr;
150
149
  using testing::internal::MatchMatrix;
151
150
  using testing::internal::RE;
@@ -189,7 +188,7 @@ Matcher<int> GreaterThan(int n) {
189
188
  return MakeMatcher(new GreaterThanMatcher(n));
190
189
  }
191
190
 
192
- string OfType(const string& type_name) {
191
+ std::string OfType(const std::string& type_name) {
193
192
  #if GTEST_HAS_RTTI
194
193
  return " (of type " + type_name + ")";
195
194
  #else
@@ -199,28 +198,30 @@ string OfType(const string& type_name) {
199
198
 
200
199
  // Returns the description of the given matcher.
201
200
  template <typename T>
202
- string Describe(const Matcher<T>& m) {
203
- stringstream ss;
204
- m.DescribeTo(&ss);
205
- return ss.str();
201
+ std::string Describe(const Matcher<T>& m) {
202
+ return DescribeMatcher<T>(m);
206
203
  }
207
204
 
208
205
  // Returns the description of the negation of the given matcher.
209
206
  template <typename T>
210
- string DescribeNegation(const Matcher<T>& m) {
211
- stringstream ss;
212
- m.DescribeNegationTo(&ss);
213
- return ss.str();
207
+ std::string DescribeNegation(const Matcher<T>& m) {
208
+ return DescribeMatcher<T>(m, true);
214
209
  }
215
210
 
216
211
  // Returns the reason why x matches, or doesn't match, m.
217
212
  template <typename MatcherType, typename Value>
218
- string Explain(const MatcherType& m, const Value& x) {
213
+ std::string Explain(const MatcherType& m, const Value& x) {
219
214
  StringMatchResultListener listener;
220
215
  ExplainMatchResult(m, x, &listener);
221
216
  return listener.str();
222
217
  }
223
218
 
219
+ TEST(MonotonicMatcherTest, IsPrintable) {
220
+ stringstream ss;
221
+ ss << GreaterThan(5);
222
+ EXPECT_EQ("is > 5", ss.str());
223
+ }
224
+
224
225
  TEST(MatchResultListenerTest, StreamingWorks) {
225
226
  StringMatchResultListener listener;
226
227
  listener << "hi" << 5;
@@ -332,6 +333,22 @@ TEST(MatcherTest, CanBeImplicitlyConstructedFromNULL) {
332
333
  EXPECT_FALSE(m1.Matches(&n));
333
334
  }
334
335
 
336
+ // Tests that matchers can be constructed from a variable that is not properly
337
+ // defined. This should be illegal, but many users rely on this accidentally.
338
+ struct Undefined {
339
+ virtual ~Undefined() = 0;
340
+ static const int kInt = 1;
341
+ };
342
+
343
+ TEST(MatcherTest, CanBeConstructedFromUndefinedVariable) {
344
+ Matcher<int> m1 = Undefined::kInt;
345
+ EXPECT_TRUE(m1.Matches(1));
346
+ EXPECT_FALSE(m1.Matches(2));
347
+ }
348
+
349
+ // Test that a matcher parameterized with an abstract class compiles.
350
+ TEST(MatcherTest, CanAcceptAbstractClass) { Matcher<const Undefined&> m = _; }
351
+
335
352
  // Tests that matchers are copyable.
336
353
  TEST(MatcherTest, IsCopyable) {
337
354
  // Tests the copy constructor.
@@ -365,66 +382,132 @@ TEST(MatcherTest, MatchAndExplain) {
365
382
  }
366
383
 
367
384
  // Tests that a C-string literal can be implicitly converted to a
368
- // Matcher<string> or Matcher<const string&>.
385
+ // Matcher<std::string> or Matcher<const std::string&>.
369
386
  TEST(StringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
370
- Matcher<string> m1 = "hi";
387
+ Matcher<std::string> m1 = "hi";
371
388
  EXPECT_TRUE(m1.Matches("hi"));
372
389
  EXPECT_FALSE(m1.Matches("hello"));
373
390
 
374
- Matcher<const string&> m2 = "hi";
391
+ Matcher<const std::string&> m2 = "hi";
375
392
  EXPECT_TRUE(m2.Matches("hi"));
376
393
  EXPECT_FALSE(m2.Matches("hello"));
377
394
  }
378
395
 
379
396
  // Tests that a string object can be implicitly converted to a
380
- // Matcher<string> or Matcher<const string&>.
397
+ // Matcher<std::string> or Matcher<const std::string&>.
381
398
  TEST(StringMatcherTest, CanBeImplicitlyConstructedFromString) {
382
- Matcher<string> m1 = string("hi");
399
+ Matcher<std::string> m1 = std::string("hi");
400
+ EXPECT_TRUE(m1.Matches("hi"));
401
+ EXPECT_FALSE(m1.Matches("hello"));
402
+
403
+ Matcher<const std::string&> m2 = std::string("hi");
404
+ EXPECT_TRUE(m2.Matches("hi"));
405
+ EXPECT_FALSE(m2.Matches("hello"));
406
+ }
407
+
408
+ #if GTEST_HAS_GLOBAL_STRING
409
+ // Tests that a ::string object can be implicitly converted to a
410
+ // Matcher<std::string> or Matcher<const std::string&>.
411
+ TEST(StringMatcherTest, CanBeImplicitlyConstructedFromGlobalString) {
412
+ Matcher<std::string> m1 = ::string("hi");
383
413
  EXPECT_TRUE(m1.Matches("hi"));
384
414
  EXPECT_FALSE(m1.Matches("hello"));
385
415
 
386
- Matcher<const string&> m2 = string("hi");
416
+ Matcher<const std::string&> m2 = ::string("hi");
387
417
  EXPECT_TRUE(m2.Matches("hi"));
388
418
  EXPECT_FALSE(m2.Matches("hello"));
389
419
  }
420
+ #endif // GTEST_HAS_GLOBAL_STRING
390
421
 
391
- #if GTEST_HAS_STRING_PIECE_
422
+ #if GTEST_HAS_GLOBAL_STRING
392
423
  // Tests that a C-string literal can be implicitly converted to a
393
- // Matcher<StringPiece> or Matcher<const StringPiece&>.
394
- TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
395
- Matcher<StringPiece> m1 = "cats";
424
+ // Matcher<::string> or Matcher<const ::string&>.
425
+ TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
426
+ Matcher< ::string> m1 = "hi";
427
+ EXPECT_TRUE(m1.Matches("hi"));
428
+ EXPECT_FALSE(m1.Matches("hello"));
429
+
430
+ Matcher<const ::string&> m2 = "hi";
431
+ EXPECT_TRUE(m2.Matches("hi"));
432
+ EXPECT_FALSE(m2.Matches("hello"));
433
+ }
434
+
435
+ // Tests that a std::string object can be implicitly converted to a
436
+ // Matcher<::string> or Matcher<const ::string&>.
437
+ TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromString) {
438
+ Matcher< ::string> m1 = std::string("hi");
439
+ EXPECT_TRUE(m1.Matches("hi"));
440
+ EXPECT_FALSE(m1.Matches("hello"));
441
+
442
+ Matcher<const ::string&> m2 = std::string("hi");
443
+ EXPECT_TRUE(m2.Matches("hi"));
444
+ EXPECT_FALSE(m2.Matches("hello"));
445
+ }
446
+
447
+ // Tests that a ::string object can be implicitly converted to a
448
+ // Matcher<::string> or Matcher<const ::string&>.
449
+ TEST(GlobalStringMatcherTest, CanBeImplicitlyConstructedFromGlobalString) {
450
+ Matcher< ::string> m1 = ::string("hi");
451
+ EXPECT_TRUE(m1.Matches("hi"));
452
+ EXPECT_FALSE(m1.Matches("hello"));
453
+
454
+ Matcher<const ::string&> m2 = ::string("hi");
455
+ EXPECT_TRUE(m2.Matches("hi"));
456
+ EXPECT_FALSE(m2.Matches("hello"));
457
+ }
458
+ #endif // GTEST_HAS_GLOBAL_STRING
459
+
460
+ #if GTEST_HAS_ABSL
461
+ // Tests that a C-string literal can be implicitly converted to a
462
+ // Matcher<absl::string_view> or Matcher<const absl::string_view&>.
463
+ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {
464
+ Matcher<absl::string_view> m1 = "cats";
396
465
  EXPECT_TRUE(m1.Matches("cats"));
397
466
  EXPECT_FALSE(m1.Matches("dogs"));
398
467
 
399
- Matcher<const StringPiece&> m2 = "cats";
468
+ Matcher<const absl::string_view&> m2 = "cats";
400
469
  EXPECT_TRUE(m2.Matches("cats"));
401
470
  EXPECT_FALSE(m2.Matches("dogs"));
402
471
  }
403
472
 
404
- // Tests that a string object can be implicitly converted to a
405
- // Matcher<StringPiece> or Matcher<const StringPiece&>.
406
- TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromString) {
407
- Matcher<StringPiece> m1 = string("cats");
473
+ // Tests that a std::string object can be implicitly converted to a
474
+ // Matcher<absl::string_view> or Matcher<const absl::string_view&>.
475
+ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromString) {
476
+ Matcher<absl::string_view> m1 = std::string("cats");
408
477
  EXPECT_TRUE(m1.Matches("cats"));
409
478
  EXPECT_FALSE(m1.Matches("dogs"));
410
479
 
411
- Matcher<const StringPiece&> m2 = string("cats");
480
+ Matcher<const absl::string_view&> m2 = std::string("cats");
412
481
  EXPECT_TRUE(m2.Matches("cats"));
413
482
  EXPECT_FALSE(m2.Matches("dogs"));
414
483
  }
415
484
 
416
- // Tests that a StringPiece object can be implicitly converted to a
417
- // Matcher<StringPiece> or Matcher<const StringPiece&>.
418
- TEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromStringPiece) {
419
- Matcher<StringPiece> m1 = StringPiece("cats");
485
+ #if GTEST_HAS_GLOBAL_STRING
486
+ // Tests that a ::string object can be implicitly converted to a
487
+ // Matcher<absl::string_view> or Matcher<const absl::string_view&>.
488
+ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromGlobalString) {
489
+ Matcher<absl::string_view> m1 = ::string("cats");
420
490
  EXPECT_TRUE(m1.Matches("cats"));
421
491
  EXPECT_FALSE(m1.Matches("dogs"));
422
492
 
423
- Matcher<const StringPiece&> m2 = StringPiece("cats");
493
+ Matcher<const absl::string_view&> m2 = ::string("cats");
424
494
  EXPECT_TRUE(m2.Matches("cats"));
425
495
  EXPECT_FALSE(m2.Matches("dogs"));
426
496
  }
427
- #endif // GTEST_HAS_STRING_PIECE_
497
+ #endif // GTEST_HAS_GLOBAL_STRING
498
+
499
+ // Tests that a absl::string_view object can be implicitly converted to a
500
+ // Matcher<absl::string_view> or Matcher<const absl::string_view&>.
501
+ TEST(StringViewMatcherTest, CanBeImplicitlyConstructedFromStringView) {
502
+ Matcher<absl::string_view> m1 = absl::string_view("cats");
503
+ EXPECT_TRUE(m1.Matches("cats"));
504
+ EXPECT_FALSE(m1.Matches("dogs"));
505
+
506
+ Matcher<const absl::string_view&> m2 = absl::string_view("cats");
507
+ EXPECT_TRUE(m2.Matches("cats"));
508
+ EXPECT_FALSE(m2.Matches("dogs"));
509
+ }
510
+ #endif // GTEST_HAS_ABSL
428
511
 
429
512
  // Tests that MakeMatcher() constructs a Matcher<T> from a
430
513
  // MatcherInterface* without requiring the user to explicitly
@@ -609,6 +692,71 @@ TEST(MatcherCastTest, FromSameType) {
609
692
  EXPECT_FALSE(m2.Matches(1));
610
693
  }
611
694
 
695
+ // Tests that MatcherCast<T>(m) works when m is a value of the same type as the
696
+ // value type of the Matcher.
697
+ TEST(MatcherCastTest, FromAValue) {
698
+ Matcher<int> m = MatcherCast<int>(42);
699
+ EXPECT_TRUE(m.Matches(42));
700
+ EXPECT_FALSE(m.Matches(239));
701
+ }
702
+
703
+ // Tests that MatcherCast<T>(m) works when m is a value of the type implicitly
704
+ // convertible to the value type of the Matcher.
705
+ TEST(MatcherCastTest, FromAnImplicitlyConvertibleValue) {
706
+ const int kExpected = 'c';
707
+ Matcher<int> m = MatcherCast<int>('c');
708
+ EXPECT_TRUE(m.Matches(kExpected));
709
+ EXPECT_FALSE(m.Matches(kExpected + 1));
710
+ }
711
+
712
+ struct NonImplicitlyConstructibleTypeWithOperatorEq {
713
+ friend bool operator==(
714
+ const NonImplicitlyConstructibleTypeWithOperatorEq& /* ignored */,
715
+ int rhs) {
716
+ return 42 == rhs;
717
+ }
718
+ friend bool operator==(
719
+ int lhs,
720
+ const NonImplicitlyConstructibleTypeWithOperatorEq& /* ignored */) {
721
+ return lhs == 42;
722
+ }
723
+ };
724
+
725
+ // Tests that MatcherCast<T>(m) works when m is a neither a matcher nor
726
+ // implicitly convertible to the value type of the Matcher, but the value type
727
+ // of the matcher has operator==() overload accepting m.
728
+ TEST(MatcherCastTest, NonImplicitlyConstructibleTypeWithOperatorEq) {
729
+ Matcher<NonImplicitlyConstructibleTypeWithOperatorEq> m1 =
730
+ MatcherCast<NonImplicitlyConstructibleTypeWithOperatorEq>(42);
731
+ EXPECT_TRUE(m1.Matches(NonImplicitlyConstructibleTypeWithOperatorEq()));
732
+
733
+ Matcher<NonImplicitlyConstructibleTypeWithOperatorEq> m2 =
734
+ MatcherCast<NonImplicitlyConstructibleTypeWithOperatorEq>(239);
735
+ EXPECT_FALSE(m2.Matches(NonImplicitlyConstructibleTypeWithOperatorEq()));
736
+
737
+ // When updating the following lines please also change the comment to
738
+ // namespace convertible_from_any.
739
+ Matcher<int> m3 =
740
+ MatcherCast<int>(NonImplicitlyConstructibleTypeWithOperatorEq());
741
+ EXPECT_TRUE(m3.Matches(42));
742
+ EXPECT_FALSE(m3.Matches(239));
743
+ }
744
+
745
+ // ConvertibleFromAny does not work with MSVC. resulting in
746
+ // error C2440: 'initializing': cannot convert from 'Eq' to 'M'
747
+ // No constructor could take the source type, or constructor overload
748
+ // resolution was ambiguous
749
+
750
+ #if !defined _MSC_VER
751
+
752
+ // The below ConvertibleFromAny struct is implicitly constructible from anything
753
+ // and when in the same namespace can interact with other tests. In particular,
754
+ // if it is in the same namespace as other tests and one removes
755
+ // NonImplicitlyConstructibleTypeWithOperatorEq::operator==(int lhs, ...);
756
+ // then the corresponding test still compiles (and it should not!) by implicitly
757
+ // converting NonImplicitlyConstructibleTypeWithOperatorEq to ConvertibleFromAny
758
+ // in m3.Matcher().
759
+ namespace convertible_from_any {
612
760
  // Implicitly convertible from any type.
613
761
  struct ConvertibleFromAny {
614
762
  ConvertibleFromAny(int a_value) : value(a_value) {}
@@ -639,6 +787,9 @@ TEST(MatcherCastTest, FromConvertibleFromAny) {
639
787
  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
640
788
  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
641
789
  }
790
+ } // namespace convertible_from_any
791
+
792
+ #endif // !defined _MSC_VER
642
793
 
643
794
  struct IntReferenceWrapper {
644
795
  IntReferenceWrapper(const int& a_value) : value(&a_value) {}
@@ -744,6 +895,9 @@ TEST(SafeMatcherCastTest, FromSameType) {
744
895
  EXPECT_FALSE(m2.Matches(1));
745
896
  }
746
897
 
898
+ #if !defined _MSC_VER
899
+
900
+ namespace convertible_from_any {
747
901
  TEST(SafeMatcherCastTest, ConversionConstructorIsUsed) {
748
902
  Matcher<ConvertibleFromAny> m = SafeMatcherCast<ConvertibleFromAny>(1);
749
903
  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
@@ -756,6 +910,9 @@ TEST(SafeMatcherCastTest, FromConvertibleFromAny) {
756
910
  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));
757
911
  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));
758
912
  }
913
+ } // namespace convertible_from_any
914
+
915
+ #endif // !defined _MSC_VER
759
916
 
760
917
  TEST(SafeMatcherCastTest, ValueIsNotCopied) {
761
918
  int n = 42;
@@ -767,7 +924,7 @@ TEST(SafeMatcherCastTest, ValueIsNotCopied) {
767
924
  TEST(ExpectThat, TakesLiterals) {
768
925
  EXPECT_THAT(1, 1);
769
926
  EXPECT_THAT(1.0, 1.0);
770
- EXPECT_THAT(string(), "");
927
+ EXPECT_THAT(std::string(), "");
771
928
  }
772
929
 
773
930
  TEST(ExpectThat, TakesFunctions) {
@@ -867,7 +1024,7 @@ class Unprintable {
867
1024
  public:
868
1025
  Unprintable() : c_('a') {}
869
1026
 
870
- bool operator==(const Unprintable& /* rhs */) { return true; }
1027
+ bool operator==(const Unprintable& /* rhs */) const { return true; }
871
1028
  private:
872
1029
  char c_;
873
1030
  };
@@ -910,7 +1067,7 @@ TEST(TypedEqTest, CanDescribeSelf) {
910
1067
  // Type<T>::IsTypeOf(v) compiles iff the type of value v is T, where T
911
1068
  // is a "bare" type (i.e. not in the form of const U or U&). If v's
912
1069
  // type is not T, the compiler will generate a message about
913
- // "undefined referece".
1070
+ // "undefined reference".
914
1071
  template <typename T>
915
1072
  struct Type {
916
1073
  static bool IsTypeOf(const T& /* v */) { return true; }
@@ -969,7 +1126,7 @@ TEST(LeTest, CanDescribeSelf) {
969
1126
 
970
1127
  // Tests that Lt(v) matches anything < v.
971
1128
  TEST(LtTest, ImplementsLessThan) {
972
- Matcher<const string&> m1 = Lt("Hello");
1129
+ Matcher<const std::string&> m1 = Lt("Hello");
973
1130
  EXPECT_TRUE(m1.Matches("Abc"));
974
1131
  EXPECT_FALSE(m1.Matches("Hello"));
975
1132
  EXPECT_FALSE(m1.Matches("Hello, world!"));
@@ -1042,14 +1199,14 @@ TEST(IsNullTest, ReferenceToConstLinkedPtr) {
1042
1199
  EXPECT_FALSE(m.Matches(non_null_p));
1043
1200
  }
1044
1201
 
1045
- #if GTEST_HAS_STD_FUNCTION_
1202
+ #if GTEST_LANG_CXX11
1046
1203
  TEST(IsNullTest, StdFunction) {
1047
1204
  const Matcher<std::function<void()>> m = IsNull();
1048
1205
 
1049
1206
  EXPECT_TRUE(m.Matches(std::function<void()>()));
1050
1207
  EXPECT_FALSE(m.Matches([]{}));
1051
1208
  }
1052
- #endif // GTEST_HAS_STD_FUNCTION_
1209
+ #endif // GTEST_LANG_CXX11
1053
1210
 
1054
1211
  // Tests that IsNull() describes itself properly.
1055
1212
  TEST(IsNullTest, CanDescribeSelf) {
@@ -1090,14 +1247,14 @@ TEST(NotNullTest, ReferenceToConstLinkedPtr) {
1090
1247
  EXPECT_TRUE(m.Matches(non_null_p));
1091
1248
  }
1092
1249
 
1093
- #if GTEST_HAS_STD_FUNCTION_
1250
+ #if GTEST_LANG_CXX11
1094
1251
  TEST(NotNullTest, StdFunction) {
1095
1252
  const Matcher<std::function<void()>> m = NotNull();
1096
1253
 
1097
1254
  EXPECT_TRUE(m.Matches([]{}));
1098
1255
  EXPECT_FALSE(m.Matches(std::function<void()>()));
1099
1256
  }
1100
- #endif // GTEST_HAS_STD_FUNCTION_
1257
+ #endif // GTEST_LANG_CXX11
1101
1258
 
1102
1259
  // Tests that NotNull() describes itself properly.
1103
1260
  TEST(NotNullTest, CanDescribeSelf) {
@@ -1121,7 +1278,7 @@ TEST(RefTest, CanDescribeSelf) {
1121
1278
  Matcher<int&> m = Ref(n);
1122
1279
  stringstream ss;
1123
1280
  ss << "references the variable @" << &n << " 5";
1124
- EXPECT_EQ(string(ss.str()), Describe(m));
1281
+ EXPECT_EQ(ss.str(), Describe(m));
1125
1282
  }
1126
1283
 
1127
1284
  // Test that Ref(non_const_varialbe) can be used as a matcher for a
@@ -1165,27 +1322,34 @@ TEST(RefTest, ExplainsResult) {
1165
1322
  // Tests string comparison matchers.
1166
1323
 
1167
1324
  TEST(StrEqTest, MatchesEqualString) {
1168
- Matcher<const char*> m = StrEq(string("Hello"));
1325
+ Matcher<const char*> m = StrEq(std::string("Hello"));
1169
1326
  EXPECT_TRUE(m.Matches("Hello"));
1170
1327
  EXPECT_FALSE(m.Matches("hello"));
1171
1328
  EXPECT_FALSE(m.Matches(NULL));
1172
1329
 
1173
- Matcher<const string&> m2 = StrEq("Hello");
1330
+ Matcher<const std::string&> m2 = StrEq("Hello");
1174
1331
  EXPECT_TRUE(m2.Matches("Hello"));
1175
1332
  EXPECT_FALSE(m2.Matches("Hi"));
1333
+
1334
+ #if GTEST_HAS_ABSL
1335
+ Matcher<const absl::string_view&> m3 = StrEq("Hello");
1336
+ EXPECT_TRUE(m3.Matches(absl::string_view("Hello")));
1337
+ EXPECT_FALSE(m3.Matches(absl::string_view("hello")));
1338
+ EXPECT_FALSE(m3.Matches(absl::string_view()));
1339
+ #endif // GTEST_HAS_ABSL
1176
1340
  }
1177
1341
 
1178
1342
  TEST(StrEqTest, CanDescribeSelf) {
1179
- Matcher<string> m = StrEq("Hi-\'\"?\\\a\b\f\n\r\t\v\xD3");
1343
+ Matcher<std::string> m = StrEq("Hi-\'\"?\\\a\b\f\n\r\t\v\xD3");
1180
1344
  EXPECT_EQ("is equal to \"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\xD3\"",
1181
1345
  Describe(m));
1182
1346
 
1183
- string str("01204500800");
1347
+ std::string str("01204500800");
1184
1348
  str[3] = '\0';
1185
- Matcher<string> m2 = StrEq(str);
1349
+ Matcher<std::string> m2 = StrEq(str);
1186
1350
  EXPECT_EQ("is equal to \"012\\04500800\"", Describe(m2));
1187
1351
  str[0] = str[6] = str[7] = str[9] = str[10] = '\0';
1188
- Matcher<string> m3 = StrEq(str);
1352
+ Matcher<std::string> m3 = StrEq(str);
1189
1353
  EXPECT_EQ("is equal to \"\\012\\045\\0\\08\\0\\0\"", Describe(m3));
1190
1354
  }
1191
1355
 
@@ -1195,9 +1359,16 @@ TEST(StrNeTest, MatchesUnequalString) {
1195
1359
  EXPECT_TRUE(m.Matches(NULL));
1196
1360
  EXPECT_FALSE(m.Matches("Hello"));
1197
1361
 
1198
- Matcher<string> m2 = StrNe(string("Hello"));
1362
+ Matcher<std::string> m2 = StrNe(std::string("Hello"));
1199
1363
  EXPECT_TRUE(m2.Matches("hello"));
1200
1364
  EXPECT_FALSE(m2.Matches("Hello"));
1365
+
1366
+ #if GTEST_HAS_ABSL
1367
+ Matcher<const absl::string_view> m3 = StrNe("Hello");
1368
+ EXPECT_TRUE(m3.Matches(absl::string_view("")));
1369
+ EXPECT_TRUE(m3.Matches(absl::string_view()));
1370
+ EXPECT_FALSE(m3.Matches(absl::string_view("Hello")));
1371
+ #endif // GTEST_HAS_ABSL
1201
1372
  }
1202
1373
 
1203
1374
  TEST(StrNeTest, CanDescribeSelf) {
@@ -1206,44 +1377,52 @@ TEST(StrNeTest, CanDescribeSelf) {
1206
1377
  }
1207
1378
 
1208
1379
  TEST(StrCaseEqTest, MatchesEqualStringIgnoringCase) {
1209
- Matcher<const char*> m = StrCaseEq(string("Hello"));
1380
+ Matcher<const char*> m = StrCaseEq(std::string("Hello"));
1210
1381
  EXPECT_TRUE(m.Matches("Hello"));
1211
1382
  EXPECT_TRUE(m.Matches("hello"));
1212
1383
  EXPECT_FALSE(m.Matches("Hi"));
1213
1384
  EXPECT_FALSE(m.Matches(NULL));
1214
1385
 
1215
- Matcher<const string&> m2 = StrCaseEq("Hello");
1386
+ Matcher<const std::string&> m2 = StrCaseEq("Hello");
1216
1387
  EXPECT_TRUE(m2.Matches("hello"));
1217
1388
  EXPECT_FALSE(m2.Matches("Hi"));
1389
+
1390
+ #if GTEST_HAS_ABSL
1391
+ Matcher<const absl::string_view&> m3 = StrCaseEq(std::string("Hello"));
1392
+ EXPECT_TRUE(m3.Matches(absl::string_view("Hello")));
1393
+ EXPECT_TRUE(m3.Matches(absl::string_view("hello")));
1394
+ EXPECT_FALSE(m3.Matches(absl::string_view("Hi")));
1395
+ EXPECT_FALSE(m3.Matches(absl::string_view()));
1396
+ #endif // GTEST_HAS_ABSL
1218
1397
  }
1219
1398
 
1220
1399
  TEST(StrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {
1221
- string str1("oabocdooeoo");
1222
- string str2("OABOCDOOEOO");
1223
- Matcher<const string&> m0 = StrCaseEq(str1);
1224
- EXPECT_FALSE(m0.Matches(str2 + string(1, '\0')));
1400
+ std::string str1("oabocdooeoo");
1401
+ std::string str2("OABOCDOOEOO");
1402
+ Matcher<const std::string&> m0 = StrCaseEq(str1);
1403
+ EXPECT_FALSE(m0.Matches(str2 + std::string(1, '\0')));
1225
1404
 
1226
1405
  str1[3] = str2[3] = '\0';
1227
- Matcher<const string&> m1 = StrCaseEq(str1);
1406
+ Matcher<const std::string&> m1 = StrCaseEq(str1);
1228
1407
  EXPECT_TRUE(m1.Matches(str2));
1229
1408
 
1230
1409
  str1[0] = str1[6] = str1[7] = str1[10] = '\0';
1231
1410
  str2[0] = str2[6] = str2[7] = str2[10] = '\0';
1232
- Matcher<const string&> m2 = StrCaseEq(str1);
1411
+ Matcher<const std::string&> m2 = StrCaseEq(str1);
1233
1412
  str1[9] = str2[9] = '\0';
1234
1413
  EXPECT_FALSE(m2.Matches(str2));
1235
1414
 
1236
- Matcher<const string&> m3 = StrCaseEq(str1);
1415
+ Matcher<const std::string&> m3 = StrCaseEq(str1);
1237
1416
  EXPECT_TRUE(m3.Matches(str2));
1238
1417
 
1239
1418
  EXPECT_FALSE(m3.Matches(str2 + "x"));
1240
1419
  str2.append(1, '\0');
1241
1420
  EXPECT_FALSE(m3.Matches(str2));
1242
- EXPECT_FALSE(m3.Matches(string(str2, 0, 9)));
1421
+ EXPECT_FALSE(m3.Matches(std::string(str2, 0, 9)));
1243
1422
  }
1244
1423
 
1245
1424
  TEST(StrCaseEqTest, CanDescribeSelf) {
1246
- Matcher<string> m = StrCaseEq("Hi");
1425
+ Matcher<std::string> m = StrCaseEq("Hi");
1247
1426
  EXPECT_EQ("is equal to (ignoring case) \"Hi\"", Describe(m));
1248
1427
  }
1249
1428
 
@@ -1254,9 +1433,17 @@ TEST(StrCaseNeTest, MatchesUnequalStringIgnoringCase) {
1254
1433
  EXPECT_FALSE(m.Matches("Hello"));
1255
1434
  EXPECT_FALSE(m.Matches("hello"));
1256
1435
 
1257
- Matcher<string> m2 = StrCaseNe(string("Hello"));
1436
+ Matcher<std::string> m2 = StrCaseNe(std::string("Hello"));
1258
1437
  EXPECT_TRUE(m2.Matches(""));
1259
1438
  EXPECT_FALSE(m2.Matches("Hello"));
1439
+
1440
+ #if GTEST_HAS_ABSL
1441
+ Matcher<const absl::string_view> m3 = StrCaseNe("Hello");
1442
+ EXPECT_TRUE(m3.Matches(absl::string_view("Hi")));
1443
+ EXPECT_TRUE(m3.Matches(absl::string_view()));
1444
+ EXPECT_FALSE(m3.Matches(absl::string_view("Hello")));
1445
+ EXPECT_FALSE(m3.Matches(absl::string_view("hello")));
1446
+ #endif // GTEST_HAS_ABSL
1260
1447
  }
1261
1448
 
1262
1449
  TEST(StrCaseNeTest, CanDescribeSelf) {
@@ -1266,9 +1453,9 @@ TEST(StrCaseNeTest, CanDescribeSelf) {
1266
1453
 
1267
1454
  // Tests that HasSubstr() works for matching string-typed values.
1268
1455
  TEST(HasSubstrTest, WorksForStringClasses) {
1269
- const Matcher<string> m1 = HasSubstr("foo");
1270
- EXPECT_TRUE(m1.Matches(string("I love food.")));
1271
- EXPECT_FALSE(m1.Matches(string("tofo")));
1456
+ const Matcher<std::string> m1 = HasSubstr("foo");
1457
+ EXPECT_TRUE(m1.Matches(std::string("I love food.")));
1458
+ EXPECT_FALSE(m1.Matches(std::string("tofo")));
1272
1459
 
1273
1460
  const Matcher<const std::string&> m2 = HasSubstr("foo");
1274
1461
  EXPECT_TRUE(m2.Matches(std::string("I love food.")));
@@ -1288,9 +1475,28 @@ TEST(HasSubstrTest, WorksForCStrings) {
1288
1475
  EXPECT_FALSE(m2.Matches(NULL));
1289
1476
  }
1290
1477
 
1478
+ #if GTEST_HAS_ABSL
1479
+ // Tests that HasSubstr() works for matching absl::string_view-typed values.
1480
+ TEST(HasSubstrTest, WorksForStringViewClasses) {
1481
+ const Matcher<absl::string_view> m1 = HasSubstr("foo");
1482
+ EXPECT_TRUE(m1.Matches(absl::string_view("I love food.")));
1483
+ EXPECT_FALSE(m1.Matches(absl::string_view("tofo")));
1484
+ EXPECT_FALSE(m1.Matches(absl::string_view()));
1485
+
1486
+ const Matcher<const absl::string_view&> m2 = HasSubstr("foo");
1487
+ EXPECT_TRUE(m2.Matches(absl::string_view("I love food.")));
1488
+ EXPECT_FALSE(m2.Matches(absl::string_view("tofo")));
1489
+ EXPECT_FALSE(m2.Matches(absl::string_view()));
1490
+
1491
+ const Matcher<const absl::string_view&> m3 = HasSubstr("");
1492
+ EXPECT_TRUE(m3.Matches(absl::string_view("foo")));
1493
+ EXPECT_FALSE(m3.Matches(absl::string_view()));
1494
+ }
1495
+ #endif // GTEST_HAS_ABSL
1496
+
1291
1497
  // Tests that HasSubstr(s) describes itself properly.
1292
1498
  TEST(HasSubstrTest, CanDescribeSelf) {
1293
- Matcher<string> m = HasSubstr("foo\n\"");
1499
+ Matcher<std::string> m = HasSubstr("foo\n\"");
1294
1500
  EXPECT_EQ("has substring \"foo\\n\\\"\"", Describe(m));
1295
1501
  }
1296
1502
 
@@ -1316,6 +1522,35 @@ TEST(KeyTest, MatchesCorrectly) {
1316
1522
  EXPECT_THAT(p, Not(Key(Lt(25))));
1317
1523
  }
1318
1524
 
1525
+ #if GTEST_LANG_CXX11
1526
+ template <size_t I>
1527
+ struct Tag {};
1528
+
1529
+ struct PairWithGet {
1530
+ int member_1;
1531
+ string member_2;
1532
+ using first_type = int;
1533
+ using second_type = string;
1534
+
1535
+ const int& GetImpl(Tag<0>) const { return member_1; }
1536
+ const string& GetImpl(Tag<1>) const { return member_2; }
1537
+ };
1538
+ template <size_t I>
1539
+ auto get(const PairWithGet& value) -> decltype(value.GetImpl(Tag<I>())) {
1540
+ return value.GetImpl(Tag<I>());
1541
+ }
1542
+ TEST(PairTest, MatchesPairWithGetCorrectly) {
1543
+ PairWithGet p{25, "foo"};
1544
+ EXPECT_THAT(p, Key(25));
1545
+ EXPECT_THAT(p, Not(Key(42)));
1546
+ EXPECT_THAT(p, Key(Ge(20)));
1547
+ EXPECT_THAT(p, Not(Key(Lt(25))));
1548
+
1549
+ std::vector<PairWithGet> v = {{11, "Foo"}, {29, "gMockIsBestMock"}};
1550
+ EXPECT_THAT(v, Contains(Key(29)));
1551
+ }
1552
+ #endif // GTEST_LANG_CXX11
1553
+
1319
1554
  TEST(KeyTest, SafelyCastsInnerMatcher) {
1320
1555
  Matcher<int> is_positive = Gt(0);
1321
1556
  Matcher<int> is_negative = Lt(0);
@@ -1453,15 +1688,27 @@ TEST(PairTest, InsideContainsUsingMap) {
1453
1688
  EXPECT_THAT(container, Not(Contains(Pair(3, _))));
1454
1689
  }
1455
1690
 
1691
+ #if GTEST_LANG_CXX11
1692
+ TEST(PairTest, UseGetInsteadOfMembers) {
1693
+ PairWithGet pair{7, "ABC"};
1694
+ EXPECT_THAT(pair, Pair(7, "ABC"));
1695
+ EXPECT_THAT(pair, Pair(Ge(7), HasSubstr("AB")));
1696
+ EXPECT_THAT(pair, Not(Pair(Lt(7), "ABC")));
1697
+
1698
+ std::vector<PairWithGet> v = {{11, "Foo"}, {29, "gMockIsBestMock"}};
1699
+ EXPECT_THAT(v, ElementsAre(Pair(11, string("Foo")), Pair(Ge(10), Not(""))));
1700
+ }
1701
+ #endif // GTEST_LANG_CXX11
1702
+
1456
1703
  // Tests StartsWith(s).
1457
1704
 
1458
1705
  TEST(StartsWithTest, MatchesStringWithGivenPrefix) {
1459
- const Matcher<const char*> m1 = StartsWith(string(""));
1706
+ const Matcher<const char*> m1 = StartsWith(std::string(""));
1460
1707
  EXPECT_TRUE(m1.Matches("Hi"));
1461
1708
  EXPECT_TRUE(m1.Matches(""));
1462
1709
  EXPECT_FALSE(m1.Matches(NULL));
1463
1710
 
1464
- const Matcher<const string&> m2 = StartsWith("Hi");
1711
+ const Matcher<const std::string&> m2 = StartsWith("Hi");
1465
1712
  EXPECT_TRUE(m2.Matches("Hi"));
1466
1713
  EXPECT_TRUE(m2.Matches("Hi Hi!"));
1467
1714
  EXPECT_TRUE(m2.Matches("High"));
@@ -1482,12 +1729,30 @@ TEST(EndsWithTest, MatchesStringWithGivenSuffix) {
1482
1729
  EXPECT_TRUE(m1.Matches(""));
1483
1730
  EXPECT_FALSE(m1.Matches(NULL));
1484
1731
 
1485
- const Matcher<const string&> m2 = EndsWith(string("Hi"));
1732
+ const Matcher<const std::string&> m2 = EndsWith(std::string("Hi"));
1486
1733
  EXPECT_TRUE(m2.Matches("Hi"));
1487
1734
  EXPECT_TRUE(m2.Matches("Wow Hi Hi"));
1488
1735
  EXPECT_TRUE(m2.Matches("Super Hi"));
1489
1736
  EXPECT_FALSE(m2.Matches("i"));
1490
1737
  EXPECT_FALSE(m2.Matches("Hi "));
1738
+
1739
+ #if GTEST_HAS_GLOBAL_STRING
1740
+ const Matcher<const ::string&> m3 = EndsWith(::string("Hi"));
1741
+ EXPECT_TRUE(m3.Matches("Hi"));
1742
+ EXPECT_TRUE(m3.Matches("Wow Hi Hi"));
1743
+ EXPECT_TRUE(m3.Matches("Super Hi"));
1744
+ EXPECT_FALSE(m3.Matches("i"));
1745
+ EXPECT_FALSE(m3.Matches("Hi "));
1746
+ #endif // GTEST_HAS_GLOBAL_STRING
1747
+
1748
+ #if GTEST_HAS_ABSL
1749
+ const Matcher<const absl::string_view&> m4 = EndsWith("");
1750
+ EXPECT_TRUE(m4.Matches("Hi"));
1751
+ EXPECT_TRUE(m4.Matches(""));
1752
+ // Default-constructed absl::string_view should not match anything, in order
1753
+ // to distinguish it from an empty string.
1754
+ EXPECT_FALSE(m4.Matches(absl::string_view()));
1755
+ #endif // GTEST_HAS_ABSL
1491
1756
  }
1492
1757
 
1493
1758
  TEST(EndsWithTest, CanDescribeSelf) {
@@ -1503,32 +1768,61 @@ TEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {
1503
1768
  EXPECT_TRUE(m1.Matches("abcz"));
1504
1769
  EXPECT_FALSE(m1.Matches(NULL));
1505
1770
 
1506
- const Matcher<const string&> m2 = MatchesRegex(new RE("a.*z"));
1771
+ const Matcher<const std::string&> m2 = MatchesRegex(new RE("a.*z"));
1507
1772
  EXPECT_TRUE(m2.Matches("azbz"));
1508
1773
  EXPECT_FALSE(m2.Matches("az1"));
1509
1774
  EXPECT_FALSE(m2.Matches("1az"));
1775
+
1776
+ #if GTEST_HAS_ABSL
1777
+ const Matcher<const absl::string_view&> m3 = MatchesRegex("a.*z");
1778
+ EXPECT_TRUE(m3.Matches(absl::string_view("az")));
1779
+ EXPECT_TRUE(m3.Matches(absl::string_view("abcz")));
1780
+ EXPECT_FALSE(m3.Matches(absl::string_view("1az")));
1781
+ // Default-constructed absl::string_view should not match anything, in order
1782
+ // to distinguish it from an empty string.
1783
+ EXPECT_FALSE(m3.Matches(absl::string_view()));
1784
+ const Matcher<const absl::string_view&> m4 = MatchesRegex("");
1785
+ EXPECT_FALSE(m4.Matches(absl::string_view()));
1786
+ #endif // GTEST_HAS_ABSL
1510
1787
  }
1511
1788
 
1512
1789
  TEST(MatchesRegexTest, CanDescribeSelf) {
1513
- Matcher<const std::string> m1 = MatchesRegex(string("Hi.*"));
1790
+ Matcher<const std::string> m1 = MatchesRegex(std::string("Hi.*"));
1514
1791
  EXPECT_EQ("matches regular expression \"Hi.*\"", Describe(m1));
1515
1792
 
1516
1793
  Matcher<const char*> m2 = MatchesRegex(new RE("a.*"));
1517
1794
  EXPECT_EQ("matches regular expression \"a.*\"", Describe(m2));
1795
+
1796
+ #if GTEST_HAS_ABSL
1797
+ Matcher<const absl::string_view> m3 = MatchesRegex(new RE("0.*"));
1798
+ EXPECT_EQ("matches regular expression \"0.*\"", Describe(m3));
1799
+ #endif // GTEST_HAS_ABSL
1518
1800
  }
1519
1801
 
1520
1802
  // Tests ContainsRegex().
1521
1803
 
1522
1804
  TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
1523
- const Matcher<const char*> m1 = ContainsRegex(string("a.*z"));
1805
+ const Matcher<const char*> m1 = ContainsRegex(std::string("a.*z"));
1524
1806
  EXPECT_TRUE(m1.Matches("az"));
1525
1807
  EXPECT_TRUE(m1.Matches("0abcz1"));
1526
1808
  EXPECT_FALSE(m1.Matches(NULL));
1527
1809
 
1528
- const Matcher<const string&> m2 = ContainsRegex(new RE("a.*z"));
1810
+ const Matcher<const std::string&> m2 = ContainsRegex(new RE("a.*z"));
1529
1811
  EXPECT_TRUE(m2.Matches("azbz"));
1530
1812
  EXPECT_TRUE(m2.Matches("az1"));
1531
1813
  EXPECT_FALSE(m2.Matches("1a"));
1814
+
1815
+ #if GTEST_HAS_ABSL
1816
+ const Matcher<const absl::string_view&> m3 = ContainsRegex(new RE("a.*z"));
1817
+ EXPECT_TRUE(m3.Matches(absl::string_view("azbz")));
1818
+ EXPECT_TRUE(m3.Matches(absl::string_view("az1")));
1819
+ EXPECT_FALSE(m3.Matches(absl::string_view("1a")));
1820
+ // Default-constructed absl::string_view should not match anything, in order
1821
+ // to distinguish it from an empty string.
1822
+ EXPECT_FALSE(m3.Matches(absl::string_view()));
1823
+ const Matcher<const absl::string_view&> m4 = ContainsRegex("");
1824
+ EXPECT_FALSE(m4.Matches(absl::string_view()));
1825
+ #endif // GTEST_HAS_ABSL
1532
1826
  }
1533
1827
 
1534
1828
  TEST(ContainsRegexTest, CanDescribeSelf) {
@@ -1537,6 +1831,11 @@ TEST(ContainsRegexTest, CanDescribeSelf) {
1537
1831
 
1538
1832
  Matcher<const char*> m2 = ContainsRegex(new RE("a.*"));
1539
1833
  EXPECT_EQ("contains regular expression \"a.*\"", Describe(m2));
1834
+
1835
+ #if GTEST_HAS_ABSL
1836
+ Matcher<const absl::string_view> m3 = ContainsRegex(new RE("0.*"));
1837
+ EXPECT_EQ("contains regular expression \"0.*\"", Describe(m3));
1838
+ #endif // GTEST_HAS_ABSL
1540
1839
  }
1541
1840
 
1542
1841
  // Tests for wide strings.
@@ -2014,6 +2313,150 @@ TEST(Ne2Test, CanDescribeSelf) {
2014
2313
  EXPECT_EQ("are an unequal pair", Describe(m));
2015
2314
  }
2016
2315
 
2316
+ // Tests that FloatEq() matches a 2-tuple where
2317
+ // FloatEq(first field) matches the second field.
2318
+ TEST(FloatEq2Test, MatchesEqualArguments) {
2319
+ typedef ::testing::tuple<float, float> Tpl;
2320
+ Matcher<const Tpl&> m = FloatEq();
2321
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2322
+ EXPECT_TRUE(m.Matches(Tpl(0.3f, 0.1f + 0.1f + 0.1f)));
2323
+ EXPECT_FALSE(m.Matches(Tpl(1.1f, 1.0f)));
2324
+ }
2325
+
2326
+ // Tests that FloatEq() describes itself properly.
2327
+ TEST(FloatEq2Test, CanDescribeSelf) {
2328
+ Matcher<const ::testing::tuple<float, float>&> m = FloatEq();
2329
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2330
+ }
2331
+
2332
+ // Tests that NanSensitiveFloatEq() matches a 2-tuple where
2333
+ // NanSensitiveFloatEq(first field) matches the second field.
2334
+ TEST(NanSensitiveFloatEqTest, MatchesEqualArgumentsWithNaN) {
2335
+ typedef ::testing::tuple<float, float> Tpl;
2336
+ Matcher<const Tpl&> m = NanSensitiveFloatEq();
2337
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2338
+ EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<float>::quiet_NaN(),
2339
+ std::numeric_limits<float>::quiet_NaN())));
2340
+ EXPECT_FALSE(m.Matches(Tpl(1.1f, 1.0f)));
2341
+ EXPECT_FALSE(m.Matches(Tpl(1.0f, std::numeric_limits<float>::quiet_NaN())));
2342
+ EXPECT_FALSE(m.Matches(Tpl(std::numeric_limits<float>::quiet_NaN(), 1.0f)));
2343
+ }
2344
+
2345
+ // Tests that NanSensitiveFloatEq() describes itself properly.
2346
+ TEST(NanSensitiveFloatEqTest, CanDescribeSelfWithNaNs) {
2347
+ Matcher<const ::testing::tuple<float, float>&> m = NanSensitiveFloatEq();
2348
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2349
+ }
2350
+
2351
+ // Tests that DoubleEq() matches a 2-tuple where
2352
+ // DoubleEq(first field) matches the second field.
2353
+ TEST(DoubleEq2Test, MatchesEqualArguments) {
2354
+ typedef ::testing::tuple<double, double> Tpl;
2355
+ Matcher<const Tpl&> m = DoubleEq();
2356
+ EXPECT_TRUE(m.Matches(Tpl(1.0, 1.0)));
2357
+ EXPECT_TRUE(m.Matches(Tpl(0.3, 0.1 + 0.1 + 0.1)));
2358
+ EXPECT_FALSE(m.Matches(Tpl(1.1, 1.0)));
2359
+ }
2360
+
2361
+ // Tests that DoubleEq() describes itself properly.
2362
+ TEST(DoubleEq2Test, CanDescribeSelf) {
2363
+ Matcher<const ::testing::tuple<double, double>&> m = DoubleEq();
2364
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2365
+ }
2366
+
2367
+ // Tests that NanSensitiveDoubleEq() matches a 2-tuple where
2368
+ // NanSensitiveDoubleEq(first field) matches the second field.
2369
+ TEST(NanSensitiveDoubleEqTest, MatchesEqualArgumentsWithNaN) {
2370
+ typedef ::testing::tuple<double, double> Tpl;
2371
+ Matcher<const Tpl&> m = NanSensitiveDoubleEq();
2372
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2373
+ EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<double>::quiet_NaN(),
2374
+ std::numeric_limits<double>::quiet_NaN())));
2375
+ EXPECT_FALSE(m.Matches(Tpl(1.1f, 1.0f)));
2376
+ EXPECT_FALSE(m.Matches(Tpl(1.0f, std::numeric_limits<double>::quiet_NaN())));
2377
+ EXPECT_FALSE(m.Matches(Tpl(std::numeric_limits<double>::quiet_NaN(), 1.0f)));
2378
+ }
2379
+
2380
+ // Tests that DoubleEq() describes itself properly.
2381
+ TEST(NanSensitiveDoubleEqTest, CanDescribeSelfWithNaNs) {
2382
+ Matcher<const ::testing::tuple<double, double>&> m = NanSensitiveDoubleEq();
2383
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2384
+ }
2385
+
2386
+ // Tests that FloatEq() matches a 2-tuple where
2387
+ // FloatNear(first field, max_abs_error) matches the second field.
2388
+ TEST(FloatNear2Test, MatchesEqualArguments) {
2389
+ typedef ::testing::tuple<float, float> Tpl;
2390
+ Matcher<const Tpl&> m = FloatNear(0.5f);
2391
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2392
+ EXPECT_TRUE(m.Matches(Tpl(1.3f, 1.0f)));
2393
+ EXPECT_FALSE(m.Matches(Tpl(1.8f, 1.0f)));
2394
+ }
2395
+
2396
+ // Tests that FloatNear() describes itself properly.
2397
+ TEST(FloatNear2Test, CanDescribeSelf) {
2398
+ Matcher<const ::testing::tuple<float, float>&> m = FloatNear(0.5f);
2399
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2400
+ }
2401
+
2402
+ // Tests that NanSensitiveFloatNear() matches a 2-tuple where
2403
+ // NanSensitiveFloatNear(first field) matches the second field.
2404
+ TEST(NanSensitiveFloatNearTest, MatchesNearbyArgumentsWithNaN) {
2405
+ typedef ::testing::tuple<float, float> Tpl;
2406
+ Matcher<const Tpl&> m = NanSensitiveFloatNear(0.5f);
2407
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2408
+ EXPECT_TRUE(m.Matches(Tpl(1.1f, 1.0f)));
2409
+ EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<float>::quiet_NaN(),
2410
+ std::numeric_limits<float>::quiet_NaN())));
2411
+ EXPECT_FALSE(m.Matches(Tpl(1.6f, 1.0f)));
2412
+ EXPECT_FALSE(m.Matches(Tpl(1.0f, std::numeric_limits<float>::quiet_NaN())));
2413
+ EXPECT_FALSE(m.Matches(Tpl(std::numeric_limits<float>::quiet_NaN(), 1.0f)));
2414
+ }
2415
+
2416
+ // Tests that NanSensitiveFloatNear() describes itself properly.
2417
+ TEST(NanSensitiveFloatNearTest, CanDescribeSelfWithNaNs) {
2418
+ Matcher<const ::testing::tuple<float, float>&> m =
2419
+ NanSensitiveFloatNear(0.5f);
2420
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2421
+ }
2422
+
2423
+ // Tests that FloatEq() matches a 2-tuple where
2424
+ // DoubleNear(first field, max_abs_error) matches the second field.
2425
+ TEST(DoubleNear2Test, MatchesEqualArguments) {
2426
+ typedef ::testing::tuple<double, double> Tpl;
2427
+ Matcher<const Tpl&> m = DoubleNear(0.5);
2428
+ EXPECT_TRUE(m.Matches(Tpl(1.0, 1.0)));
2429
+ EXPECT_TRUE(m.Matches(Tpl(1.3, 1.0)));
2430
+ EXPECT_FALSE(m.Matches(Tpl(1.8, 1.0)));
2431
+ }
2432
+
2433
+ // Tests that DoubleNear() describes itself properly.
2434
+ TEST(DoubleNear2Test, CanDescribeSelf) {
2435
+ Matcher<const ::testing::tuple<double, double>&> m = DoubleNear(0.5);
2436
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2437
+ }
2438
+
2439
+ // Tests that NanSensitiveDoubleNear() matches a 2-tuple where
2440
+ // NanSensitiveDoubleNear(first field) matches the second field.
2441
+ TEST(NanSensitiveDoubleNearTest, MatchesNearbyArgumentsWithNaN) {
2442
+ typedef ::testing::tuple<double, double> Tpl;
2443
+ Matcher<const Tpl&> m = NanSensitiveDoubleNear(0.5f);
2444
+ EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
2445
+ EXPECT_TRUE(m.Matches(Tpl(1.1f, 1.0f)));
2446
+ EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<double>::quiet_NaN(),
2447
+ std::numeric_limits<double>::quiet_NaN())));
2448
+ EXPECT_FALSE(m.Matches(Tpl(1.6f, 1.0f)));
2449
+ EXPECT_FALSE(m.Matches(Tpl(1.0f, std::numeric_limits<double>::quiet_NaN())));
2450
+ EXPECT_FALSE(m.Matches(Tpl(std::numeric_limits<double>::quiet_NaN(), 1.0f)));
2451
+ }
2452
+
2453
+ // Tests that NanSensitiveDoubleNear() describes itself properly.
2454
+ TEST(NanSensitiveDoubleNearTest, CanDescribeSelfWithNaNs) {
2455
+ Matcher<const ::testing::tuple<double, double>&> m =
2456
+ NanSensitiveDoubleNear(0.5f);
2457
+ EXPECT_EQ("are an almost-equal pair", Describe(m));
2458
+ }
2459
+
2017
2460
  // Tests that Not(m) matches any value that doesn't match m.
2018
2461
  TEST(NotTest, NegatesMatcher) {
2019
2462
  Matcher<int> m;
@@ -2102,7 +2545,7 @@ TEST(AllOfTest, VariadicMatchesWhenAllMatch) {
2102
2545
  ::testing::AllOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
2103
2546
  Matcher<int> m = AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),
2104
2547
  Ne(9), Ne(10), Ne(11));
2105
- EXPECT_THAT(Describe(m), EndsWith("and (isn't equal to 11))))))))))"));
2548
+ EXPECT_THAT(Describe(m), EndsWith("and (isn't equal to 11)"));
2106
2549
  AllOfMatches(11, m);
2107
2550
  AllOfMatches(50, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),
2108
2551
  Ne(9), Ne(10), Ne(11), Ne(12), Ne(13), Ne(14), Ne(15),
@@ -2296,7 +2739,7 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
2296
2739
  // on ADL.
2297
2740
  Matcher<int> m = ::testing::AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
2298
2741
 
2299
- EXPECT_THAT(Describe(m), EndsWith("or (is equal to 11))))))))))"));
2742
+ EXPECT_THAT(Describe(m), EndsWith("or (is equal to 11)"));
2300
2743
  AnyOfMatches(11, m);
2301
2744
  AnyOfMatches(50, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
2302
2745
  11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
@@ -2305,6 +2748,33 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
2305
2748
  41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
2306
2749
  }
2307
2750
 
2751
+ // Tests the variadic version of the ElementsAreMatcher
2752
+ TEST(ElementsAreTest, HugeMatcher) {
2753
+ vector<int> test_vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
2754
+
2755
+ EXPECT_THAT(test_vector,
2756
+ ElementsAre(Eq(1), Eq(2), Lt(13), Eq(4), Eq(5), Eq(6), Eq(7),
2757
+ Eq(8), Eq(9), Eq(10), Gt(1), Eq(12)));
2758
+ }
2759
+
2760
+ // Tests the variadic version of the UnorderedElementsAreMatcher
2761
+ TEST(ElementsAreTest, HugeMatcherStr) {
2762
+ vector<string> test_vector{
2763
+ "literal_string", "", "", "", "", "", "", "", "", "", "", ""};
2764
+
2765
+ EXPECT_THAT(test_vector, UnorderedElementsAre("literal_string", _, _, _, _, _,
2766
+ _, _, _, _, _, _));
2767
+ }
2768
+
2769
+ // Tests the variadic version of the UnorderedElementsAreMatcher
2770
+ TEST(ElementsAreTest, HugeMatcherUnordered) {
2771
+ vector<int> test_vector{2, 1, 8, 5, 4, 6, 7, 3, 9, 12, 11, 10};
2772
+
2773
+ EXPECT_THAT(test_vector, UnorderedElementsAre(
2774
+ Eq(2), Eq(1), Gt(7), Eq(5), Eq(4), Eq(6), Eq(7),
2775
+ Eq(3), Eq(9), Eq(12), Eq(11), Ne(122)));
2776
+ }
2777
+
2308
2778
  #endif // GTEST_LANG_CXX11
2309
2779
 
2310
2780
  // Tests that AnyOf(m1, ..., mn) describes itself properly.
@@ -2579,6 +3049,22 @@ TEST(ExplainMatchResultTest, WorksInsideMATCHER) {
2579
3049
  EXPECT_THAT(0, Really(Eq(0)));
2580
3050
  }
2581
3051
 
3052
+ TEST(DescribeMatcherTest, WorksWithValue) {
3053
+ EXPECT_EQ("is equal to 42", DescribeMatcher<int>(42));
3054
+ EXPECT_EQ("isn't equal to 42", DescribeMatcher<int>(42, true));
3055
+ }
3056
+
3057
+ TEST(DescribeMatcherTest, WorksWithMonomorphicMatcher) {
3058
+ const Matcher<int> monomorphic = Le(0);
3059
+ EXPECT_EQ("is <= 0", DescribeMatcher<int>(monomorphic));
3060
+ EXPECT_EQ("isn't <= 0", DescribeMatcher<int>(monomorphic, true));
3061
+ }
3062
+
3063
+ TEST(DescribeMatcherTest, WorksWithPolymorphicMatcher) {
3064
+ EXPECT_EQ("is even", DescribeMatcher<int>(PolymorphicIsEven()));
3065
+ EXPECT_EQ("is odd", DescribeMatcher<int>(PolymorphicIsEven(), true));
3066
+ }
3067
+
2582
3068
  TEST(AllArgsTest, WorksForTuple) {
2583
3069
  EXPECT_THAT(make_tuple(1, 2L), AllArgs(Lt()));
2584
3070
  EXPECT_THAT(make_tuple(2L, 1), Not(AllArgs(Lt())));
@@ -2613,6 +3099,44 @@ TEST(AllArgsTest, WorksInWithClause) {
2613
3099
  EXPECT_EQ(2, helper.Helper('a', 1));
2614
3100
  }
2615
3101
 
3102
+ class OptionalMatchersHelper {
3103
+ public:
3104
+ OptionalMatchersHelper() {}
3105
+
3106
+ MOCK_METHOD0(NoArgs, int());
3107
+
3108
+ MOCK_METHOD1(OneArg, int(int y));
3109
+
3110
+ MOCK_METHOD2(TwoArgs, int(char x, int y));
3111
+
3112
+ MOCK_METHOD1(Overloaded, int(char x));
3113
+ MOCK_METHOD2(Overloaded, int(char x, int y));
3114
+
3115
+ private:
3116
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(OptionalMatchersHelper);
3117
+ };
3118
+
3119
+ TEST(AllArgsTest, WorksWithoutMatchers) {
3120
+ OptionalMatchersHelper helper;
3121
+
3122
+ ON_CALL(helper, NoArgs).WillByDefault(Return(10));
3123
+ ON_CALL(helper, OneArg).WillByDefault(Return(20));
3124
+ ON_CALL(helper, TwoArgs).WillByDefault(Return(30));
3125
+
3126
+ EXPECT_EQ(10, helper.NoArgs());
3127
+ EXPECT_EQ(20, helper.OneArg(1));
3128
+ EXPECT_EQ(30, helper.TwoArgs('\1', 2));
3129
+
3130
+ EXPECT_CALL(helper, NoArgs).Times(1);
3131
+ EXPECT_CALL(helper, OneArg).WillOnce(Return(100));
3132
+ EXPECT_CALL(helper, OneArg(17)).WillOnce(Return(200));
3133
+ EXPECT_CALL(helper, TwoArgs).Times(0);
3134
+
3135
+ EXPECT_EQ(10, helper.NoArgs());
3136
+ EXPECT_EQ(100, helper.OneArg(1));
3137
+ EXPECT_EQ(200, helper.OneArg(17));
3138
+ }
3139
+
2616
3140
  // Tests that ASSERT_THAT() and EXPECT_THAT() work when the value
2617
3141
  // matches the matcher.
2618
3142
  TEST(MatcherAssertionTest, WorksWhenMatcherIsSatisfied) {
@@ -2681,9 +3205,9 @@ TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
2681
3205
  Matcher<const char*> starts_with_he = StartsWith("he");
2682
3206
  ASSERT_THAT("hello", starts_with_he);
2683
3207
 
2684
- Matcher<const string&> ends_with_ok = EndsWith("ok");
3208
+ Matcher<const std::string&> ends_with_ok = EndsWith("ok");
2685
3209
  ASSERT_THAT("book", ends_with_ok);
2686
- const string bad = "bad";
3210
+ const std::string bad = "bad";
2687
3211
  EXPECT_NONFATAL_FAILURE(EXPECT_THAT(bad, ends_with_ok),
2688
3212
  "Value of: bad\n"
2689
3213
  "Expected: ends with \"ok\"\n"
@@ -2708,18 +3232,22 @@ class FloatingPointTest : public testing::Test {
2708
3232
  zero_bits_(Floating(0).bits()),
2709
3233
  one_bits_(Floating(1).bits()),
2710
3234
  infinity_bits_(Floating(Floating::Infinity()).bits()),
2711
- close_to_positive_zero_(AsBits(zero_bits_ + max_ulps_/2)),
2712
- close_to_negative_zero_(AsBits(zero_bits_ + max_ulps_ - max_ulps_/2)),
2713
- further_from_negative_zero_(-AsBits(
3235
+ close_to_positive_zero_(
3236
+ Floating::ReinterpretBits(zero_bits_ + max_ulps_/2)),
3237
+ close_to_negative_zero_(
3238
+ -Floating::ReinterpretBits(zero_bits_ + max_ulps_ - max_ulps_/2)),
3239
+ further_from_negative_zero_(-Floating::ReinterpretBits(
2714
3240
  zero_bits_ + max_ulps_ + 1 - max_ulps_/2)),
2715
- close_to_one_(AsBits(one_bits_ + max_ulps_)),
2716
- further_from_one_(AsBits(one_bits_ + max_ulps_ + 1)),
3241
+ close_to_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_)),
3242
+ further_from_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_ + 1)),
2717
3243
  infinity_(Floating::Infinity()),
2718
- close_to_infinity_(AsBits(infinity_bits_ - max_ulps_)),
2719
- further_from_infinity_(AsBits(infinity_bits_ - max_ulps_ - 1)),
3244
+ close_to_infinity_(
3245
+ Floating::ReinterpretBits(infinity_bits_ - max_ulps_)),
3246
+ further_from_infinity_(
3247
+ Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)),
2720
3248
  max_(Floating::Max()),
2721
- nan1_(AsBits(Floating::kExponentBitMask | 1)),
2722
- nan2_(AsBits(Floating::kExponentBitMask | 200)) {
3249
+ nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)),
3250
+ nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {
2723
3251
  }
2724
3252
 
2725
3253
  void TestSize() {
@@ -2774,7 +3302,7 @@ class FloatingPointTest : public testing::Test {
2774
3302
 
2775
3303
  // Pre-calculated numbers to be used by the tests.
2776
3304
 
2777
- const size_t max_ulps_;
3305
+ const Bits max_ulps_;
2778
3306
 
2779
3307
  const Bits zero_bits_; // The bits that represent 0.0.
2780
3308
  const Bits one_bits_; // The bits that represent 1.0.
@@ -2800,12 +3328,6 @@ class FloatingPointTest : public testing::Test {
2800
3328
  // Some NaNs.
2801
3329
  const RawType nan1_;
2802
3330
  const RawType nan2_;
2803
-
2804
- private:
2805
- template <typename T>
2806
- static RawType AsBits(T value) {
2807
- return Floating::ReinterpretBits(static_cast<Bits>(value));
2808
- }
2809
3331
  };
2810
3332
 
2811
3333
  // Tests floating-point matchers with fixed epsilons.
@@ -3095,7 +3617,8 @@ TEST_F(DoubleNearTest, ExplainsResultWhenMatchFails) {
3095
3617
  EXPECT_EQ("which is 0.2 from 2", Explain(DoubleNear(2.0, 0.1), 2.2));
3096
3618
  EXPECT_EQ("which is -0.3 from 2", Explain(DoubleNear(2.0, 0.1), 1.7));
3097
3619
 
3098
- const string explanation = Explain(DoubleNear(2.1, 1e-10), 2.1 + 1.2e-10);
3620
+ const std::string explanation =
3621
+ Explain(DoubleNear(2.1, 1e-10), 2.1 + 1.2e-10);
3099
3622
  // Different C++ implementations may print floating-point numbers
3100
3623
  // slightly differently.
3101
3624
  EXPECT_TRUE(explanation == "which is 1.2e-10 from 2.1" || // GCC
@@ -3182,7 +3705,6 @@ MATCHER_P(FieldIIs, inner_matcher, "") {
3182
3705
  }
3183
3706
 
3184
3707
  #if GTEST_HAS_RTTI
3185
-
3186
3708
  TEST(WhenDynamicCastToTest, SameType) {
3187
3709
  Derived derived;
3188
3710
  derived.i = 4;
@@ -3240,7 +3762,7 @@ TEST(WhenDynamicCastToTest, AmbiguousCast) {
3240
3762
 
3241
3763
  TEST(WhenDynamicCastToTest, Describe) {
3242
3764
  Matcher<Base*> matcher = WhenDynamicCastTo<Derived*>(Pointee(_));
3243
- const string prefix =
3765
+ const std::string prefix =
3244
3766
  "when dynamic_cast to " + internal::GetTypeName<Derived*>() + ", ";
3245
3767
  EXPECT_EQ(prefix + "points to a value that is anything", Describe(matcher));
3246
3768
  EXPECT_EQ(prefix + "does not point to a value that is anything",
@@ -3274,7 +3796,6 @@ TEST(WhenDynamicCastToTest, BadReference) {
3274
3796
  Base& as_base_ref = derived;
3275
3797
  EXPECT_THAT(as_base_ref, Not(WhenDynamicCastTo<const OtherDerived&>(_)));
3276
3798
  }
3277
-
3278
3799
  #endif // GTEST_HAS_RTTI
3279
3800
 
3280
3801
  // Minimal const-propagating pointer.
@@ -3333,9 +3854,9 @@ TEST(PointeeTest, CanDescribeSelf) {
3333
3854
  }
3334
3855
 
3335
3856
  TEST(PointeeTest, CanExplainMatchResult) {
3336
- const Matcher<const string*> m = Pointee(StartsWith("Hi"));
3857
+ const Matcher<const std::string*> m = Pointee(StartsWith("Hi"));
3337
3858
 
3338
- EXPECT_EQ("", Explain(m, static_cast<const string*>(NULL)));
3859
+ EXPECT_EQ("", Explain(m, static_cast<const std::string*>(NULL)));
3339
3860
 
3340
3861
  const Matcher<long*> m2 = Pointee(GreaterThan(1)); // NOLINT
3341
3862
  long n = 3; // NOLINT
@@ -3396,11 +3917,14 @@ struct DerivedStruct : public AStruct {
3396
3917
  // Tests that Field(&Foo::field, ...) works when field is non-const.
3397
3918
  TEST(FieldTest, WorksForNonConstField) {
3398
3919
  Matcher<AStruct> m = Field(&AStruct::x, Ge(0));
3920
+ Matcher<AStruct> m_with_name = Field("x", &AStruct::x, Ge(0));
3399
3921
 
3400
3922
  AStruct a;
3401
3923
  EXPECT_TRUE(m.Matches(a));
3924
+ EXPECT_TRUE(m_with_name.Matches(a));
3402
3925
  a.x = -1;
3403
3926
  EXPECT_FALSE(m.Matches(a));
3927
+ EXPECT_FALSE(m_with_name.Matches(a));
3404
3928
  }
3405
3929
 
3406
3930
  // Tests that Field(&Foo::field, ...) works when field is const.
@@ -3408,9 +3932,13 @@ TEST(FieldTest, WorksForConstField) {
3408
3932
  AStruct a;
3409
3933
 
3410
3934
  Matcher<AStruct> m = Field(&AStruct::y, Ge(0.0));
3935
+ Matcher<AStruct> m_with_name = Field("y", &AStruct::y, Ge(0.0));
3411
3936
  EXPECT_TRUE(m.Matches(a));
3937
+ EXPECT_TRUE(m_with_name.Matches(a));
3412
3938
  m = Field(&AStruct::y, Le(0.0));
3939
+ m_with_name = Field("y", &AStruct::y, Le(0.0));
3413
3940
  EXPECT_FALSE(m.Matches(a));
3941
+ EXPECT_FALSE(m_with_name.Matches(a));
3414
3942
  }
3415
3943
 
3416
3944
  // Tests that Field(&Foo::field, ...) works when field is not copyable.
@@ -3484,6 +4012,14 @@ TEST(FieldTest, CanDescribeSelf) {
3484
4012
  EXPECT_EQ("is an object whose given field isn't >= 0", DescribeNegation(m));
3485
4013
  }
3486
4014
 
4015
+ TEST(FieldTest, CanDescribeSelfWithFieldName) {
4016
+ Matcher<const AStruct&> m = Field("field_name", &AStruct::x, Ge(0));
4017
+
4018
+ EXPECT_EQ("is an object whose field `field_name` is >= 0", Describe(m));
4019
+ EXPECT_EQ("is an object whose field `field_name` isn't >= 0",
4020
+ DescribeNegation(m));
4021
+ }
4022
+
3487
4023
  // Tests that Field() can explain the match result.
3488
4024
  TEST(FieldTest, CanExplainMatchResult) {
3489
4025
  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));
@@ -3498,6 +4034,19 @@ TEST(FieldTest, CanExplainMatchResult) {
3498
4034
  Explain(m, a));
3499
4035
  }
3500
4036
 
4037
+ TEST(FieldTest, CanExplainMatchResultWithFieldName) {
4038
+ Matcher<const AStruct&> m = Field("field_name", &AStruct::x, Ge(0));
4039
+
4040
+ AStruct a;
4041
+ a.x = 1;
4042
+ EXPECT_EQ("whose field `field_name` is 1" + OfType("int"), Explain(m, a));
4043
+
4044
+ m = Field("field_name", &AStruct::x, GreaterThan(0));
4045
+ EXPECT_EQ("whose field `field_name` is 1" + OfType("int") +
4046
+ ", which is 1 more than 0",
4047
+ Explain(m, a));
4048
+ }
4049
+
3501
4050
  // Tests that Field() works when the argument is a pointer to const.
3502
4051
  TEST(FieldForPointerTest, WorksForPointerToConst) {
3503
4052
  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));
@@ -3555,6 +4104,14 @@ TEST(FieldForPointerTest, CanDescribeSelf) {
3555
4104
  EXPECT_EQ("is an object whose given field isn't >= 0", DescribeNegation(m));
3556
4105
  }
3557
4106
 
4107
+ TEST(FieldForPointerTest, CanDescribeSelfWithFieldName) {
4108
+ Matcher<const AStruct*> m = Field("field_name", &AStruct::x, Ge(0));
4109
+
4110
+ EXPECT_EQ("is an object whose field `field_name` is >= 0", Describe(m));
4111
+ EXPECT_EQ("is an object whose field `field_name` isn't >= 0",
4112
+ DescribeNegation(m));
4113
+ }
4114
+
3558
4115
  // Tests that Field() can explain the result of matching a pointer.
3559
4116
  TEST(FieldForPointerTest, CanExplainMatchResult) {
3560
4117
  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));
@@ -3570,6 +4127,22 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
3570
4127
  ", which is 1 more than 0", Explain(m, &a));
3571
4128
  }
3572
4129
 
4130
+ TEST(FieldForPointerTest, CanExplainMatchResultWithFieldName) {
4131
+ Matcher<const AStruct*> m = Field("field_name", &AStruct::x, Ge(0));
4132
+
4133
+ AStruct a;
4134
+ a.x = 1;
4135
+ EXPECT_EQ("", Explain(m, static_cast<const AStruct*>(NULL)));
4136
+ EXPECT_EQ(
4137
+ "which points to an object whose field `field_name` is 1" + OfType("int"),
4138
+ Explain(m, &a));
4139
+
4140
+ m = Field("field_name", &AStruct::x, GreaterThan(0));
4141
+ EXPECT_EQ("which points to an object whose field `field_name` is 1" +
4142
+ OfType("int") + ", which is 1 more than 0",
4143
+ Explain(m, &a));
4144
+ }
4145
+
3573
4146
  // A user-defined class for testing Property().
3574
4147
  class AClass {
3575
4148
  public:
@@ -3581,15 +4154,20 @@ class AClass {
3581
4154
  void set_n(int new_n) { n_ = new_n; }
3582
4155
 
3583
4156
  // A getter that returns a reference to const.
3584
- const string& s() const { return s_; }
4157
+ const std::string& s() const { return s_; }
4158
+
4159
+ #if GTEST_LANG_CXX11
4160
+ const std::string& s_ref() const & { return s_; }
4161
+ #endif
3585
4162
 
3586
- void set_s(const string& new_s) { s_ = new_s; }
4163
+ void set_s(const std::string& new_s) { s_ = new_s; }
3587
4164
 
3588
4165
  // A getter that returns a reference to non-const.
3589
4166
  double& x() const { return x_; }
4167
+
3590
4168
  private:
3591
4169
  int n_;
3592
- string s_;
4170
+ std::string s_;
3593
4171
 
3594
4172
  static double x_;
3595
4173
  };
@@ -3608,28 +4186,50 @@ class DerivedClass : public AClass {
3608
4186
  // returns a non-reference.
3609
4187
  TEST(PropertyTest, WorksForNonReferenceProperty) {
3610
4188
  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));
4189
+ Matcher<const AClass&> m_with_name = Property("n", &AClass::n, Ge(0));
3611
4190
 
3612
4191
  AClass a;
3613
4192
  a.set_n(1);
3614
4193
  EXPECT_TRUE(m.Matches(a));
4194
+ EXPECT_TRUE(m_with_name.Matches(a));
3615
4195
 
3616
4196
  a.set_n(-1);
3617
4197
  EXPECT_FALSE(m.Matches(a));
4198
+ EXPECT_FALSE(m_with_name.Matches(a));
3618
4199
  }
3619
4200
 
3620
4201
  // Tests that Property(&Foo::property, ...) works when property()
3621
4202
  // returns a reference to const.
3622
4203
  TEST(PropertyTest, WorksForReferenceToConstProperty) {
3623
4204
  Matcher<const AClass&> m = Property(&AClass::s, StartsWith("hi"));
4205
+ Matcher<const AClass&> m_with_name =
4206
+ Property("s", &AClass::s, StartsWith("hi"));
3624
4207
 
3625
4208
  AClass a;
3626
4209
  a.set_s("hill");
3627
4210
  EXPECT_TRUE(m.Matches(a));
4211
+ EXPECT_TRUE(m_with_name.Matches(a));
3628
4212
 
3629
4213
  a.set_s("hole");
3630
4214
  EXPECT_FALSE(m.Matches(a));
4215
+ EXPECT_FALSE(m_with_name.Matches(a));
3631
4216
  }
3632
4217
 
4218
+ #if GTEST_LANG_CXX11
4219
+ // Tests that Property(&Foo::property, ...) works when property() is
4220
+ // ref-qualified.
4221
+ TEST(PropertyTest, WorksForRefQualifiedProperty) {
4222
+ Matcher<const AClass&> m = Property(&AClass::s_ref, StartsWith("hi"));
4223
+
4224
+ AClass a;
4225
+ a.set_s("hill");
4226
+ EXPECT_TRUE(m.Matches(a));
4227
+
4228
+ a.set_s("hole");
4229
+ EXPECT_FALSE(m.Matches(a));
4230
+ }
4231
+ #endif
4232
+
3633
4233
  // Tests that Property(&Foo::property, ...) works when property()
3634
4234
  // returns a reference to non-const.
3635
4235
  TEST(PropertyTest, WorksForReferenceToNonConstProperty) {
@@ -3678,10 +4278,15 @@ TEST(PropertyTest, WorksForCompatibleMatcherType) {
3678
4278
  Matcher<const AClass&> m = Property(&AClass::n,
3679
4279
  Matcher<signed char>(Ge(0)));
3680
4280
 
4281
+ Matcher<const AClass&> m_with_name =
4282
+ Property("n", &AClass::n, Matcher<signed char>(Ge(0)));
4283
+
3681
4284
  AClass a;
3682
4285
  EXPECT_TRUE(m.Matches(a));
4286
+ EXPECT_TRUE(m_with_name.Matches(a));
3683
4287
  a.set_n(-1);
3684
4288
  EXPECT_FALSE(m.Matches(a));
4289
+ EXPECT_FALSE(m_with_name.Matches(a));
3685
4290
  }
3686
4291
 
3687
4292
  // Tests that Property() can describe itself.
@@ -3693,6 +4298,14 @@ TEST(PropertyTest, CanDescribeSelf) {
3693
4298
  DescribeNegation(m));
3694
4299
  }
3695
4300
 
4301
+ TEST(PropertyTest, CanDescribeSelfWithPropertyName) {
4302
+ Matcher<const AClass&> m = Property("fancy_name", &AClass::n, Ge(0));
4303
+
4304
+ EXPECT_EQ("is an object whose property `fancy_name` is >= 0", Describe(m));
4305
+ EXPECT_EQ("is an object whose property `fancy_name` isn't >= 0",
4306
+ DescribeNegation(m));
4307
+ }
4308
+
3696
4309
  // Tests that Property() can explain the match result.
3697
4310
  TEST(PropertyTest, CanExplainMatchResult) {
3698
4311
  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));
@@ -3707,6 +4320,19 @@ TEST(PropertyTest, CanExplainMatchResult) {
3707
4320
  Explain(m, a));
3708
4321
  }
3709
4322
 
4323
+ TEST(PropertyTest, CanExplainMatchResultWithPropertyName) {
4324
+ Matcher<const AClass&> m = Property("fancy_name", &AClass::n, Ge(0));
4325
+
4326
+ AClass a;
4327
+ a.set_n(1);
4328
+ EXPECT_EQ("whose property `fancy_name` is 1" + OfType("int"), Explain(m, a));
4329
+
4330
+ m = Property("fancy_name", &AClass::n, GreaterThan(0));
4331
+ EXPECT_EQ("whose property `fancy_name` is 1" + OfType("int") +
4332
+ ", which is 1 more than 0",
4333
+ Explain(m, a));
4334
+ }
4335
+
3710
4336
  // Tests that Property() works when the argument is a pointer to const.
3711
4337
  TEST(PropertyForPointerTest, WorksForPointerToConst) {
3712
4338
  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));
@@ -3774,6 +4400,14 @@ TEST(PropertyForPointerTest, CanDescribeSelf) {
3774
4400
  DescribeNegation(m));
3775
4401
  }
3776
4402
 
4403
+ TEST(PropertyForPointerTest, CanDescribeSelfWithPropertyDescription) {
4404
+ Matcher<const AClass*> m = Property("fancy_name", &AClass::n, Ge(0));
4405
+
4406
+ EXPECT_EQ("is an object whose property `fancy_name` is >= 0", Describe(m));
4407
+ EXPECT_EQ("is an object whose property `fancy_name` isn't >= 0",
4408
+ DescribeNegation(m));
4409
+ }
4410
+
3777
4411
  // Tests that Property() can explain the result of matching a pointer.
3778
4412
  TEST(PropertyForPointerTest, CanExplainMatchResult) {
3779
4413
  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));
@@ -3791,14 +4425,32 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
3791
4425
  Explain(m, &a));
3792
4426
  }
3793
4427
 
4428
+ TEST(PropertyForPointerTest, CanExplainMatchResultWithPropertyName) {
4429
+ Matcher<const AClass*> m = Property("fancy_name", &AClass::n, Ge(0));
4430
+
4431
+ AClass a;
4432
+ a.set_n(1);
4433
+ EXPECT_EQ("", Explain(m, static_cast<const AClass*>(NULL)));
4434
+ EXPECT_EQ("which points to an object whose property `fancy_name` is 1" +
4435
+ OfType("int"),
4436
+ Explain(m, &a));
4437
+
4438
+ m = Property("fancy_name", &AClass::n, GreaterThan(0));
4439
+ EXPECT_EQ("which points to an object whose property `fancy_name` is 1" +
4440
+ OfType("int") + ", which is 1 more than 0",
4441
+ Explain(m, &a));
4442
+ }
4443
+
3794
4444
  // Tests ResultOf.
3795
4445
 
3796
4446
  // Tests that ResultOf(f, ...) compiles and works as expected when f is a
3797
4447
  // function pointer.
3798
- string IntToStringFunction(int input) { return input == 1 ? "foo" : "bar"; }
4448
+ std::string IntToStringFunction(int input) {
4449
+ return input == 1 ? "foo" : "bar";
4450
+ }
3799
4451
 
3800
4452
  TEST(ResultOfTest, WorksForFunctionPointers) {
3801
- Matcher<int> matcher = ResultOf(&IntToStringFunction, Eq(string("foo")));
4453
+ Matcher<int> matcher = ResultOf(&IntToStringFunction, Eq(std::string("foo")));
3802
4454
 
3803
4455
  EXPECT_TRUE(matcher.Matches(1));
3804
4456
  EXPECT_FALSE(matcher.Matches(2));
@@ -3864,12 +4516,12 @@ TEST(ResultOfTest, WorksForReferenceToNonConstResults) {
3864
4516
 
3865
4517
  // Tests that ResultOf(f, ...) compiles and works as expected when f(x)
3866
4518
  // returns a reference to const.
3867
- const string& StringFunction(const string& input) { return input; }
4519
+ const std::string& StringFunction(const std::string& input) { return input; }
3868
4520
 
3869
4521
  TEST(ResultOfTest, WorksForReferenceToConstResults) {
3870
- string s = "foo";
3871
- string s2 = s;
3872
- Matcher<const string&> matcher = ResultOf(&StringFunction, Ref(s));
4522
+ std::string s = "foo";
4523
+ std::string s2 = s;
4524
+ Matcher<const std::string&> matcher = ResultOf(&StringFunction, Ref(s));
3873
4525
 
3874
4526
  EXPECT_TRUE(matcher.Matches(s));
3875
4527
  EXPECT_FALSE(matcher.Matches(s2));
@@ -3889,8 +4541,9 @@ TEST(ResultOfTest, WorksForCompatibleMatcherTypes) {
3889
4541
  // a NULL function pointer.
3890
4542
  TEST(ResultOfDeathTest, DiesOnNullFunctionPointers) {
3891
4543
  EXPECT_DEATH_IF_SUPPORTED(
3892
- ResultOf(static_cast<string(*)(int dummy)>(NULL), Eq(string("foo"))),
3893
- "NULL function pointer is passed into ResultOf\\(\\)\\.");
4544
+ ResultOf(static_cast<std::string (*)(int dummy)>(NULL),
4545
+ Eq(std::string("foo"))),
4546
+ "NULL function pointer is passed into ResultOf\\(\\)\\.");
3894
4547
  }
3895
4548
 
3896
4549
  // Tests that ResultOf(f, ...) compiles and works as expected when f is a
@@ -3903,14 +4556,14 @@ TEST(ResultOfTest, WorksForFunctionReferences) {
3903
4556
 
3904
4557
  // Tests that ResultOf(f, ...) compiles and works as expected when f is a
3905
4558
  // function object.
3906
- struct Functor : public ::std::unary_function<int, string> {
4559
+ struct Functor : public ::std::unary_function<int, std::string> {
3907
4560
  result_type operator()(argument_type input) const {
3908
4561
  return IntToStringFunction(input);
3909
4562
  }
3910
4563
  };
3911
4564
 
3912
4565
  TEST(ResultOfTest, WorksForFunctors) {
3913
- Matcher<int> matcher = ResultOf(Functor(), Eq(string("foo")));
4566
+ Matcher<int> matcher = ResultOf(Functor(), Eq(std::string("foo")));
3914
4567
 
3915
4568
  EXPECT_TRUE(matcher.Matches(1));
3916
4569
  EXPECT_FALSE(matcher.Matches(2));
@@ -4076,11 +4729,11 @@ TEST(IsEmptyTest, ImplementsIsEmpty) {
4076
4729
  }
4077
4730
 
4078
4731
  TEST(IsEmptyTest, WorksWithString) {
4079
- string text;
4732
+ std::string text;
4080
4733
  EXPECT_THAT(text, IsEmpty());
4081
4734
  text = "foo";
4082
4735
  EXPECT_THAT(text, Not(IsEmpty()));
4083
- text = string("\0", 1);
4736
+ text = std::string("\0", 1);
4084
4737
  EXPECT_THAT(text, Not(IsEmpty()));
4085
4738
  }
4086
4739
 
@@ -4098,6 +4751,44 @@ TEST(IsEmptyTest, ExplainsResult) {
4098
4751
  EXPECT_EQ("whose size is 1", Explain(m, container));
4099
4752
  }
4100
4753
 
4754
+ TEST(IsTrueTest, IsTrueIsFalse) {
4755
+ EXPECT_THAT(true, IsTrue());
4756
+ EXPECT_THAT(false, IsFalse());
4757
+ EXPECT_THAT(true, Not(IsFalse()));
4758
+ EXPECT_THAT(false, Not(IsTrue()));
4759
+ EXPECT_THAT(0, Not(IsTrue()));
4760
+ EXPECT_THAT(0, IsFalse());
4761
+ EXPECT_THAT(NULL, Not(IsTrue()));
4762
+ EXPECT_THAT(NULL, IsFalse());
4763
+ EXPECT_THAT(-1, IsTrue());
4764
+ EXPECT_THAT(-1, Not(IsFalse()));
4765
+ EXPECT_THAT(1, IsTrue());
4766
+ EXPECT_THAT(1, Not(IsFalse()));
4767
+ EXPECT_THAT(2, IsTrue());
4768
+ EXPECT_THAT(2, Not(IsFalse()));
4769
+ int a = 42;
4770
+ EXPECT_THAT(a, IsTrue());
4771
+ EXPECT_THAT(a, Not(IsFalse()));
4772
+ EXPECT_THAT(&a, IsTrue());
4773
+ EXPECT_THAT(&a, Not(IsFalse()));
4774
+ EXPECT_THAT(false, Not(IsTrue()));
4775
+ EXPECT_THAT(true, Not(IsFalse()));
4776
+ #if GTEST_LANG_CXX11
4777
+ EXPECT_THAT(std::true_type(), IsTrue());
4778
+ EXPECT_THAT(std::true_type(), Not(IsFalse()));
4779
+ EXPECT_THAT(std::false_type(), IsFalse());
4780
+ EXPECT_THAT(std::false_type(), Not(IsTrue()));
4781
+ EXPECT_THAT(nullptr, Not(IsTrue()));
4782
+ EXPECT_THAT(nullptr, IsFalse());
4783
+ std::unique_ptr<int> null_unique;
4784
+ std::unique_ptr<int> nonnull_unique(new int(0));
4785
+ EXPECT_THAT(null_unique, Not(IsTrue()));
4786
+ EXPECT_THAT(null_unique, IsFalse());
4787
+ EXPECT_THAT(nonnull_unique, IsTrue());
4788
+ EXPECT_THAT(nonnull_unique, Not(IsFalse()));
4789
+ #endif // GTEST_LANG_CXX11
4790
+ }
4791
+
4101
4792
  TEST(SizeIsTest, ImplementsSizeIs) {
4102
4793
  vector<int> container;
4103
4794
  EXPECT_THAT(container, SizeIs(0));
@@ -4111,7 +4802,7 @@ TEST(SizeIsTest, ImplementsSizeIs) {
4111
4802
  }
4112
4803
 
4113
4804
  TEST(SizeIsTest, WorksWithMap) {
4114
- map<string, int> container;
4805
+ map<std::string, int> container;
4115
4806
  EXPECT_THAT(container, SizeIs(0));
4116
4807
  EXPECT_THAT(container, Not(SizeIs(1)));
4117
4808
  container.insert(make_pair("foo", 1));
@@ -4231,7 +4922,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) {
4231
4922
  #endif // GTEST_HAS_TYPED_TEST
4232
4923
 
4233
4924
  // Tests that mutliple missing values are reported.
4234
- // Using just vector here, so order is predicatble.
4925
+ // Using just vector here, so order is predictable.
4235
4926
  TEST(ContainerEqExtraTest, MultipleValuesMissing) {
4236
4927
  static const int vals[] = {1, 1, 2, 3, 5, 8};
4237
4928
  static const int test_vals[] = {2, 1, 5};
@@ -4244,7 +4935,7 @@ TEST(ContainerEqExtraTest, MultipleValuesMissing) {
4244
4935
  }
4245
4936
 
4246
4937
  // Tests that added values are reported.
4247
- // Using just vector here, so order is predicatble.
4938
+ // Using just vector here, so order is predictable.
4248
4939
  TEST(ContainerEqExtraTest, MultipleValuesAdded) {
4249
4940
  static const int vals[] = {1, 1, 2, 3, 5, 8};
4250
4941
  static const int test_vals[] = {1, 2, 92, 3, 5, 8, 46};
@@ -4376,13 +5067,13 @@ TEST(WhenSortedByTest, WorksForNonEmptyContainer) {
4376
5067
  }
4377
5068
 
4378
5069
  TEST(WhenSortedByTest, WorksForNonVectorContainer) {
4379
- list<string> words;
5070
+ list<std::string> words;
4380
5071
  words.push_back("say");
4381
5072
  words.push_back("hello");
4382
5073
  words.push_back("world");
4383
- EXPECT_THAT(words, WhenSortedBy(less<string>(),
5074
+ EXPECT_THAT(words, WhenSortedBy(less<std::string>(),
4384
5075
  ElementsAre("hello", "say", "world")));
4385
- EXPECT_THAT(words, Not(WhenSortedBy(less<string>(),
5076
+ EXPECT_THAT(words, Not(WhenSortedBy(less<std::string>(),
4386
5077
  ElementsAre("say", "hello", "world"))));
4387
5078
  }
4388
5079
 
@@ -4425,7 +5116,7 @@ TEST(WhenSortedTest, WorksForEmptyContainer) {
4425
5116
  }
4426
5117
 
4427
5118
  TEST(WhenSortedTest, WorksForNonEmptyContainer) {
4428
- list<string> words;
5119
+ list<std::string> words;
4429
5120
  words.push_back("3");
4430
5121
  words.push_back("1");
4431
5122
  words.push_back("2");
@@ -4435,14 +5126,16 @@ TEST(WhenSortedTest, WorksForNonEmptyContainer) {
4435
5126
  }
4436
5127
 
4437
5128
  TEST(WhenSortedTest, WorksForMapTypes) {
4438
- map<string, int> word_counts;
4439
- word_counts["and"] = 1;
4440
- word_counts["the"] = 1;
4441
- word_counts["buffalo"] = 2;
4442
- EXPECT_THAT(word_counts, WhenSorted(ElementsAre(
4443
- Pair("and", 1), Pair("buffalo", 2), Pair("the", 1))));
4444
- EXPECT_THAT(word_counts, Not(WhenSorted(ElementsAre(
4445
- Pair("and", 1), Pair("the", 1), Pair("buffalo", 2)))));
5129
+ map<std::string, int> word_counts;
5130
+ word_counts["and"] = 1;
5131
+ word_counts["the"] = 1;
5132
+ word_counts["buffalo"] = 2;
5133
+ EXPECT_THAT(word_counts,
5134
+ WhenSorted(ElementsAre(Pair("and", 1), Pair("buffalo", 2),
5135
+ Pair("the", 1))));
5136
+ EXPECT_THAT(word_counts,
5137
+ Not(WhenSorted(ElementsAre(Pair("and", 1), Pair("the", 1),
5138
+ Pair("buffalo", 2)))));
4446
5139
  }
4447
5140
 
4448
5141
  TEST(WhenSortedTest, WorksForMultiMapTypes) {
@@ -4650,6 +5343,250 @@ TEST(WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike) {
4650
5343
  EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3))));
4651
5344
  }
4652
5345
 
5346
+ TEST(IsSupersetOfTest, WorksForNativeArray) {
5347
+ const int subset[] = {1, 4};
5348
+ const int superset[] = {1, 2, 4};
5349
+ const int disjoint[] = {1, 0, 3};
5350
+ EXPECT_THAT(subset, IsSupersetOf(subset));
5351
+ EXPECT_THAT(subset, Not(IsSupersetOf(superset)));
5352
+ EXPECT_THAT(superset, IsSupersetOf(subset));
5353
+ EXPECT_THAT(subset, Not(IsSupersetOf(disjoint)));
5354
+ EXPECT_THAT(disjoint, Not(IsSupersetOf(subset)));
5355
+ }
5356
+
5357
+ TEST(IsSupersetOfTest, WorksWithDuplicates) {
5358
+ const int not_enough[] = {1, 2};
5359
+ const int enough[] = {1, 1, 2};
5360
+ const int expected[] = {1, 1};
5361
+ EXPECT_THAT(not_enough, Not(IsSupersetOf(expected)));
5362
+ EXPECT_THAT(enough, IsSupersetOf(expected));
5363
+ }
5364
+
5365
+ TEST(IsSupersetOfTest, WorksForEmpty) {
5366
+ vector<int> numbers;
5367
+ vector<int> expected;
5368
+ EXPECT_THAT(numbers, IsSupersetOf(expected));
5369
+ expected.push_back(1);
5370
+ EXPECT_THAT(numbers, Not(IsSupersetOf(expected)));
5371
+ expected.clear();
5372
+ numbers.push_back(1);
5373
+ numbers.push_back(2);
5374
+ EXPECT_THAT(numbers, IsSupersetOf(expected));
5375
+ expected.push_back(1);
5376
+ EXPECT_THAT(numbers, IsSupersetOf(expected));
5377
+ expected.push_back(2);
5378
+ EXPECT_THAT(numbers, IsSupersetOf(expected));
5379
+ expected.push_back(3);
5380
+ EXPECT_THAT(numbers, Not(IsSupersetOf(expected)));
5381
+ }
5382
+
5383
+ TEST(IsSupersetOfTest, WorksForStreamlike) {
5384
+ const int a[5] = {1, 2, 3, 4, 5};
5385
+ Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
5386
+
5387
+ vector<int> expected;
5388
+ expected.push_back(1);
5389
+ expected.push_back(2);
5390
+ expected.push_back(5);
5391
+ EXPECT_THAT(s, IsSupersetOf(expected));
5392
+
5393
+ expected.push_back(0);
5394
+ EXPECT_THAT(s, Not(IsSupersetOf(expected)));
5395
+ }
5396
+
5397
+ TEST(IsSupersetOfTest, TakesStlContainer) {
5398
+ const int actual[] = {3, 1, 2};
5399
+
5400
+ ::std::list<int> expected;
5401
+ expected.push_back(1);
5402
+ expected.push_back(3);
5403
+ EXPECT_THAT(actual, IsSupersetOf(expected));
5404
+
5405
+ expected.push_back(4);
5406
+ EXPECT_THAT(actual, Not(IsSupersetOf(expected)));
5407
+ }
5408
+
5409
+ TEST(IsSupersetOfTest, Describe) {
5410
+ typedef std::vector<int> IntVec;
5411
+ IntVec expected;
5412
+ expected.push_back(111);
5413
+ expected.push_back(222);
5414
+ expected.push_back(333);
5415
+ EXPECT_THAT(
5416
+ Describe<IntVec>(IsSupersetOf(expected)),
5417
+ Eq("a surjection from elements to requirements exists such that:\n"
5418
+ " - an element is equal to 111\n"
5419
+ " - an element is equal to 222\n"
5420
+ " - an element is equal to 333"));
5421
+ }
5422
+
5423
+ TEST(IsSupersetOfTest, DescribeNegation) {
5424
+ typedef std::vector<int> IntVec;
5425
+ IntVec expected;
5426
+ expected.push_back(111);
5427
+ expected.push_back(222);
5428
+ expected.push_back(333);
5429
+ EXPECT_THAT(
5430
+ DescribeNegation<IntVec>(IsSupersetOf(expected)),
5431
+ Eq("no surjection from elements to requirements exists such that:\n"
5432
+ " - an element is equal to 111\n"
5433
+ " - an element is equal to 222\n"
5434
+ " - an element is equal to 333"));
5435
+ }
5436
+
5437
+ TEST(IsSupersetOfTest, MatchAndExplain) {
5438
+ std::vector<int> v;
5439
+ v.push_back(2);
5440
+ v.push_back(3);
5441
+ std::vector<int> expected;
5442
+ expected.push_back(1);
5443
+ expected.push_back(2);
5444
+ StringMatchResultListener listener;
5445
+ ASSERT_FALSE(ExplainMatchResult(IsSupersetOf(expected), v, &listener))
5446
+ << listener.str();
5447
+ EXPECT_THAT(listener.str(),
5448
+ Eq("where the following matchers don't match any elements:\n"
5449
+ "matcher #0: is equal to 1"));
5450
+
5451
+ v.push_back(1);
5452
+ listener.Clear();
5453
+ ASSERT_TRUE(ExplainMatchResult(IsSupersetOf(expected), v, &listener))
5454
+ << listener.str();
5455
+ EXPECT_THAT(listener.str(), Eq("where:\n"
5456
+ " - element #0 is matched by matcher #1,\n"
5457
+ " - element #2 is matched by matcher #0"));
5458
+ }
5459
+
5460
+ #if GTEST_HAS_STD_INITIALIZER_LIST_
5461
+ TEST(IsSupersetOfTest, WorksForRhsInitializerList) {
5462
+ const int numbers[] = {1, 3, 6, 2, 4, 5};
5463
+ EXPECT_THAT(numbers, IsSupersetOf({1, 2}));
5464
+ EXPECT_THAT(numbers, Not(IsSupersetOf({3, 0})));
5465
+ }
5466
+ #endif
5467
+
5468
+ TEST(IsSubsetOfTest, WorksForNativeArray) {
5469
+ const int subset[] = {1, 4};
5470
+ const int superset[] = {1, 2, 4};
5471
+ const int disjoint[] = {1, 0, 3};
5472
+ EXPECT_THAT(subset, IsSubsetOf(subset));
5473
+ EXPECT_THAT(subset, IsSubsetOf(superset));
5474
+ EXPECT_THAT(superset, Not(IsSubsetOf(subset)));
5475
+ EXPECT_THAT(subset, Not(IsSubsetOf(disjoint)));
5476
+ EXPECT_THAT(disjoint, Not(IsSubsetOf(subset)));
5477
+ }
5478
+
5479
+ TEST(IsSubsetOfTest, WorksWithDuplicates) {
5480
+ const int not_enough[] = {1, 2};
5481
+ const int enough[] = {1, 1, 2};
5482
+ const int actual[] = {1, 1};
5483
+ EXPECT_THAT(actual, Not(IsSubsetOf(not_enough)));
5484
+ EXPECT_THAT(actual, IsSubsetOf(enough));
5485
+ }
5486
+
5487
+ TEST(IsSubsetOfTest, WorksForEmpty) {
5488
+ vector<int> numbers;
5489
+ vector<int> expected;
5490
+ EXPECT_THAT(numbers, IsSubsetOf(expected));
5491
+ expected.push_back(1);
5492
+ EXPECT_THAT(numbers, IsSubsetOf(expected));
5493
+ expected.clear();
5494
+ numbers.push_back(1);
5495
+ numbers.push_back(2);
5496
+ EXPECT_THAT(numbers, Not(IsSubsetOf(expected)));
5497
+ expected.push_back(1);
5498
+ EXPECT_THAT(numbers, Not(IsSubsetOf(expected)));
5499
+ expected.push_back(2);
5500
+ EXPECT_THAT(numbers, IsSubsetOf(expected));
5501
+ expected.push_back(3);
5502
+ EXPECT_THAT(numbers, IsSubsetOf(expected));
5503
+ }
5504
+
5505
+ TEST(IsSubsetOfTest, WorksForStreamlike) {
5506
+ const int a[5] = {1, 2};
5507
+ Streamlike<int> s(a, a + GTEST_ARRAY_SIZE_(a));
5508
+
5509
+ vector<int> expected;
5510
+ expected.push_back(1);
5511
+ EXPECT_THAT(s, Not(IsSubsetOf(expected)));
5512
+ expected.push_back(2);
5513
+ expected.push_back(5);
5514
+ EXPECT_THAT(s, IsSubsetOf(expected));
5515
+ }
5516
+
5517
+ TEST(IsSubsetOfTest, TakesStlContainer) {
5518
+ const int actual[] = {3, 1, 2};
5519
+
5520
+ ::std::list<int> expected;
5521
+ expected.push_back(1);
5522
+ expected.push_back(3);
5523
+ EXPECT_THAT(actual, Not(IsSubsetOf(expected)));
5524
+
5525
+ expected.push_back(2);
5526
+ expected.push_back(4);
5527
+ EXPECT_THAT(actual, IsSubsetOf(expected));
5528
+ }
5529
+
5530
+ TEST(IsSubsetOfTest, Describe) {
5531
+ typedef std::vector<int> IntVec;
5532
+ IntVec expected;
5533
+ expected.push_back(111);
5534
+ expected.push_back(222);
5535
+ expected.push_back(333);
5536
+
5537
+ EXPECT_THAT(
5538
+ Describe<IntVec>(IsSubsetOf(expected)),
5539
+ Eq("an injection from elements to requirements exists such that:\n"
5540
+ " - an element is equal to 111\n"
5541
+ " - an element is equal to 222\n"
5542
+ " - an element is equal to 333"));
5543
+ }
5544
+
5545
+ TEST(IsSubsetOfTest, DescribeNegation) {
5546
+ typedef std::vector<int> IntVec;
5547
+ IntVec expected;
5548
+ expected.push_back(111);
5549
+ expected.push_back(222);
5550
+ expected.push_back(333);
5551
+ EXPECT_THAT(
5552
+ DescribeNegation<IntVec>(IsSubsetOf(expected)),
5553
+ Eq("no injection from elements to requirements exists such that:\n"
5554
+ " - an element is equal to 111\n"
5555
+ " - an element is equal to 222\n"
5556
+ " - an element is equal to 333"));
5557
+ }
5558
+
5559
+ TEST(IsSubsetOfTest, MatchAndExplain) {
5560
+ std::vector<int> v;
5561
+ v.push_back(2);
5562
+ v.push_back(3);
5563
+ std::vector<int> expected;
5564
+ expected.push_back(1);
5565
+ expected.push_back(2);
5566
+ StringMatchResultListener listener;
5567
+ ASSERT_FALSE(ExplainMatchResult(IsSubsetOf(expected), v, &listener))
5568
+ << listener.str();
5569
+ EXPECT_THAT(listener.str(),
5570
+ Eq("where the following elements don't match any matchers:\n"
5571
+ "element #1: 3"));
5572
+
5573
+ expected.push_back(3);
5574
+ listener.Clear();
5575
+ ASSERT_TRUE(ExplainMatchResult(IsSubsetOf(expected), v, &listener))
5576
+ << listener.str();
5577
+ EXPECT_THAT(listener.str(), Eq("where:\n"
5578
+ " - element #0 is matched by matcher #1,\n"
5579
+ " - element #1 is matched by matcher #2"));
5580
+ }
5581
+
5582
+ #if GTEST_HAS_STD_INITIALIZER_LIST_
5583
+ TEST(IsSubsetOfTest, WorksForRhsInitializerList) {
5584
+ const int numbers[] = {1, 2, 3};
5585
+ EXPECT_THAT(numbers, IsSubsetOf({1, 2, 3, 4}));
5586
+ EXPECT_THAT(numbers, Not(IsSubsetOf({1, 2})));
5587
+ }
5588
+ #endif
5589
+
4653
5590
  // Tests using ElementsAre() and ElementsAreArray() with stream-like
4654
5591
  // "containers".
4655
5592
 
@@ -4759,7 +5696,7 @@ TEST(UnorderedElementsAreArrayTest, TakesInitializerList) {
4759
5696
  }
4760
5697
 
4761
5698
  TEST(UnorderedElementsAreArrayTest, TakesInitializerListOfCStrings) {
4762
- const string a[5] = {"a", "b", "c", "d", "e"};
5699
+ const std::string a[5] = {"a", "b", "c", "d", "e"};
4763
5700
  EXPECT_THAT(a, UnorderedElementsAreArray({"a", "b", "c", "d", "e"}));
4764
5701
  EXPECT_THAT(a, Not(UnorderedElementsAreArray({"a", "b", "c", "d", "ef"})));
4765
5702
  }
@@ -4933,7 +5870,7 @@ TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatcherAndElement) {
4933
5870
  }
4934
5871
 
4935
5872
  // Test helper for formatting element, matcher index pairs in expectations.
4936
- static string EMString(int element, int matcher) {
5873
+ static std::string EMString(int element, int matcher) {
4937
5874
  stringstream ss;
4938
5875
  ss << "(element #" << element << ", matcher #" << matcher << ")";
4939
5876
  return ss.str();
@@ -4942,7 +5879,7 @@ static string EMString(int element, int matcher) {
4942
5879
  TEST_F(UnorderedElementsAreTest, FailMessageImperfectMatchOnly) {
4943
5880
  // A situation where all elements and matchers have a match
4944
5881
  // associated with them, but the max matching is not perfect.
4945
- std::vector<string> v;
5882
+ std::vector<std::string> v;
4946
5883
  v.push_back("a");
4947
5884
  v.push_back("b");
4948
5885
  v.push_back("c");
@@ -4951,7 +5888,7 @@ TEST_F(UnorderedElementsAreTest, FailMessageImperfectMatchOnly) {
4951
5888
  UnorderedElementsAre("a", "a", AnyOf("b", "c")), v, &listener))
4952
5889
  << listener.str();
4953
5890
 
4954
- string prefix =
5891
+ std::string prefix =
4955
5892
  "where no permutation of the elements can satisfy all matchers, "
4956
5893
  "and the closest match is 2 of 3 matchers with the "
4957
5894
  "pairings:\n";
@@ -5234,28 +6171,6 @@ TEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {
5234
6171
  EXPECT_FALSE(IsReadableTypeName("void (&)(int, bool, char, float)"));
5235
6172
  }
5236
6173
 
5237
- // Tests JoinAsTuple().
5238
-
5239
- TEST(JoinAsTupleTest, JoinsEmptyTuple) {
5240
- EXPECT_EQ("", JoinAsTuple(Strings()));
5241
- }
5242
-
5243
- TEST(JoinAsTupleTest, JoinsOneTuple) {
5244
- const char* fields[] = {"1"};
5245
- EXPECT_EQ("1", JoinAsTuple(Strings(fields, fields + 1)));
5246
- }
5247
-
5248
- TEST(JoinAsTupleTest, JoinsTwoTuple) {
5249
- const char* fields[] = {"1", "a"};
5250
- EXPECT_EQ("(1, a)", JoinAsTuple(Strings(fields, fields + 2)));
5251
- }
5252
-
5253
- TEST(JoinAsTupleTest, JoinsTenTuple) {
5254
- const char* fields[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
5255
- EXPECT_EQ("(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)",
5256
- JoinAsTuple(Strings(fields, fields + 10)));
5257
- }
5258
-
5259
6174
  // Tests FormatMatcherDescription().
5260
6175
 
5261
6176
  TEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {
@@ -5362,13 +6277,13 @@ TEST(EachTest, MatchesVectorWhenAllElementsMatch) {
5362
6277
  EXPECT_THAT(some_vector, Not(Each(3)));
5363
6278
  EXPECT_THAT(some_vector, Each(Lt(3.5)));
5364
6279
 
5365
- vector<string> another_vector;
6280
+ vector<std::string> another_vector;
5366
6281
  another_vector.push_back("fee");
5367
- EXPECT_THAT(another_vector, Each(string("fee")));
6282
+ EXPECT_THAT(another_vector, Each(std::string("fee")));
5368
6283
  another_vector.push_back("fie");
5369
6284
  another_vector.push_back("foe");
5370
6285
  another_vector.push_back("fum");
5371
- EXPECT_THAT(another_vector, Not(Each(string("fee"))));
6286
+ EXPECT_THAT(another_vector, Not(Each(std::string("fee"))));
5372
6287
  }
5373
6288
 
5374
6289
  TEST(EachTest, MatchesMapWhenAllElementsMatch) {
@@ -5377,15 +6292,15 @@ TEST(EachTest, MatchesMapWhenAllElementsMatch) {
5377
6292
  my_map[bar] = 2;
5378
6293
  EXPECT_THAT(my_map, Each(make_pair(bar, 2)));
5379
6294
 
5380
- map<string, int> another_map;
5381
- EXPECT_THAT(another_map, Each(make_pair(string("fee"), 1)));
6295
+ map<std::string, int> another_map;
6296
+ EXPECT_THAT(another_map, Each(make_pair(std::string("fee"), 1)));
5382
6297
  another_map["fee"] = 1;
5383
- EXPECT_THAT(another_map, Each(make_pair(string("fee"), 1)));
6298
+ EXPECT_THAT(another_map, Each(make_pair(std::string("fee"), 1)));
5384
6299
  another_map["fie"] = 2;
5385
6300
  another_map["foe"] = 3;
5386
6301
  another_map["fum"] = 4;
5387
- EXPECT_THAT(another_map, Not(Each(make_pair(string("fee"), 1))));
5388
- EXPECT_THAT(another_map, Not(Each(make_pair(string("fum"), 1))));
6302
+ EXPECT_THAT(another_map, Not(Each(make_pair(std::string("fee"), 1))));
6303
+ EXPECT_THAT(another_map, Not(Each(make_pair(std::string("fum"), 1))));
5389
6304
  EXPECT_THAT(another_map, Each(Pair(_, Gt(0))));
5390
6305
  }
5391
6306
 
@@ -5479,6 +6394,16 @@ TEST(PointwiseTest, WorksForRhsNativeArray) {
5479
6394
  EXPECT_THAT(lhs, Not(Pointwise(Lt(), rhs)));
5480
6395
  }
5481
6396
 
6397
+ // Test is effective only with sanitizers.
6398
+ TEST(PointwiseTest, WorksForVectorOfBool) {
6399
+ vector<bool> rhs(3, false);
6400
+ rhs[1] = true;
6401
+ vector<bool> lhs = rhs;
6402
+ EXPECT_THAT(lhs, Pointwise(Eq(), rhs));
6403
+ rhs[0] = true;
6404
+ EXPECT_THAT(lhs, Not(Pointwise(Eq(), rhs)));
6405
+ }
6406
+
5482
6407
  #if GTEST_HAS_STD_INITIALIZER_LIST_
5483
6408
 
5484
6409
  TEST(PointwiseTest, WorksForRhsInitializerList) {
@@ -5644,5 +6569,199 @@ TEST(UnorderedPointwiseTest, AllowsMonomorphicInnerMatcher) {
5644
6569
  EXPECT_THAT(lhs, UnorderedPointwise(m2, rhs));
5645
6570
  }
5646
6571
 
6572
+ // Sample optional type implementation with minimal requirements for use with
6573
+ // Optional matcher.
6574
+ class SampleOptionalInt {
6575
+ public:
6576
+ typedef int value_type;
6577
+ explicit SampleOptionalInt(int value) : value_(value), has_value_(true) {}
6578
+ SampleOptionalInt() : value_(0), has_value_(false) {}
6579
+ operator bool() const {
6580
+ return has_value_;
6581
+ }
6582
+ const int& operator*() const {
6583
+ return value_;
6584
+ }
6585
+ private:
6586
+ int value_;
6587
+ bool has_value_;
6588
+ };
6589
+
6590
+ TEST(OptionalTest, DescribesSelf) {
6591
+ const Matcher<SampleOptionalInt> m = Optional(Eq(1));
6592
+ EXPECT_EQ("value is equal to 1", Describe(m));
6593
+ }
6594
+
6595
+ TEST(OptionalTest, ExplainsSelf) {
6596
+ const Matcher<SampleOptionalInt> m = Optional(Eq(1));
6597
+ EXPECT_EQ("whose value 1 matches", Explain(m, SampleOptionalInt(1)));
6598
+ EXPECT_EQ("whose value 2 doesn't match", Explain(m, SampleOptionalInt(2)));
6599
+ }
6600
+
6601
+ TEST(OptionalTest, MatchesNonEmptyOptional) {
6602
+ const Matcher<SampleOptionalInt> m1 = Optional(1);
6603
+ const Matcher<SampleOptionalInt> m2 = Optional(Eq(2));
6604
+ const Matcher<SampleOptionalInt> m3 = Optional(Lt(3));
6605
+ SampleOptionalInt opt(1);
6606
+ EXPECT_TRUE(m1.Matches(opt));
6607
+ EXPECT_FALSE(m2.Matches(opt));
6608
+ EXPECT_TRUE(m3.Matches(opt));
6609
+ }
6610
+
6611
+ TEST(OptionalTest, DoesNotMatchNullopt) {
6612
+ const Matcher<SampleOptionalInt> m = Optional(1);
6613
+ SampleOptionalInt empty;
6614
+ EXPECT_FALSE(m.Matches(empty));
6615
+ }
6616
+
6617
+ class SampleVariantIntString {
6618
+ public:
6619
+ SampleVariantIntString(int i) : i_(i), has_int_(true) {}
6620
+ SampleVariantIntString(const std::string& s) : s_(s), has_int_(false) {}
6621
+
6622
+ template <typename T>
6623
+ friend bool holds_alternative(const SampleVariantIntString& value) {
6624
+ return value.has_int_ == internal::IsSame<T, int>::value;
6625
+ }
6626
+
6627
+ template <typename T>
6628
+ friend const T& get(const SampleVariantIntString& value) {
6629
+ return value.get_impl(static_cast<T*>(NULL));
6630
+ }
6631
+
6632
+ private:
6633
+ const int& get_impl(int*) const { return i_; }
6634
+ const std::string& get_impl(std::string*) const { return s_; }
6635
+
6636
+ int i_;
6637
+ std::string s_;
6638
+ bool has_int_;
6639
+ };
6640
+
6641
+ TEST(VariantTest, DescribesSelf) {
6642
+ const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
6643
+ EXPECT_THAT(Describe(m), ContainsRegex("is a variant<> with value of type "
6644
+ "'.*' and the value is equal to 1"));
6645
+ }
6646
+
6647
+ TEST(VariantTest, ExplainsSelf) {
6648
+ const Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
6649
+ EXPECT_THAT(Explain(m, SampleVariantIntString(1)),
6650
+ ContainsRegex("whose value 1"));
6651
+ EXPECT_THAT(Explain(m, SampleVariantIntString("A")),
6652
+ HasSubstr("whose value is not of type '"));
6653
+ EXPECT_THAT(Explain(m, SampleVariantIntString(2)),
6654
+ "whose value 2 doesn't match");
6655
+ }
6656
+
6657
+ TEST(VariantTest, FullMatch) {
6658
+ Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
6659
+ EXPECT_TRUE(m.Matches(SampleVariantIntString(1)));
6660
+
6661
+ m = VariantWith<std::string>(Eq("1"));
6662
+ EXPECT_TRUE(m.Matches(SampleVariantIntString("1")));
6663
+ }
6664
+
6665
+ TEST(VariantTest, TypeDoesNotMatch) {
6666
+ Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
6667
+ EXPECT_FALSE(m.Matches(SampleVariantIntString("1")));
6668
+
6669
+ m = VariantWith<std::string>(Eq("1"));
6670
+ EXPECT_FALSE(m.Matches(SampleVariantIntString(1)));
6671
+ }
6672
+
6673
+ TEST(VariantTest, InnerDoesNotMatch) {
6674
+ Matcher<SampleVariantIntString> m = VariantWith<int>(Eq(1));
6675
+ EXPECT_FALSE(m.Matches(SampleVariantIntString(2)));
6676
+
6677
+ m = VariantWith<std::string>(Eq("1"));
6678
+ EXPECT_FALSE(m.Matches(SampleVariantIntString("2")));
6679
+ }
6680
+
6681
+ class SampleAnyType {
6682
+ public:
6683
+ explicit SampleAnyType(int i) : index_(0), i_(i) {}
6684
+ explicit SampleAnyType(const std::string& s) : index_(1), s_(s) {}
6685
+
6686
+ template <typename T>
6687
+ friend const T* any_cast(const SampleAnyType* any) {
6688
+ return any->get_impl(static_cast<T*>(NULL));
6689
+ }
6690
+
6691
+ private:
6692
+ int index_;
6693
+ int i_;
6694
+ std::string s_;
6695
+
6696
+ const int* get_impl(int*) const { return index_ == 0 ? &i_ : NULL; }
6697
+ const std::string* get_impl(std::string*) const {
6698
+ return index_ == 1 ? &s_ : NULL;
6699
+ }
6700
+ };
6701
+
6702
+ TEST(AnyWithTest, FullMatch) {
6703
+ Matcher<SampleAnyType> m = AnyWith<int>(Eq(1));
6704
+ EXPECT_TRUE(m.Matches(SampleAnyType(1)));
6705
+ }
6706
+
6707
+ TEST(AnyWithTest, TestBadCastType) {
6708
+ Matcher<SampleAnyType> m = AnyWith<std::string>(Eq("fail"));
6709
+ EXPECT_FALSE(m.Matches(SampleAnyType(1)));
6710
+ }
6711
+
6712
+ #if GTEST_LANG_CXX11
6713
+ TEST(AnyWithTest, TestUseInContainers) {
6714
+ std::vector<SampleAnyType> a;
6715
+ a.emplace_back(1);
6716
+ a.emplace_back(2);
6717
+ a.emplace_back(3);
6718
+ EXPECT_THAT(
6719
+ a, ElementsAreArray({AnyWith<int>(1), AnyWith<int>(2), AnyWith<int>(3)}));
6720
+
6721
+ std::vector<SampleAnyType> b;
6722
+ b.emplace_back("hello");
6723
+ b.emplace_back("merhaba");
6724
+ b.emplace_back("salut");
6725
+ EXPECT_THAT(b, ElementsAreArray({AnyWith<std::string>("hello"),
6726
+ AnyWith<std::string>("merhaba"),
6727
+ AnyWith<std::string>("salut")}));
6728
+ }
6729
+ #endif // GTEST_LANG_CXX11
6730
+ TEST(AnyWithTest, TestCompare) {
6731
+ EXPECT_THAT(SampleAnyType(1), AnyWith<int>(Gt(0)));
6732
+ }
6733
+
6734
+ TEST(AnyWithTest, DescribesSelf) {
6735
+ const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
6736
+ EXPECT_THAT(Describe(m), ContainsRegex("is an 'any' type with value of type "
6737
+ "'.*' and the value is equal to 1"));
6738
+ }
6739
+
6740
+ TEST(AnyWithTest, ExplainsSelf) {
6741
+ const Matcher<const SampleAnyType&> m = AnyWith<int>(Eq(1));
6742
+
6743
+ EXPECT_THAT(Explain(m, SampleAnyType(1)), ContainsRegex("whose value 1"));
6744
+ EXPECT_THAT(Explain(m, SampleAnyType("A")),
6745
+ HasSubstr("whose value is not of type '"));
6746
+ EXPECT_THAT(Explain(m, SampleAnyType(2)), "whose value 2 doesn't match");
6747
+ }
6748
+
6749
+ #if GTEST_LANG_CXX11
6750
+
6751
+ TEST(PointeeTest, WorksOnMoveOnlyType) {
6752
+ std::unique_ptr<int> p(new int(3));
6753
+ EXPECT_THAT(p, Pointee(Eq(3)));
6754
+ EXPECT_THAT(p, Not(Pointee(Eq(2))));
6755
+ }
6756
+
6757
+ TEST(NotTest, WorksOnMoveOnlyType) {
6758
+ std::unique_ptr<int> p(new int(3));
6759
+ EXPECT_THAT(p, Pointee(Eq(3)));
6760
+ EXPECT_THAT(p, Not(Pointee(Eq(2))));
6761
+ }
6762
+
6763
+ #endif // GTEST_LANG_CXX11
6764
+
5647
6765
  } // namespace gmock_matchers_test
5648
6766
  } // namespace testing
6767
+