rj_schema 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +4 -0
  3. data/ext/rj_schema/rapidjson/thirdparty/gtest/CMakeLists.txt +16 -0
  4. data/ext/rj_schema/rapidjson/thirdparty/gtest/README.md +141 -0
  5. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CHANGES +126 -0
  6. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CMakeLists.txt +202 -0
  7. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/CONTRIBUTORS +40 -0
  8. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/LICENSE +28 -0
  9. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/Makefile.am +224 -0
  10. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/README.md +333 -0
  11. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/configure.ac +146 -0
  12. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CheatSheet.md +562 -0
  13. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/CookBook.md +3675 -0
  14. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DesignDoc.md +280 -0
  15. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/DevGuide.md +132 -0
  16. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/Documentation.md +12 -0
  17. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/ForDummies.md +439 -0
  18. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/FrequentlyAskedQuestions.md +628 -0
  19. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/KnownIssues.md +19 -0
  20. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CheatSheet.md +525 -0
  21. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/CookBook.md +3250 -0
  22. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/Documentation.md +11 -0
  23. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/ForDummies.md +439 -0
  24. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_5/FrequentlyAskedQuestions.md +624 -0
  25. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CheatSheet.md +534 -0
  26. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/CookBook.md +3342 -0
  27. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/Documentation.md +12 -0
  28. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/ForDummies.md +439 -0
  29. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_6/FrequentlyAskedQuestions.md +628 -0
  30. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CheatSheet.md +556 -0
  31. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/CookBook.md +3432 -0
  32. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/Documentation.md +12 -0
  33. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/ForDummies.md +439 -0
  34. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/docs/v1_7/FrequentlyAskedQuestions.md +628 -0
  35. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-actions.h +1205 -0
  36. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-cardinalities.h +147 -0
  37. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h +2377 -0
  38. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-actions.h.pump +794 -0
  39. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h +1095 -0
  40. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +291 -0
  41. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h +2179 -0
  42. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-matchers.h.pump +672 -0
  43. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h +397 -0
  44. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-generated-nice-strict.h.pump +161 -0
  45. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-matchers.h +4399 -0
  46. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-actions.h +246 -0
  47. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-more-matchers.h +58 -0
  48. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock-spec-builders.h +1847 -0
  49. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/gmock.h +94 -0
  50. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +8 -0
  51. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +10 -0
  52. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-matchers.h +39 -0
  53. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/custom/gmock-port.h +46 -0
  54. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h +279 -0
  55. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-generated-internal-utils.h.pump +136 -0
  56. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-internal-utils.h +511 -0
  57. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/include/gmock/internal/gmock-port.h +91 -0
  58. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/make/Makefile +101 -0
  59. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.sln +32 -0
  60. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock.vcproj +191 -0
  61. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_config.vsprops +15 -0
  62. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_main.vcproj +187 -0
  63. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2005/gmock_test.vcproj +201 -0
  64. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.sln +32 -0
  65. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock.vcxproj +82 -0
  66. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_config.props +19 -0
  67. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_main.vcxproj +88 -0
  68. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2010/gmock_test.vcxproj +101 -0
  69. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.sln +32 -0
  70. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock.vcxproj +84 -0
  71. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_config.props +19 -0
  72. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_main.vcxproj +90 -0
  73. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/msvc/2015/gmock_test.vcxproj +103 -0
  74. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/fuse_gmock_files.py +240 -0
  75. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/LICENSE +203 -0
  76. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README +35 -0
  77. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/README.cppclean +115 -0
  78. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/__init__.py +0 -0
  79. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/ast.py +1733 -0
  80. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class.py +227 -0
  81. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/gmock_class_test.py +448 -0
  82. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/keywords.py +59 -0
  83. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/tokenize.py +287 -0
  84. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/cpp/utils.py +41 -0
  85. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/generator/gmock_gen.py +31 -0
  86. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock-config.in +303 -0
  87. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/gmock_doctor.py +640 -0
  88. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload.py +1387 -0
  89. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/scripts/upload_gmock.py +78 -0
  90. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-all.cc +47 -0
  91. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-cardinalities.cc +156 -0
  92. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-internal-utils.cc +174 -0
  93. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-matchers.cc +498 -0
  94. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock-spec-builders.cc +823 -0
  95. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock.cc +183 -0
  96. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/src/gmock_main.cc +54 -0
  97. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-actions_test.cc +1411 -0
  98. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-cardinalities_test.cc +428 -0
  99. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-actions_test.cc +1228 -0
  100. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-function-mockers_test.cc +622 -0
  101. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-internal-utils_test.cc +127 -0
  102. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-generated-matchers_test.cc +1286 -0
  103. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-internal-utils_test.cc +699 -0
  104. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-matchers_test.cc +5648 -0
  105. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-more-actions_test.cc +708 -0
  106. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-nice-strict_test.cc +424 -0
  107. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-port_test.cc +43 -0
  108. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock-spec-builders_test.cc +2644 -0
  109. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_all_test.cc +51 -0
  110. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_ex_test.cc +81 -0
  111. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test.py +108 -0
  112. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_leak_test_.cc +100 -0
  113. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link2_test.cc +40 -0
  114. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.cc +40 -0
  115. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_link_test.h +669 -0
  116. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test.py +180 -0
  117. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_.cc +291 -0
  118. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_output_test_golden.txt +310 -0
  119. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_stress_test.cc +322 -0
  120. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test.cc +220 -0
  121. data/ext/rj_schema/rapidjson/thirdparty/gtest/googlemock/test/gmock_test_utils.py +112 -0
  122. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CHANGES +157 -0
  123. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CMakeLists.txt +286 -0
  124. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/CONTRIBUTORS +37 -0
  125. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/LICENSE +28 -0
  126. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/Makefile.am +310 -0
  127. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/README.md +280 -0
  128. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/cmake/internal_utils.cmake +242 -0
  129. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.cbproj +138 -0
  130. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest.groupproj +54 -0
  131. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_all.cc +38 -0
  132. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_link.cc +40 -0
  133. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_main.cbproj +82 -0
  134. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/codegear/gtest_unittest.cbproj +88 -0
  135. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/configure.ac +68 -0
  136. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/AdvancedGuide.md +2182 -0
  137. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/DevGuide.md +126 -0
  138. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Documentation.md +14 -0
  139. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/FAQ.md +1087 -0
  140. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Primer.md +502 -0
  141. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/PumpManual.md +177 -0
  142. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/Samples.md +14 -0
  143. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_AdvancedGuide.md +2096 -0
  144. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Documentation.md +12 -0
  145. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_FAQ.md +886 -0
  146. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_Primer.md +497 -0
  147. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_PumpManual.md +177 -0
  148. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_5_XcodeGuide.md +93 -0
  149. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_AdvancedGuide.md +2178 -0
  150. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Documentation.md +14 -0
  151. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_FAQ.md +1038 -0
  152. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Primer.md +501 -0
  153. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_PumpManual.md +177 -0
  154. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_Samples.md +14 -0
  155. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_6_XcodeGuide.md +93 -0
  156. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_AdvancedGuide.md +2181 -0
  157. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Documentation.md +14 -0
  158. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_FAQ.md +1082 -0
  159. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Primer.md +501 -0
  160. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_PumpManual.md +177 -0
  161. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_Samples.md +14 -0
  162. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/V1_7_XcodeGuide.md +93 -0
  163. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/docs/XcodeGuide.md +93 -0
  164. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-death-test.h +294 -0
  165. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-message.h +250 -0
  166. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h +1444 -0
  167. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-param-test.h.pump +510 -0
  168. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-printers.h +993 -0
  169. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-spi.h +232 -0
  170. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-test-part.h +179 -0
  171. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest-typed-test.h +263 -0
  172. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest.h +2236 -0
  173. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_pred_impl.h +358 -0
  174. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/gtest_prod.h +58 -0
  175. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-port.h +69 -0
  176. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
  177. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/custom/gtest.h +41 -0
  178. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-death-test-internal.h +319 -0
  179. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-filepath.h +206 -0
  180. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-internal.h +1238 -0
  181. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
  182. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h +5146 -0
  183. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +286 -0
  184. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-param-util.h +731 -0
  185. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port-arch.h +93 -0
  186. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-port.h +2554 -0
  187. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-string.h +167 -0
  188. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
  189. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
  190. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h +3331 -0
  191. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/include/gtest/internal/gtest-type-util.h.pump +297 -0
  192. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/acx_pthread.m4 +363 -0
  193. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/m4/gtest.m4 +74 -0
  194. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/make/Makefile +82 -0
  195. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.sln +45 -0
  196. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest-md.vcproj +126 -0
  197. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.sln +45 -0
  198. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest.vcproj +126 -0
  199. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main-md.vcproj +129 -0
  200. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_main.vcproj +129 -0
  201. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test-md.vcproj +164 -0
  202. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_prod_test.vcproj +164 -0
  203. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest-md.vcproj +147 -0
  204. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/msvc/gtest_unittest.vcproj +147 -0
  205. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/prime_tables.h +123 -0
  206. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.cc +68 -0
  207. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1.h +43 -0
  208. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample10_unittest.cc +144 -0
  209. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample1_unittest.cc +153 -0
  210. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.cc +56 -0
  211. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2.h +85 -0
  212. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample2_unittest.cc +109 -0
  213. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3-inl.h +172 -0
  214. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample3_unittest.cc +151 -0
  215. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.cc +46 -0
  216. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4.h +53 -0
  217. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample4_unittest.cc +45 -0
  218. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample5_unittest.cc +199 -0
  219. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample6_unittest.cc +224 -0
  220. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample7_unittest.cc +130 -0
  221. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample8_unittest.cc +173 -0
  222. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/samples/sample9_unittest.cc +160 -0
  223. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/common.py +83 -0
  224. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/fuse_gtest_files.py +253 -0
  225. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gen_gtest_pred_impl.py +730 -0
  226. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/gtest-config.in +274 -0
  227. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/pump.py +855 -0
  228. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/release_docs.py +158 -0
  229. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/test/Makefile +59 -0
  230. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload.py +1387 -0
  231. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/scripts/upload_gtest.py +78 -0
  232. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-all.cc +48 -0
  233. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-death-test.cc +1342 -0
  234. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-filepath.cc +387 -0
  235. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-internal-inl.h +1183 -0
  236. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-port.cc +1259 -0
  237. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-printers.cc +373 -0
  238. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-test-part.cc +110 -0
  239. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest-typed-test.cc +118 -0
  240. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest.cc +5388 -0
  241. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/src/gtest_main.cc +38 -0
  242. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_ex_test.cc +93 -0
  243. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-death-test_test.cc +1427 -0
  244. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-filepath_test.cc +662 -0
  245. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-linked_ptr_test.cc +154 -0
  246. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-listener_test.cc +311 -0
  247. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-message_test.cc +159 -0
  248. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-options_test.cc +215 -0
  249. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test2_test.cc +65 -0
  250. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.cc +1055 -0
  251. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-param-test_test.h +57 -0
  252. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-port_test.cc +1304 -0
  253. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-printers_test.cc +1635 -0
  254. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-test-part_test.cc +208 -0
  255. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-tuple_test.cc +320 -0
  256. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test2_test.cc +45 -0
  257. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.cc +380 -0
  258. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-typed-test_test.h +66 -0
  259. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest-unittest-api_test.cc +341 -0
  260. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_all_test.cc +47 -0
  261. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest.py +212 -0
  262. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_break_on_failure_unittest_.cc +88 -0
  263. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test.py +237 -0
  264. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_catch_exceptions_test_.cc +311 -0
  265. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test.py +130 -0
  266. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_color_test_.cc +71 -0
  267. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test.py +117 -0
  268. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_env_var_test_.cc +126 -0
  269. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_environment_test.cc +192 -0
  270. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest.py +636 -0
  271. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_filter_unittest_.cc +140 -0
  272. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test.py +172 -0
  273. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_help_test_.cc +46 -0
  274. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest.py +207 -0
  275. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_list_tests_unittest_.cc +157 -0
  276. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_main_unittest.cc +45 -0
  277. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_no_test_unittest.cc +56 -0
  278. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test.py +340 -0
  279. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_.cc +1062 -0
  280. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_output_test_golden_lin.txt +743 -0
  281. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_pred_impl_unittest.cc +2427 -0
  282. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_premature_exit_test.cc +127 -0
  283. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_prod_test.cc +57 -0
  284. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_repeat_test.cc +253 -0
  285. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test.py +325 -0
  286. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_shuffle_test_.cc +103 -0
  287. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_sole_header_test.cc +57 -0
  288. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_stress_test.cc +256 -0
  289. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_test_utils.py +320 -0
  290. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_ex_test.cc +92 -0
  291. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test.py +171 -0
  292. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_throw_on_failure_test_.cc +72 -0
  293. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test.py +70 -0
  294. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_uninitialized_test_.cc +43 -0
  295. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_unittest.cc +7706 -0
  296. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile1_test_.cc +49 -0
  297. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfile2_test_.cc +49 -0
  298. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_outfiles_test.py +132 -0
  299. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest.py +308 -0
  300. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_output_unittest_.cc +181 -0
  301. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/gtest_xml_test_utils.py +194 -0
  302. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.cc +36 -0
  303. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/test/production.h +55 -0
  304. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/DebugProject.xcconfig +30 -0
  305. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/FrameworkTarget.xcconfig +17 -0
  306. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/General.xcconfig +41 -0
  307. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/ReleaseProject.xcconfig +32 -0
  308. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/StaticLibraryTarget.xcconfig +18 -0
  309. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Config/TestTarget.xcconfig +8 -0
  310. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Resources/Info.plist +30 -0
  311. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/Info.plist +28 -0
  312. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj +457 -0
  313. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/runtests.sh +62 -0
  314. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.cc +63 -0
  315. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget.h +59 -0
  316. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Samples/FrameworkSample/widget_test.cc +68 -0
  317. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/runtests.sh +65 -0
  318. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/Scripts/versiongenerate.py +100 -0
  319. data/ext/rj_schema/rapidjson/thirdparty/gtest/googletest/xcode/gtest.xcodeproj/project.pbxproj +1135 -0
  320. data/ext/rj_schema/rapidjson/thirdparty/gtest/travis.sh +15 -0
  321. data/ext/rj_schema/rj_schema.cpp +64 -41
  322. data/lib/rj_schema.rb +1 -1
  323. metadata +378 -5
@@ -0,0 +1,127 @@
1
+ // Copyright 2007, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ //
30
+ // Author: wan@google.com (Zhanyong Wan)
31
+
32
+ // Google Mock - a framework for writing C++ mock classes.
33
+ //
34
+ // This file tests the internal utilities.
35
+
36
+ #include "gmock/internal/gmock-generated-internal-utils.h"
37
+ #include "gmock/internal/gmock-internal-utils.h"
38
+ #include "gtest/gtest.h"
39
+
40
+ namespace {
41
+
42
+ using ::testing::tuple;
43
+ using ::testing::Matcher;
44
+ using ::testing::internal::CompileAssertTypesEqual;
45
+ using ::testing::internal::MatcherTuple;
46
+ using ::testing::internal::Function;
47
+ using ::testing::internal::IgnoredValue;
48
+
49
+ // Tests the MatcherTuple template struct.
50
+
51
+ TEST(MatcherTupleTest, ForSize0) {
52
+ CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();
53
+ }
54
+
55
+ TEST(MatcherTupleTest, ForSize1) {
56
+ CompileAssertTypesEqual<tuple<Matcher<int> >,
57
+ MatcherTuple<tuple<int> >::type>();
58
+ }
59
+
60
+ TEST(MatcherTupleTest, ForSize2) {
61
+ CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,
62
+ MatcherTuple<tuple<int, char> >::type>();
63
+ }
64
+
65
+ TEST(MatcherTupleTest, ForSize5) {
66
+ CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
67
+ Matcher<double>, Matcher<char*> >,
68
+ MatcherTuple<tuple<int, char, bool, double, char*>
69
+ >::type>();
70
+ }
71
+
72
+ // Tests the Function template struct.
73
+
74
+ TEST(FunctionTest, Nullary) {
75
+ typedef Function<int()> F; // NOLINT
76
+ CompileAssertTypesEqual<int, F::Result>();
77
+ CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();
78
+ CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();
79
+ CompileAssertTypesEqual<void(), F::MakeResultVoid>();
80
+ CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();
81
+ }
82
+
83
+ TEST(FunctionTest, Unary) {
84
+ typedef Function<int(bool)> F; // NOLINT
85
+ CompileAssertTypesEqual<int, F::Result>();
86
+ CompileAssertTypesEqual<bool, F::Argument1>();
87
+ CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();
88
+ CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();
89
+ CompileAssertTypesEqual<void(bool), F::MakeResultVoid>(); // NOLINT
90
+ CompileAssertTypesEqual<IgnoredValue(bool), // NOLINT
91
+ F::MakeResultIgnoredValue>();
92
+ }
93
+
94
+ TEST(FunctionTest, Binary) {
95
+ typedef Function<int(bool, const long&)> F; // NOLINT
96
+ CompileAssertTypesEqual<int, F::Result>();
97
+ CompileAssertTypesEqual<bool, F::Argument1>();
98
+ CompileAssertTypesEqual<const long&, F::Argument2>(); // NOLINT
99
+ CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>(); // NOLINT
100
+ CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<const long&> >, // NOLINT
101
+ F::ArgumentMatcherTuple>();
102
+ CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>(); // NOLINT
103
+ CompileAssertTypesEqual<IgnoredValue(bool, const long&), // NOLINT
104
+ F::MakeResultIgnoredValue>();
105
+ }
106
+
107
+ TEST(FunctionTest, LongArgumentList) {
108
+ typedef Function<char(bool, int, char*, int&, const long&)> F; // NOLINT
109
+ CompileAssertTypesEqual<char, F::Result>();
110
+ CompileAssertTypesEqual<bool, F::Argument1>();
111
+ CompileAssertTypesEqual<int, F::Argument2>();
112
+ CompileAssertTypesEqual<char*, F::Argument3>();
113
+ CompileAssertTypesEqual<int&, F::Argument4>();
114
+ CompileAssertTypesEqual<const long&, F::Argument5>(); // NOLINT
115
+ CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>, // NOLINT
116
+ F::ArgumentTuple>();
117
+ CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<int>, Matcher<char*>,
118
+ Matcher<int&>, Matcher<const long&> >, // NOLINT
119
+ F::ArgumentMatcherTuple>();
120
+ CompileAssertTypesEqual<void(bool, int, char*, int&, const long&), // NOLINT
121
+ F::MakeResultVoid>();
122
+ CompileAssertTypesEqual<
123
+ IgnoredValue(bool, int, char*, int&, const long&), // NOLINT
124
+ F::MakeResultIgnoredValue>();
125
+ }
126
+
127
+ } // Unnamed namespace
@@ -0,0 +1,1286 @@
1
+ // Copyright 2008, Google Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright
9
+ // notice, this list of conditions and the following disclaimer.
10
+ // * Redistributions in binary form must reproduce the above
11
+ // copyright notice, this list of conditions and the following disclaimer
12
+ // in the documentation and/or other materials provided with the
13
+ // distribution.
14
+ // * Neither the name of Google Inc. nor the names of its
15
+ // contributors may be used to endorse or promote products derived from
16
+ // this software without specific prior written permission.
17
+ //
18
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ // Google Mock - a framework for writing C++ mock classes.
31
+ //
32
+ // This file tests the built-in matchers generated by a script.
33
+
34
+ #include "gmock/gmock-generated-matchers.h"
35
+
36
+ #include <list>
37
+ #include <map>
38
+ #include <set>
39
+ #include <sstream>
40
+ #include <string>
41
+ #include <utility>
42
+ #include <vector>
43
+
44
+ #include "gmock/gmock.h"
45
+ #include "gtest/gtest.h"
46
+ #include "gtest/gtest-spi.h"
47
+
48
+ namespace {
49
+
50
+ using std::list;
51
+ using std::map;
52
+ using std::pair;
53
+ using std::set;
54
+ using std::stringstream;
55
+ using std::vector;
56
+ using testing::get;
57
+ using testing::make_tuple;
58
+ using testing::tuple;
59
+ using testing::_;
60
+ using testing::Args;
61
+ using testing::Contains;
62
+ using testing::ElementsAre;
63
+ using testing::ElementsAreArray;
64
+ using testing::Eq;
65
+ using testing::Ge;
66
+ using testing::Gt;
67
+ using testing::Le;
68
+ using testing::Lt;
69
+ using testing::MakeMatcher;
70
+ using testing::Matcher;
71
+ using testing::MatcherInterface;
72
+ using testing::MatchResultListener;
73
+ using testing::Ne;
74
+ using testing::Not;
75
+ using testing::Pointee;
76
+ using testing::PrintToString;
77
+ using testing::Ref;
78
+ using testing::StaticAssertTypeEq;
79
+ using testing::StrEq;
80
+ using testing::Value;
81
+ using testing::internal::ElementsAreArrayMatcher;
82
+ using testing::internal::string;
83
+
84
+ // Returns the description of the given matcher.
85
+ template <typename T>
86
+ string Describe(const Matcher<T>& m) {
87
+ stringstream ss;
88
+ m.DescribeTo(&ss);
89
+ return ss.str();
90
+ }
91
+
92
+ // Returns the description of the negation of the given matcher.
93
+ template <typename T>
94
+ string DescribeNegation(const Matcher<T>& m) {
95
+ stringstream ss;
96
+ m.DescribeNegationTo(&ss);
97
+ return ss.str();
98
+ }
99
+
100
+ // Returns the reason why x matches, or doesn't match, m.
101
+ template <typename MatcherType, typename Value>
102
+ string Explain(const MatcherType& m, const Value& x) {
103
+ stringstream ss;
104
+ m.ExplainMatchResultTo(x, &ss);
105
+ return ss.str();
106
+ }
107
+
108
+ // Tests Args<k0, ..., kn>(m).
109
+
110
+ TEST(ArgsTest, AcceptsZeroTemplateArg) {
111
+ const tuple<int, bool> t(5, true);
112
+ EXPECT_THAT(t, Args<>(Eq(tuple<>())));
113
+ EXPECT_THAT(t, Not(Args<>(Ne(tuple<>()))));
114
+ }
115
+
116
+ TEST(ArgsTest, AcceptsOneTemplateArg) {
117
+ const tuple<int, bool> t(5, true);
118
+ EXPECT_THAT(t, Args<0>(Eq(make_tuple(5))));
119
+ EXPECT_THAT(t, Args<1>(Eq(make_tuple(true))));
120
+ EXPECT_THAT(t, Not(Args<1>(Eq(make_tuple(false)))));
121
+ }
122
+
123
+ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
124
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
125
+
126
+ EXPECT_THAT(t, (Args<0, 1>(Lt())));
127
+ EXPECT_THAT(t, (Args<1, 2>(Lt())));
128
+ EXPECT_THAT(t, Not(Args<0, 2>(Gt())));
129
+ }
130
+
131
+ TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
132
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
133
+ EXPECT_THAT(t, (Args<0, 0>(Eq())));
134
+ EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
135
+ }
136
+
137
+ TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
138
+ const tuple<short, int, long> t(4, 5, 6L); // NOLINT
139
+ EXPECT_THAT(t, (Args<2, 0>(Gt())));
140
+ EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
141
+ }
142
+
143
+ // The MATCHER*() macros trigger warning C4100 (unreferenced formal
144
+ // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
145
+ // the macro definition, as the warnings are generated when the macro
146
+ // is expanded and macro expansion cannot contain #pragma. Therefore
147
+ // we suppress them here.
148
+ #ifdef _MSC_VER
149
+ # pragma warning(push)
150
+ # pragma warning(disable:4100)
151
+ #endif
152
+
153
+ MATCHER(SumIsZero, "") {
154
+ return get<0>(arg) + get<1>(arg) + get<2>(arg) == 0;
155
+ }
156
+
157
+ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
158
+ EXPECT_THAT(make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
159
+ EXPECT_THAT(make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
160
+ }
161
+
162
+ TEST(ArgsTest, CanBeNested) {
163
+ const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT
164
+ EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
165
+ EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
166
+ }
167
+
168
+ TEST(ArgsTest, CanMatchTupleByValue) {
169
+ typedef tuple<char, int, int> Tuple3;
170
+ const Matcher<Tuple3> m = Args<1, 2>(Lt());
171
+ EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2)));
172
+ EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2)));
173
+ }
174
+
175
+ TEST(ArgsTest, CanMatchTupleByReference) {
176
+ typedef tuple<char, char, int> Tuple3;
177
+ const Matcher<const Tuple3&> m = Args<0, 1>(Lt());
178
+ EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2)));
179
+ EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2)));
180
+ }
181
+
182
+ // Validates that arg is printed as str.
183
+ MATCHER_P(PrintsAs, str, "") {
184
+ return testing::PrintToString(arg) == str;
185
+ }
186
+
187
+ TEST(ArgsTest, AcceptsTenTemplateArgs) {
188
+ EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
189
+ (Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
190
+ PrintsAs("(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
191
+ EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
192
+ Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
193
+ PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
194
+ }
195
+
196
+ TEST(ArgsTest, DescirbesSelfCorrectly) {
197
+ const Matcher<tuple<int, bool, char> > m = Args<2, 0>(Lt());
198
+ EXPECT_EQ("are a tuple whose fields (#2, #0) are a pair where "
199
+ "the first < the second",
200
+ Describe(m));
201
+ }
202
+
203
+ TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
204
+ const Matcher<const tuple<int, bool, char, int>&> m =
205
+ Args<0, 2, 3>(Args<2, 0>(Lt()));
206
+ EXPECT_EQ("are a tuple whose fields (#0, #2, #3) are a tuple "
207
+ "whose fields (#2, #0) are a pair where the first < the second",
208
+ Describe(m));
209
+ }
210
+
211
+ TEST(ArgsTest, DescribesNegationCorrectly) {
212
+ const Matcher<tuple<int, char> > m = Args<1, 0>(Gt());
213
+ EXPECT_EQ("are a tuple whose fields (#1, #0) aren't a pair "
214
+ "where the first > the second",
215
+ DescribeNegation(m));
216
+ }
217
+
218
+ TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
219
+ const Matcher<tuple<bool, int, int> > m = Args<1, 2>(Eq());
220
+ EXPECT_EQ("whose fields (#1, #2) are (42, 42)",
221
+ Explain(m, make_tuple(false, 42, 42)));
222
+ EXPECT_EQ("whose fields (#1, #2) are (42, 43)",
223
+ Explain(m, make_tuple(false, 42, 43)));
224
+ }
225
+
226
+ // For testing Args<>'s explanation.
227
+ class LessThanMatcher : public MatcherInterface<tuple<char, int> > {
228
+ public:
229
+ virtual void DescribeTo(::std::ostream* os) const {}
230
+
231
+ virtual bool MatchAndExplain(tuple<char, int> value,
232
+ MatchResultListener* listener) const {
233
+ const int diff = get<0>(value) - get<1>(value);
234
+ if (diff > 0) {
235
+ *listener << "where the first value is " << diff
236
+ << " more than the second";
237
+ }
238
+ return diff < 0;
239
+ }
240
+ };
241
+
242
+ Matcher<tuple<char, int> > LessThan() {
243
+ return MakeMatcher(new LessThanMatcher);
244
+ }
245
+
246
+ TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
247
+ const Matcher<tuple<char, int, int> > m = Args<0, 2>(LessThan());
248
+ EXPECT_EQ("whose fields (#0, #2) are ('a' (97, 0x61), 42), "
249
+ "where the first value is 55 more than the second",
250
+ Explain(m, make_tuple('a', 42, 42)));
251
+ EXPECT_EQ("whose fields (#0, #2) are ('\\0', 43)",
252
+ Explain(m, make_tuple('\0', 42, 43)));
253
+ }
254
+
255
+ // For testing ExplainMatchResultTo().
256
+ class GreaterThanMatcher : public MatcherInterface<int> {
257
+ public:
258
+ explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {}
259
+
260
+ virtual void DescribeTo(::std::ostream* os) const {
261
+ *os << "is greater than " << rhs_;
262
+ }
263
+
264
+ virtual bool MatchAndExplain(int lhs,
265
+ MatchResultListener* listener) const {
266
+ const int diff = lhs - rhs_;
267
+ if (diff > 0) {
268
+ *listener << "which is " << diff << " more than " << rhs_;
269
+ } else if (diff == 0) {
270
+ *listener << "which is the same as " << rhs_;
271
+ } else {
272
+ *listener << "which is " << -diff << " less than " << rhs_;
273
+ }
274
+
275
+ return lhs > rhs_;
276
+ }
277
+
278
+ private:
279
+ int rhs_;
280
+ };
281
+
282
+ Matcher<int> GreaterThan(int n) {
283
+ return MakeMatcher(new GreaterThanMatcher(n));
284
+ }
285
+
286
+ // Tests for ElementsAre().
287
+
288
+ TEST(ElementsAreTest, CanDescribeExpectingNoElement) {
289
+ Matcher<const vector<int>&> m = ElementsAre();
290
+ EXPECT_EQ("is empty", Describe(m));
291
+ }
292
+
293
+ TEST(ElementsAreTest, CanDescribeExpectingOneElement) {
294
+ Matcher<vector<int> > m = ElementsAre(Gt(5));
295
+ EXPECT_EQ("has 1 element that is > 5", Describe(m));
296
+ }
297
+
298
+ TEST(ElementsAreTest, CanDescribeExpectingManyElements) {
299
+ Matcher<list<string> > m = ElementsAre(StrEq("one"), "two");
300
+ EXPECT_EQ("has 2 elements where\n"
301
+ "element #0 is equal to \"one\",\n"
302
+ "element #1 is equal to \"two\"", Describe(m));
303
+ }
304
+
305
+ TEST(ElementsAreTest, CanDescribeNegationOfExpectingNoElement) {
306
+ Matcher<vector<int> > m = ElementsAre();
307
+ EXPECT_EQ("isn't empty", DescribeNegation(m));
308
+ }
309
+
310
+ TEST(ElementsAreTest, CanDescribeNegationOfExpectingOneElment) {
311
+ Matcher<const list<int>& > m = ElementsAre(Gt(5));
312
+ EXPECT_EQ("doesn't have 1 element, or\n"
313
+ "element #0 isn't > 5", DescribeNegation(m));
314
+ }
315
+
316
+ TEST(ElementsAreTest, CanDescribeNegationOfExpectingManyElements) {
317
+ Matcher<const list<string>& > m = ElementsAre("one", "two");
318
+ EXPECT_EQ("doesn't have 2 elements, or\n"
319
+ "element #0 isn't equal to \"one\", or\n"
320
+ "element #1 isn't equal to \"two\"", DescribeNegation(m));
321
+ }
322
+
323
+ TEST(ElementsAreTest, DoesNotExplainTrivialMatch) {
324
+ Matcher<const list<int>& > m = ElementsAre(1, Ne(2));
325
+
326
+ list<int> test_list;
327
+ test_list.push_back(1);
328
+ test_list.push_back(3);
329
+ EXPECT_EQ("", Explain(m, test_list)); // No need to explain anything.
330
+ }
331
+
332
+ TEST(ElementsAreTest, ExplainsNonTrivialMatch) {
333
+ Matcher<const vector<int>& > m =
334
+ ElementsAre(GreaterThan(1), 0, GreaterThan(2));
335
+
336
+ const int a[] = { 10, 0, 100 };
337
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
338
+ EXPECT_EQ("whose element #0 matches, which is 9 more than 1,\n"
339
+ "and whose element #2 matches, which is 98 more than 2",
340
+ Explain(m, test_vector));
341
+ }
342
+
343
+ TEST(ElementsAreTest, CanExplainMismatchWrongSize) {
344
+ Matcher<const list<int>& > m = ElementsAre(1, 3);
345
+
346
+ list<int> test_list;
347
+ // No need to explain when the container is empty.
348
+ EXPECT_EQ("", Explain(m, test_list));
349
+
350
+ test_list.push_back(1);
351
+ EXPECT_EQ("which has 1 element", Explain(m, test_list));
352
+ }
353
+
354
+ TEST(ElementsAreTest, CanExplainMismatchRightSize) {
355
+ Matcher<const vector<int>& > m = ElementsAre(1, GreaterThan(5));
356
+
357
+ vector<int> v;
358
+ v.push_back(2);
359
+ v.push_back(1);
360
+ EXPECT_EQ("whose element #0 doesn't match", Explain(m, v));
361
+
362
+ v[0] = 1;
363
+ EXPECT_EQ("whose element #1 doesn't match, which is 4 less than 5",
364
+ Explain(m, v));
365
+ }
366
+
367
+ TEST(ElementsAreTest, MatchesOneElementVector) {
368
+ vector<string> test_vector;
369
+ test_vector.push_back("test string");
370
+
371
+ EXPECT_THAT(test_vector, ElementsAre(StrEq("test string")));
372
+ }
373
+
374
+ TEST(ElementsAreTest, MatchesOneElementList) {
375
+ list<string> test_list;
376
+ test_list.push_back("test string");
377
+
378
+ EXPECT_THAT(test_list, ElementsAre("test string"));
379
+ }
380
+
381
+ TEST(ElementsAreTest, MatchesThreeElementVector) {
382
+ vector<string> test_vector;
383
+ test_vector.push_back("one");
384
+ test_vector.push_back("two");
385
+ test_vector.push_back("three");
386
+
387
+ EXPECT_THAT(test_vector, ElementsAre("one", StrEq("two"), _));
388
+ }
389
+
390
+ TEST(ElementsAreTest, MatchesOneElementEqMatcher) {
391
+ vector<int> test_vector;
392
+ test_vector.push_back(4);
393
+
394
+ EXPECT_THAT(test_vector, ElementsAre(Eq(4)));
395
+ }
396
+
397
+ TEST(ElementsAreTest, MatchesOneElementAnyMatcher) {
398
+ vector<int> test_vector;
399
+ test_vector.push_back(4);
400
+
401
+ EXPECT_THAT(test_vector, ElementsAre(_));
402
+ }
403
+
404
+ TEST(ElementsAreTest, MatchesOneElementValue) {
405
+ vector<int> test_vector;
406
+ test_vector.push_back(4);
407
+
408
+ EXPECT_THAT(test_vector, ElementsAre(4));
409
+ }
410
+
411
+ TEST(ElementsAreTest, MatchesThreeElementsMixedMatchers) {
412
+ vector<int> test_vector;
413
+ test_vector.push_back(1);
414
+ test_vector.push_back(2);
415
+ test_vector.push_back(3);
416
+
417
+ EXPECT_THAT(test_vector, ElementsAre(1, Eq(2), _));
418
+ }
419
+
420
+ TEST(ElementsAreTest, MatchesTenElementVector) {
421
+ const int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
422
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
423
+
424
+ EXPECT_THAT(test_vector,
425
+ // The element list can contain values and/or matchers
426
+ // of different types.
427
+ ElementsAre(0, Ge(0), _, 3, 4, Ne(2), Eq(6), 7, 8, _));
428
+ }
429
+
430
+ TEST(ElementsAreTest, DoesNotMatchWrongSize) {
431
+ vector<string> test_vector;
432
+ test_vector.push_back("test string");
433
+ test_vector.push_back("test string");
434
+
435
+ Matcher<vector<string> > m = ElementsAre(StrEq("test string"));
436
+ EXPECT_FALSE(m.Matches(test_vector));
437
+ }
438
+
439
+ TEST(ElementsAreTest, DoesNotMatchWrongValue) {
440
+ vector<string> test_vector;
441
+ test_vector.push_back("other string");
442
+
443
+ Matcher<vector<string> > m = ElementsAre(StrEq("test string"));
444
+ EXPECT_FALSE(m.Matches(test_vector));
445
+ }
446
+
447
+ TEST(ElementsAreTest, DoesNotMatchWrongOrder) {
448
+ vector<string> test_vector;
449
+ test_vector.push_back("one");
450
+ test_vector.push_back("three");
451
+ test_vector.push_back("two");
452
+
453
+ Matcher<vector<string> > m = ElementsAre(
454
+ StrEq("one"), StrEq("two"), StrEq("three"));
455
+ EXPECT_FALSE(m.Matches(test_vector));
456
+ }
457
+
458
+ TEST(ElementsAreTest, WorksForNestedContainer) {
459
+ const char* strings[] = {
460
+ "Hi",
461
+ "world"
462
+ };
463
+
464
+ vector<list<char> > nested;
465
+ for (size_t i = 0; i < GTEST_ARRAY_SIZE_(strings); i++) {
466
+ nested.push_back(list<char>(strings[i], strings[i] + strlen(strings[i])));
467
+ }
468
+
469
+ EXPECT_THAT(nested, ElementsAre(ElementsAre('H', Ne('e')),
470
+ ElementsAre('w', 'o', _, _, 'd')));
471
+ EXPECT_THAT(nested, Not(ElementsAre(ElementsAre('H', 'e'),
472
+ ElementsAre('w', 'o', _, _, 'd'))));
473
+ }
474
+
475
+ TEST(ElementsAreTest, WorksWithByRefElementMatchers) {
476
+ int a[] = { 0, 1, 2 };
477
+ vector<int> v(a, a + GTEST_ARRAY_SIZE_(a));
478
+
479
+ EXPECT_THAT(v, ElementsAre(Ref(v[0]), Ref(v[1]), Ref(v[2])));
480
+ EXPECT_THAT(v, Not(ElementsAre(Ref(v[0]), Ref(v[1]), Ref(a[2]))));
481
+ }
482
+
483
+ TEST(ElementsAreTest, WorksWithContainerPointerUsingPointee) {
484
+ int a[] = { 0, 1, 2 };
485
+ vector<int> v(a, a + GTEST_ARRAY_SIZE_(a));
486
+
487
+ EXPECT_THAT(&v, Pointee(ElementsAre(0, 1, _)));
488
+ EXPECT_THAT(&v, Not(Pointee(ElementsAre(0, _, 3))));
489
+ }
490
+
491
+ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {
492
+ int array[] = { 0, 1, 2 };
493
+ EXPECT_THAT(array, ElementsAre(0, 1, _));
494
+ EXPECT_THAT(array, Not(ElementsAre(1, _, _)));
495
+ EXPECT_THAT(array, Not(ElementsAre(0, _)));
496
+ }
497
+
498
+ class NativeArrayPassedAsPointerAndSize {
499
+ public:
500
+ NativeArrayPassedAsPointerAndSize() {}
501
+
502
+ MOCK_METHOD2(Helper, void(int* array, int size));
503
+
504
+ private:
505
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(NativeArrayPassedAsPointerAndSize);
506
+ };
507
+
508
+ TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {
509
+ int array[] = { 0, 1 };
510
+ ::testing::tuple<int*, size_t> array_as_tuple(array, 2);
511
+ EXPECT_THAT(array_as_tuple, ElementsAre(0, 1));
512
+ EXPECT_THAT(array_as_tuple, Not(ElementsAre(0)));
513
+
514
+ NativeArrayPassedAsPointerAndSize helper;
515
+ EXPECT_CALL(helper, Helper(_, _))
516
+ .With(ElementsAre(0, 1));
517
+ helper.Helper(array, 2);
518
+ }
519
+
520
+ TEST(ElementsAreTest, WorksWithTwoDimensionalNativeArray) {
521
+ const char a2[][3] = { "hi", "lo" };
522
+ EXPECT_THAT(a2, ElementsAre(ElementsAre('h', 'i', '\0'),
523
+ ElementsAre('l', 'o', '\0')));
524
+ EXPECT_THAT(a2, ElementsAre(StrEq("hi"), StrEq("lo")));
525
+ EXPECT_THAT(a2, ElementsAre(Not(ElementsAre('h', 'o', '\0')),
526
+ ElementsAre('l', 'o', '\0')));
527
+ }
528
+
529
+ TEST(ElementsAreTest, AcceptsStringLiteral) {
530
+ string array[] = { "hi", "one", "two" };
531
+ EXPECT_THAT(array, ElementsAre("hi", "one", "two"));
532
+ EXPECT_THAT(array, Not(ElementsAre("hi", "one", "too")));
533
+ }
534
+
535
+ #ifndef _MSC_VER
536
+
537
+ // The following test passes a value of type const char[] to a
538
+ // function template that expects const T&. Some versions of MSVC
539
+ // generates a compiler error C2665 for that. We believe it's a bug
540
+ // in MSVC. Therefore this test is #if-ed out for MSVC.
541
+
542
+ // Declared here with the size unknown. Defined AFTER the following test.
543
+ extern const char kHi[];
544
+
545
+ TEST(ElementsAreTest, AcceptsArrayWithUnknownSize) {
546
+ // The size of kHi is not known in this test, but ElementsAre() should
547
+ // still accept it.
548
+
549
+ string array1[] = { "hi" };
550
+ EXPECT_THAT(array1, ElementsAre(kHi));
551
+
552
+ string array2[] = { "ho" };
553
+ EXPECT_THAT(array2, Not(ElementsAre(kHi)));
554
+ }
555
+
556
+ const char kHi[] = "hi";
557
+
558
+ #endif // _MSC_VER
559
+
560
+ TEST(ElementsAreTest, MakesCopyOfArguments) {
561
+ int x = 1;
562
+ int y = 2;
563
+ // This should make a copy of x and y.
564
+ ::testing::internal::ElementsAreMatcher<testing::tuple<int, int> >
565
+ polymorphic_matcher = ElementsAre(x, y);
566
+ // Changing x and y now shouldn't affect the meaning of the above matcher.
567
+ x = y = 0;
568
+ const int array1[] = { 1, 2 };
569
+ EXPECT_THAT(array1, polymorphic_matcher);
570
+ const int array2[] = { 0, 0 };
571
+ EXPECT_THAT(array2, Not(polymorphic_matcher));
572
+ }
573
+
574
+
575
+ // Tests for ElementsAreArray(). Since ElementsAreArray() shares most
576
+ // of the implementation with ElementsAre(), we don't test it as
577
+ // thoroughly here.
578
+
579
+ TEST(ElementsAreArrayTest, CanBeCreatedWithValueArray) {
580
+ const int a[] = { 1, 2, 3 };
581
+
582
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
583
+ EXPECT_THAT(test_vector, ElementsAreArray(a));
584
+
585
+ test_vector[2] = 0;
586
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(a)));
587
+ }
588
+
589
+ TEST(ElementsAreArrayTest, CanBeCreatedWithArraySize) {
590
+ const char* a[] = { "one", "two", "three" };
591
+
592
+ vector<string> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
593
+ EXPECT_THAT(test_vector, ElementsAreArray(a, GTEST_ARRAY_SIZE_(a)));
594
+
595
+ const char** p = a;
596
+ test_vector[0] = "1";
597
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(p, GTEST_ARRAY_SIZE_(a))));
598
+ }
599
+
600
+ TEST(ElementsAreArrayTest, CanBeCreatedWithoutArraySize) {
601
+ const char* a[] = { "one", "two", "three" };
602
+
603
+ vector<string> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
604
+ EXPECT_THAT(test_vector, ElementsAreArray(a));
605
+
606
+ test_vector[0] = "1";
607
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(a)));
608
+ }
609
+
610
+ TEST(ElementsAreArrayTest, CanBeCreatedWithMatcherArray) {
611
+ const Matcher<string> kMatcherArray[] =
612
+ { StrEq("one"), StrEq("two"), StrEq("three") };
613
+
614
+ vector<string> test_vector;
615
+ test_vector.push_back("one");
616
+ test_vector.push_back("two");
617
+ test_vector.push_back("three");
618
+ EXPECT_THAT(test_vector, ElementsAreArray(kMatcherArray));
619
+
620
+ test_vector.push_back("three");
621
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(kMatcherArray)));
622
+ }
623
+
624
+ TEST(ElementsAreArrayTest, CanBeCreatedWithVector) {
625
+ const int a[] = { 1, 2, 3 };
626
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
627
+ const vector<int> expected(a, a + GTEST_ARRAY_SIZE_(a));
628
+ EXPECT_THAT(test_vector, ElementsAreArray(expected));
629
+ test_vector.push_back(4);
630
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(expected)));
631
+ }
632
+
633
+ #if GTEST_HAS_STD_INITIALIZER_LIST_
634
+
635
+ TEST(ElementsAreArrayTest, TakesInitializerList) {
636
+ const int a[5] = { 1, 2, 3, 4, 5 };
637
+ EXPECT_THAT(a, ElementsAreArray({ 1, 2, 3, 4, 5 }));
638
+ EXPECT_THAT(a, Not(ElementsAreArray({ 1, 2, 3, 5, 4 })));
639
+ EXPECT_THAT(a, Not(ElementsAreArray({ 1, 2, 3, 4, 6 })));
640
+ }
641
+
642
+ TEST(ElementsAreArrayTest, TakesInitializerListOfCStrings) {
643
+ const string a[5] = { "a", "b", "c", "d", "e" };
644
+ EXPECT_THAT(a, ElementsAreArray({ "a", "b", "c", "d", "e" }));
645
+ EXPECT_THAT(a, Not(ElementsAreArray({ "a", "b", "c", "e", "d" })));
646
+ EXPECT_THAT(a, Not(ElementsAreArray({ "a", "b", "c", "d", "ef" })));
647
+ }
648
+
649
+ TEST(ElementsAreArrayTest, TakesInitializerListOfSameTypedMatchers) {
650
+ const int a[5] = { 1, 2, 3, 4, 5 };
651
+ EXPECT_THAT(a, ElementsAreArray(
652
+ { Eq(1), Eq(2), Eq(3), Eq(4), Eq(5) }));
653
+ EXPECT_THAT(a, Not(ElementsAreArray(
654
+ { Eq(1), Eq(2), Eq(3), Eq(4), Eq(6) })));
655
+ }
656
+
657
+ TEST(ElementsAreArrayTest,
658
+ TakesInitializerListOfDifferentTypedMatchers) {
659
+ const int a[5] = { 1, 2, 3, 4, 5 };
660
+ // The compiler cannot infer the type of the initializer list if its
661
+ // elements have different types. We must explicitly specify the
662
+ // unified element type in this case.
663
+ EXPECT_THAT(a, ElementsAreArray<Matcher<int> >(
664
+ { Eq(1), Ne(-2), Ge(3), Le(4), Eq(5) }));
665
+ EXPECT_THAT(a, Not(ElementsAreArray<Matcher<int> >(
666
+ { Eq(1), Ne(-2), Ge(3), Le(4), Eq(6) })));
667
+ }
668
+
669
+ #endif // GTEST_HAS_STD_INITIALIZER_LIST_
670
+
671
+ TEST(ElementsAreArrayTest, CanBeCreatedWithMatcherVector) {
672
+ const int a[] = { 1, 2, 3 };
673
+ const Matcher<int> kMatchers[] = { Eq(1), Eq(2), Eq(3) };
674
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
675
+ const vector<Matcher<int> > expected(
676
+ kMatchers, kMatchers + GTEST_ARRAY_SIZE_(kMatchers));
677
+ EXPECT_THAT(test_vector, ElementsAreArray(expected));
678
+ test_vector.push_back(4);
679
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(expected)));
680
+ }
681
+
682
+ TEST(ElementsAreArrayTest, CanBeCreatedWithIteratorRange) {
683
+ const int a[] = { 1, 2, 3 };
684
+ const vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
685
+ const vector<int> expected(a, a + GTEST_ARRAY_SIZE_(a));
686
+ EXPECT_THAT(test_vector, ElementsAreArray(expected.begin(), expected.end()));
687
+ // Pointers are iterators, too.
688
+ EXPECT_THAT(test_vector, ElementsAreArray(a, a + GTEST_ARRAY_SIZE_(a)));
689
+ // The empty range of NULL pointers should also be okay.
690
+ int* const null_int = NULL;
691
+ EXPECT_THAT(test_vector, Not(ElementsAreArray(null_int, null_int)));
692
+ EXPECT_THAT((vector<int>()), ElementsAreArray(null_int, null_int));
693
+ }
694
+
695
+ // Since ElementsAre() and ElementsAreArray() share much of the
696
+ // implementation, we only do a sanity test for native arrays here.
697
+ TEST(ElementsAreArrayTest, WorksWithNativeArray) {
698
+ ::std::string a[] = { "hi", "ho" };
699
+ ::std::string b[] = { "hi", "ho" };
700
+
701
+ EXPECT_THAT(a, ElementsAreArray(b));
702
+ EXPECT_THAT(a, ElementsAreArray(b, 2));
703
+ EXPECT_THAT(a, Not(ElementsAreArray(b, 1)));
704
+ }
705
+
706
+ TEST(ElementsAreArrayTest, SourceLifeSpan) {
707
+ const int a[] = { 1, 2, 3 };
708
+ vector<int> test_vector(a, a + GTEST_ARRAY_SIZE_(a));
709
+ vector<int> expect(a, a + GTEST_ARRAY_SIZE_(a));
710
+ ElementsAreArrayMatcher<int> matcher_maker =
711
+ ElementsAreArray(expect.begin(), expect.end());
712
+ EXPECT_THAT(test_vector, matcher_maker);
713
+ // Changing in place the values that initialized matcher_maker should not
714
+ // affect matcher_maker anymore. It should have made its own copy of them.
715
+ typedef vector<int>::iterator Iter;
716
+ for (Iter it = expect.begin(); it != expect.end(); ++it) { *it += 10; }
717
+ EXPECT_THAT(test_vector, matcher_maker);
718
+ test_vector.push_back(3);
719
+ EXPECT_THAT(test_vector, Not(matcher_maker));
720
+ }
721
+
722
+ // Tests for the MATCHER*() macro family.
723
+
724
+ // Tests that a simple MATCHER() definition works.
725
+
726
+ MATCHER(IsEven, "") { return (arg % 2) == 0; }
727
+
728
+ TEST(MatcherMacroTest, Works) {
729
+ const Matcher<int> m = IsEven();
730
+ EXPECT_TRUE(m.Matches(6));
731
+ EXPECT_FALSE(m.Matches(7));
732
+
733
+ EXPECT_EQ("is even", Describe(m));
734
+ EXPECT_EQ("not (is even)", DescribeNegation(m));
735
+ EXPECT_EQ("", Explain(m, 6));
736
+ EXPECT_EQ("", Explain(m, 7));
737
+ }
738
+
739
+ // This also tests that the description string can reference 'negation'.
740
+ MATCHER(IsEven2, negation ? "is odd" : "is even") {
741
+ if ((arg % 2) == 0) {
742
+ // Verifies that we can stream to result_listener, a listener
743
+ // supplied by the MATCHER macro implicitly.
744
+ *result_listener << "OK";
745
+ return true;
746
+ } else {
747
+ *result_listener << "% 2 == " << (arg % 2);
748
+ return false;
749
+ }
750
+ }
751
+
752
+ // This also tests that the description string can reference matcher
753
+ // parameters.
754
+ MATCHER_P2(EqSumOf, x, y,
755
+ string(negation ? "doesn't equal" : "equals") + " the sum of " +
756
+ PrintToString(x) + " and " + PrintToString(y)) {
757
+ if (arg == (x + y)) {
758
+ *result_listener << "OK";
759
+ return true;
760
+ } else {
761
+ // Verifies that we can stream to the underlying stream of
762
+ // result_listener.
763
+ if (result_listener->stream() != NULL) {
764
+ *result_listener->stream() << "diff == " << (x + y - arg);
765
+ }
766
+ return false;
767
+ }
768
+ }
769
+
770
+ // Tests that the matcher description can reference 'negation' and the
771
+ // matcher parameters.
772
+ TEST(MatcherMacroTest, DescriptionCanReferenceNegationAndParameters) {
773
+ const Matcher<int> m1 = IsEven2();
774
+ EXPECT_EQ("is even", Describe(m1));
775
+ EXPECT_EQ("is odd", DescribeNegation(m1));
776
+
777
+ const Matcher<int> m2 = EqSumOf(5, 9);
778
+ EXPECT_EQ("equals the sum of 5 and 9", Describe(m2));
779
+ EXPECT_EQ("doesn't equal the sum of 5 and 9", DescribeNegation(m2));
780
+ }
781
+
782
+ // Tests explaining match result in a MATCHER* macro.
783
+ TEST(MatcherMacroTest, CanExplainMatchResult) {
784
+ const Matcher<int> m1 = IsEven2();
785
+ EXPECT_EQ("OK", Explain(m1, 4));
786
+ EXPECT_EQ("% 2 == 1", Explain(m1, 5));
787
+
788
+ const Matcher<int> m2 = EqSumOf(1, 2);
789
+ EXPECT_EQ("OK", Explain(m2, 3));
790
+ EXPECT_EQ("diff == -1", Explain(m2, 4));
791
+ }
792
+
793
+ // Tests that the body of MATCHER() can reference the type of the
794
+ // value being matched.
795
+
796
+ MATCHER(IsEmptyString, "") {
797
+ StaticAssertTypeEq< ::std::string, arg_type>();
798
+ return arg == "";
799
+ }
800
+
801
+ MATCHER(IsEmptyStringByRef, "") {
802
+ StaticAssertTypeEq<const ::std::string&, arg_type>();
803
+ return arg == "";
804
+ }
805
+
806
+ TEST(MatcherMacroTest, CanReferenceArgType) {
807
+ const Matcher< ::std::string> m1 = IsEmptyString();
808
+ EXPECT_TRUE(m1.Matches(""));
809
+
810
+ const Matcher<const ::std::string&> m2 = IsEmptyStringByRef();
811
+ EXPECT_TRUE(m2.Matches(""));
812
+ }
813
+
814
+ // Tests that MATCHER() can be used in a namespace.
815
+
816
+ namespace matcher_test {
817
+ MATCHER(IsOdd, "") { return (arg % 2) != 0; }
818
+ } // namespace matcher_test
819
+
820
+ TEST(MatcherMacroTest, WorksInNamespace) {
821
+ Matcher<int> m = matcher_test::IsOdd();
822
+ EXPECT_FALSE(m.Matches(4));
823
+ EXPECT_TRUE(m.Matches(5));
824
+ }
825
+
826
+ // Tests that Value() can be used to compose matchers.
827
+ MATCHER(IsPositiveOdd, "") {
828
+ return Value(arg, matcher_test::IsOdd()) && arg > 0;
829
+ }
830
+
831
+ TEST(MatcherMacroTest, CanBeComposedUsingValue) {
832
+ EXPECT_THAT(3, IsPositiveOdd());
833
+ EXPECT_THAT(4, Not(IsPositiveOdd()));
834
+ EXPECT_THAT(-1, Not(IsPositiveOdd()));
835
+ }
836
+
837
+ // Tests that a simple MATCHER_P() definition works.
838
+
839
+ MATCHER_P(IsGreaterThan32And, n, "") { return arg > 32 && arg > n; }
840
+
841
+ TEST(MatcherPMacroTest, Works) {
842
+ const Matcher<int> m = IsGreaterThan32And(5);
843
+ EXPECT_TRUE(m.Matches(36));
844
+ EXPECT_FALSE(m.Matches(5));
845
+
846
+ EXPECT_EQ("is greater than 32 and 5", Describe(m));
847
+ EXPECT_EQ("not (is greater than 32 and 5)", DescribeNegation(m));
848
+ EXPECT_EQ("", Explain(m, 36));
849
+ EXPECT_EQ("", Explain(m, 5));
850
+ }
851
+
852
+ // Tests that the description is calculated correctly from the matcher name.
853
+ MATCHER_P(_is_Greater_Than32and_, n, "") { return arg > 32 && arg > n; }
854
+
855
+ TEST(MatcherPMacroTest, GeneratesCorrectDescription) {
856
+ const Matcher<int> m = _is_Greater_Than32and_(5);
857
+
858
+ EXPECT_EQ("is greater than 32 and 5", Describe(m));
859
+ EXPECT_EQ("not (is greater than 32 and 5)", DescribeNegation(m));
860
+ EXPECT_EQ("", Explain(m, 36));
861
+ EXPECT_EQ("", Explain(m, 5));
862
+ }
863
+
864
+ // Tests that a MATCHER_P matcher can be explicitly instantiated with
865
+ // a reference parameter type.
866
+
867
+ class UncopyableFoo {
868
+ public:
869
+ explicit UncopyableFoo(char value) : value_(value) {}
870
+ private:
871
+ UncopyableFoo(const UncopyableFoo&);
872
+ void operator=(const UncopyableFoo&);
873
+
874
+ char value_;
875
+ };
876
+
877
+ MATCHER_P(ReferencesUncopyable, variable, "") { return &arg == &variable; }
878
+
879
+ TEST(MatcherPMacroTest, WorksWhenExplicitlyInstantiatedWithReference) {
880
+ UncopyableFoo foo1('1'), foo2('2');
881
+ const Matcher<const UncopyableFoo&> m =
882
+ ReferencesUncopyable<const UncopyableFoo&>(foo1);
883
+
884
+ EXPECT_TRUE(m.Matches(foo1));
885
+ EXPECT_FALSE(m.Matches(foo2));
886
+
887
+ // We don't want the address of the parameter printed, as most
888
+ // likely it will just annoy the user. If the address is
889
+ // interesting, the user should consider passing the parameter by
890
+ // pointer instead.
891
+ EXPECT_EQ("references uncopyable 1-byte object <31>", Describe(m));
892
+ }
893
+
894
+
895
+ // Tests that the body of MATCHER_Pn() can reference the parameter
896
+ // types.
897
+
898
+ MATCHER_P3(ParamTypesAreIntLongAndChar, foo, bar, baz, "") {
899
+ StaticAssertTypeEq<int, foo_type>();
900
+ StaticAssertTypeEq<long, bar_type>(); // NOLINT
901
+ StaticAssertTypeEq<char, baz_type>();
902
+ return arg == 0;
903
+ }
904
+
905
+ TEST(MatcherPnMacroTest, CanReferenceParamTypes) {
906
+ EXPECT_THAT(0, ParamTypesAreIntLongAndChar(10, 20L, 'a'));
907
+ }
908
+
909
+ // Tests that a MATCHER_Pn matcher can be explicitly instantiated with
910
+ // reference parameter types.
911
+
912
+ MATCHER_P2(ReferencesAnyOf, variable1, variable2, "") {
913
+ return &arg == &variable1 || &arg == &variable2;
914
+ }
915
+
916
+ TEST(MatcherPnMacroTest, WorksWhenExplicitlyInstantiatedWithReferences) {
917
+ UncopyableFoo foo1('1'), foo2('2'), foo3('3');
918
+ const Matcher<const UncopyableFoo&> m =
919
+ ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
920
+
921
+ EXPECT_TRUE(m.Matches(foo1));
922
+ EXPECT_TRUE(m.Matches(foo2));
923
+ EXPECT_FALSE(m.Matches(foo3));
924
+ }
925
+
926
+ TEST(MatcherPnMacroTest,
927
+ GeneratesCorretDescriptionWhenExplicitlyInstantiatedWithReferences) {
928
+ UncopyableFoo foo1('1'), foo2('2');
929
+ const Matcher<const UncopyableFoo&> m =
930
+ ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);
931
+
932
+ // We don't want the addresses of the parameters printed, as most
933
+ // likely they will just annoy the user. If the addresses are
934
+ // interesting, the user should consider passing the parameters by
935
+ // pointers instead.
936
+ EXPECT_EQ("references any of (1-byte object <31>, 1-byte object <32>)",
937
+ Describe(m));
938
+ }
939
+
940
+ // Tests that a simple MATCHER_P2() definition works.
941
+
942
+ MATCHER_P2(IsNotInClosedRange, low, hi, "") { return arg < low || arg > hi; }
943
+
944
+ TEST(MatcherPnMacroTest, Works) {
945
+ const Matcher<const long&> m = IsNotInClosedRange(10, 20); // NOLINT
946
+ EXPECT_TRUE(m.Matches(36L));
947
+ EXPECT_FALSE(m.Matches(15L));
948
+
949
+ EXPECT_EQ("is not in closed range (10, 20)", Describe(m));
950
+ EXPECT_EQ("not (is not in closed range (10, 20))", DescribeNegation(m));
951
+ EXPECT_EQ("", Explain(m, 36L));
952
+ EXPECT_EQ("", Explain(m, 15L));
953
+ }
954
+
955
+ // Tests that MATCHER*() definitions can be overloaded on the number
956
+ // of parameters; also tests MATCHER_Pn() where n >= 3.
957
+
958
+ MATCHER(EqualsSumOf, "") { return arg == 0; }
959
+ MATCHER_P(EqualsSumOf, a, "") { return arg == a; }
960
+ MATCHER_P2(EqualsSumOf, a, b, "") { return arg == a + b; }
961
+ MATCHER_P3(EqualsSumOf, a, b, c, "") { return arg == a + b + c; }
962
+ MATCHER_P4(EqualsSumOf, a, b, c, d, "") { return arg == a + b + c + d; }
963
+ MATCHER_P5(EqualsSumOf, a, b, c, d, e, "") { return arg == a + b + c + d + e; }
964
+ MATCHER_P6(EqualsSumOf, a, b, c, d, e, f, "") {
965
+ return arg == a + b + c + d + e + f;
966
+ }
967
+ MATCHER_P7(EqualsSumOf, a, b, c, d, e, f, g, "") {
968
+ return arg == a + b + c + d + e + f + g;
969
+ }
970
+ MATCHER_P8(EqualsSumOf, a, b, c, d, e, f, g, h, "") {
971
+ return arg == a + b + c + d + e + f + g + h;
972
+ }
973
+ MATCHER_P9(EqualsSumOf, a, b, c, d, e, f, g, h, i, "") {
974
+ return arg == a + b + c + d + e + f + g + h + i;
975
+ }
976
+ MATCHER_P10(EqualsSumOf, a, b, c, d, e, f, g, h, i, j, "") {
977
+ return arg == a + b + c + d + e + f + g + h + i + j;
978
+ }
979
+
980
+ TEST(MatcherPnMacroTest, CanBeOverloadedOnNumberOfParameters) {
981
+ EXPECT_THAT(0, EqualsSumOf());
982
+ EXPECT_THAT(1, EqualsSumOf(1));
983
+ EXPECT_THAT(12, EqualsSumOf(10, 2));
984
+ EXPECT_THAT(123, EqualsSumOf(100, 20, 3));
985
+ EXPECT_THAT(1234, EqualsSumOf(1000, 200, 30, 4));
986
+ EXPECT_THAT(12345, EqualsSumOf(10000, 2000, 300, 40, 5));
987
+ EXPECT_THAT("abcdef",
988
+ EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f'));
989
+ EXPECT_THAT("abcdefg",
990
+ EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g'));
991
+ EXPECT_THAT("abcdefgh",
992
+ EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
993
+ "h"));
994
+ EXPECT_THAT("abcdefghi",
995
+ EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
996
+ "h", 'i'));
997
+ EXPECT_THAT("abcdefghij",
998
+ EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
999
+ "h", 'i', ::std::string("j")));
1000
+
1001
+ EXPECT_THAT(1, Not(EqualsSumOf()));
1002
+ EXPECT_THAT(-1, Not(EqualsSumOf(1)));
1003
+ EXPECT_THAT(-12, Not(EqualsSumOf(10, 2)));
1004
+ EXPECT_THAT(-123, Not(EqualsSumOf(100, 20, 3)));
1005
+ EXPECT_THAT(-1234, Not(EqualsSumOf(1000, 200, 30, 4)));
1006
+ EXPECT_THAT(-12345, Not(EqualsSumOf(10000, 2000, 300, 40, 5)));
1007
+ EXPECT_THAT("abcdef ",
1008
+ Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f')));
1009
+ EXPECT_THAT("abcdefg ",
1010
+ Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f',
1011
+ 'g')));
1012
+ EXPECT_THAT("abcdefgh ",
1013
+ Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
1014
+ "h")));
1015
+ EXPECT_THAT("abcdefghi ",
1016
+ Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
1017
+ "h", 'i')));
1018
+ EXPECT_THAT("abcdefghij ",
1019
+ Not(EqualsSumOf(::std::string("a"), 'b', 'c', "d", "e", 'f', 'g',
1020
+ "h", 'i', ::std::string("j"))));
1021
+ }
1022
+
1023
+ // Tests that a MATCHER_Pn() definition can be instantiated with any
1024
+ // compatible parameter types.
1025
+ TEST(MatcherPnMacroTest, WorksForDifferentParameterTypes) {
1026
+ EXPECT_THAT(123, EqualsSumOf(100L, 20, static_cast<char>(3)));
1027
+ EXPECT_THAT("abcd", EqualsSumOf(::std::string("a"), "b", 'c', "d"));
1028
+
1029
+ EXPECT_THAT(124, Not(EqualsSumOf(100L, 20, static_cast<char>(3))));
1030
+ EXPECT_THAT("abcde", Not(EqualsSumOf(::std::string("a"), "b", 'c', "d")));
1031
+ }
1032
+
1033
+ // Tests that the matcher body can promote the parameter types.
1034
+
1035
+ MATCHER_P2(EqConcat, prefix, suffix, "") {
1036
+ // The following lines promote the two parameters to desired types.
1037
+ std::string prefix_str(prefix);
1038
+ char suffix_char = static_cast<char>(suffix);
1039
+ return arg == prefix_str + suffix_char;
1040
+ }
1041
+
1042
+ TEST(MatcherPnMacroTest, SimpleTypePromotion) {
1043
+ Matcher<std::string> no_promo =
1044
+ EqConcat(std::string("foo"), 't');
1045
+ Matcher<const std::string&> promo =
1046
+ EqConcat("foo", static_cast<int>('t'));
1047
+ EXPECT_FALSE(no_promo.Matches("fool"));
1048
+ EXPECT_FALSE(promo.Matches("fool"));
1049
+ EXPECT_TRUE(no_promo.Matches("foot"));
1050
+ EXPECT_TRUE(promo.Matches("foot"));
1051
+ }
1052
+
1053
+ // Verifies the type of a MATCHER*.
1054
+
1055
+ TEST(MatcherPnMacroTest, TypesAreCorrect) {
1056
+ // EqualsSumOf() must be assignable to a EqualsSumOfMatcher variable.
1057
+ EqualsSumOfMatcher a0 = EqualsSumOf();
1058
+
1059
+ // EqualsSumOf(1) must be assignable to a EqualsSumOfMatcherP variable.
1060
+ EqualsSumOfMatcherP<int> a1 = EqualsSumOf(1);
1061
+
1062
+ // EqualsSumOf(p1, ..., pk) must be assignable to a EqualsSumOfMatcherPk
1063
+ // variable, and so on.
1064
+ EqualsSumOfMatcherP2<int, char> a2 = EqualsSumOf(1, '2');
1065
+ EqualsSumOfMatcherP3<int, int, char> a3 = EqualsSumOf(1, 2, '3');
1066
+ EqualsSumOfMatcherP4<int, int, int, char> a4 = EqualsSumOf(1, 2, 3, '4');
1067
+ EqualsSumOfMatcherP5<int, int, int, int, char> a5 =
1068
+ EqualsSumOf(1, 2, 3, 4, '5');
1069
+ EqualsSumOfMatcherP6<int, int, int, int, int, char> a6 =
1070
+ EqualsSumOf(1, 2, 3, 4, 5, '6');
1071
+ EqualsSumOfMatcherP7<int, int, int, int, int, int, char> a7 =
1072
+ EqualsSumOf(1, 2, 3, 4, 5, 6, '7');
1073
+ EqualsSumOfMatcherP8<int, int, int, int, int, int, int, char> a8 =
1074
+ EqualsSumOf(1, 2, 3, 4, 5, 6, 7, '8');
1075
+ EqualsSumOfMatcherP9<int, int, int, int, int, int, int, int, char> a9 =
1076
+ EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, '9');
1077
+ EqualsSumOfMatcherP10<int, int, int, int, int, int, int, int, int, char> a10 =
1078
+ EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, 9, '0');
1079
+
1080
+ // Avoid "unused variable" warnings.
1081
+ (void)a0;
1082
+ (void)a1;
1083
+ (void)a2;
1084
+ (void)a3;
1085
+ (void)a4;
1086
+ (void)a5;
1087
+ (void)a6;
1088
+ (void)a7;
1089
+ (void)a8;
1090
+ (void)a9;
1091
+ (void)a10;
1092
+ }
1093
+
1094
+ // Tests that matcher-typed parameters can be used in Value() inside a
1095
+ // MATCHER_Pn definition.
1096
+
1097
+ // Succeeds if arg matches exactly 2 of the 3 matchers.
1098
+ MATCHER_P3(TwoOf, m1, m2, m3, "") {
1099
+ const int count = static_cast<int>(Value(arg, m1))
1100
+ + static_cast<int>(Value(arg, m2)) + static_cast<int>(Value(arg, m3));
1101
+ return count == 2;
1102
+ }
1103
+
1104
+ TEST(MatcherPnMacroTest, CanUseMatcherTypedParameterInValue) {
1105
+ EXPECT_THAT(42, TwoOf(Gt(0), Lt(50), Eq(10)));
1106
+ EXPECT_THAT(0, Not(TwoOf(Gt(-1), Lt(1), Eq(0))));
1107
+ }
1108
+
1109
+ // Tests Contains().
1110
+
1111
+ TEST(ContainsTest, ListMatchesWhenElementIsInContainer) {
1112
+ list<int> some_list;
1113
+ some_list.push_back(3);
1114
+ some_list.push_back(1);
1115
+ some_list.push_back(2);
1116
+ EXPECT_THAT(some_list, Contains(1));
1117
+ EXPECT_THAT(some_list, Contains(Gt(2.5)));
1118
+ EXPECT_THAT(some_list, Contains(Eq(2.0f)));
1119
+
1120
+ list<string> another_list;
1121
+ another_list.push_back("fee");
1122
+ another_list.push_back("fie");
1123
+ another_list.push_back("foe");
1124
+ another_list.push_back("fum");
1125
+ EXPECT_THAT(another_list, Contains(string("fee")));
1126
+ }
1127
+
1128
+ TEST(ContainsTest, ListDoesNotMatchWhenElementIsNotInContainer) {
1129
+ list<int> some_list;
1130
+ some_list.push_back(3);
1131
+ some_list.push_back(1);
1132
+ EXPECT_THAT(some_list, Not(Contains(4)));
1133
+ }
1134
+
1135
+ TEST(ContainsTest, SetMatchesWhenElementIsInContainer) {
1136
+ set<int> some_set;
1137
+ some_set.insert(3);
1138
+ some_set.insert(1);
1139
+ some_set.insert(2);
1140
+ EXPECT_THAT(some_set, Contains(Eq(1.0)));
1141
+ EXPECT_THAT(some_set, Contains(Eq(3.0f)));
1142
+ EXPECT_THAT(some_set, Contains(2));
1143
+
1144
+ set<const char*> another_set;
1145
+ another_set.insert("fee");
1146
+ another_set.insert("fie");
1147
+ another_set.insert("foe");
1148
+ another_set.insert("fum");
1149
+ EXPECT_THAT(another_set, Contains(Eq(string("fum"))));
1150
+ }
1151
+
1152
+ TEST(ContainsTest, SetDoesNotMatchWhenElementIsNotInContainer) {
1153
+ set<int> some_set;
1154
+ some_set.insert(3);
1155
+ some_set.insert(1);
1156
+ EXPECT_THAT(some_set, Not(Contains(4)));
1157
+
1158
+ set<const char*> c_string_set;
1159
+ c_string_set.insert("hello");
1160
+ EXPECT_THAT(c_string_set, Not(Contains(string("hello").c_str())));
1161
+ }
1162
+
1163
+ TEST(ContainsTest, ExplainsMatchResultCorrectly) {
1164
+ const int a[2] = { 1, 2 };
1165
+ Matcher<const int (&)[2]> m = Contains(2);
1166
+ EXPECT_EQ("whose element #1 matches", Explain(m, a));
1167
+
1168
+ m = Contains(3);
1169
+ EXPECT_EQ("", Explain(m, a));
1170
+
1171
+ m = Contains(GreaterThan(0));
1172
+ EXPECT_EQ("whose element #0 matches, which is 1 more than 0", Explain(m, a));
1173
+
1174
+ m = Contains(GreaterThan(10));
1175
+ EXPECT_EQ("", Explain(m, a));
1176
+ }
1177
+
1178
+ TEST(ContainsTest, DescribesItselfCorrectly) {
1179
+ Matcher<vector<int> > m = Contains(1);
1180
+ EXPECT_EQ("contains at least one element that is equal to 1", Describe(m));
1181
+
1182
+ Matcher<vector<int> > m2 = Not(m);
1183
+ EXPECT_EQ("doesn't contain any element that is equal to 1", Describe(m2));
1184
+ }
1185
+
1186
+ TEST(ContainsTest, MapMatchesWhenElementIsInContainer) {
1187
+ map<const char*, int> my_map;
1188
+ const char* bar = "a string";
1189
+ my_map[bar] = 2;
1190
+ EXPECT_THAT(my_map, Contains(pair<const char* const, int>(bar, 2)));
1191
+
1192
+ map<string, int> another_map;
1193
+ another_map["fee"] = 1;
1194
+ another_map["fie"] = 2;
1195
+ another_map["foe"] = 3;
1196
+ another_map["fum"] = 4;
1197
+ EXPECT_THAT(another_map, Contains(pair<const string, int>(string("fee"), 1)));
1198
+ EXPECT_THAT(another_map, Contains(pair<const string, int>("fie", 2)));
1199
+ }
1200
+
1201
+ TEST(ContainsTest, MapDoesNotMatchWhenElementIsNotInContainer) {
1202
+ map<int, int> some_map;
1203
+ some_map[1] = 11;
1204
+ some_map[2] = 22;
1205
+ EXPECT_THAT(some_map, Not(Contains(pair<const int, int>(2, 23))));
1206
+ }
1207
+
1208
+ TEST(ContainsTest, ArrayMatchesWhenElementIsInContainer) {
1209
+ const char* string_array[] = { "fee", "fie", "foe", "fum" };
1210
+ EXPECT_THAT(string_array, Contains(Eq(string("fum"))));
1211
+ }
1212
+
1213
+ TEST(ContainsTest, ArrayDoesNotMatchWhenElementIsNotInContainer) {
1214
+ int int_array[] = { 1, 2, 3, 4 };
1215
+ EXPECT_THAT(int_array, Not(Contains(5)));
1216
+ }
1217
+
1218
+ TEST(ContainsTest, AcceptsMatcher) {
1219
+ const int a[] = { 1, 2, 3 };
1220
+ EXPECT_THAT(a, Contains(Gt(2)));
1221
+ EXPECT_THAT(a, Not(Contains(Gt(4))));
1222
+ }
1223
+
1224
+ TEST(ContainsTest, WorksForNativeArrayAsTuple) {
1225
+ const int a[] = { 1, 2 };
1226
+ const int* const pointer = a;
1227
+ EXPECT_THAT(make_tuple(pointer, 2), Contains(1));
1228
+ EXPECT_THAT(make_tuple(pointer, 2), Not(Contains(Gt(3))));
1229
+ }
1230
+
1231
+ TEST(ContainsTest, WorksForTwoDimensionalNativeArray) {
1232
+ int a[][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
1233
+ EXPECT_THAT(a, Contains(ElementsAre(4, 5, 6)));
1234
+ EXPECT_THAT(a, Contains(Contains(5)));
1235
+ EXPECT_THAT(a, Not(Contains(ElementsAre(3, 4, 5))));
1236
+ EXPECT_THAT(a, Contains(Not(Contains(5))));
1237
+ }
1238
+
1239
+ TEST(AllOfTest, HugeMatcher) {
1240
+ // Verify that using AllOf with many arguments doesn't cause
1241
+ // the compiler to exceed template instantiation depth limit.
1242
+ EXPECT_THAT(0, testing::AllOf(_, _, _, _, _, _, _, _, _,
1243
+ testing::AllOf(_, _, _, _, _, _, _, _, _, _)));
1244
+ }
1245
+
1246
+ TEST(AnyOfTest, HugeMatcher) {
1247
+ // Verify that using AnyOf with many arguments doesn't cause
1248
+ // the compiler to exceed template instantiation depth limit.
1249
+ EXPECT_THAT(0, testing::AnyOf(_, _, _, _, _, _, _, _, _,
1250
+ testing::AnyOf(_, _, _, _, _, _, _, _, _, _)));
1251
+ }
1252
+
1253
+ namespace adl_test {
1254
+
1255
+ // Verifies that the implementation of ::testing::AllOf and ::testing::AnyOf
1256
+ // don't issue unqualified recursive calls. If they do, the argument dependent
1257
+ // name lookup will cause AllOf/AnyOf in the 'adl_test' namespace to be found
1258
+ // as a candidate and the compilation will break due to an ambiguous overload.
1259
+
1260
+ // The matcher must be in the same namespace as AllOf/AnyOf to make argument
1261
+ // dependent lookup find those.
1262
+ MATCHER(M, "") { return true; }
1263
+
1264
+ template <typename T1, typename T2>
1265
+ bool AllOf(const T1& t1, const T2& t2) { return true; }
1266
+
1267
+ TEST(AllOfTest, DoesNotCallAllOfUnqualified) {
1268
+ EXPECT_THAT(42, testing::AllOf(
1269
+ M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));
1270
+ }
1271
+
1272
+ template <typename T1, typename T2> bool
1273
+ AnyOf(const T1& t1, const T2& t2) { return true; }
1274
+
1275
+ TEST(AnyOfTest, DoesNotCallAnyOfUnqualified) {
1276
+ EXPECT_THAT(42, testing::AnyOf(
1277
+ M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));
1278
+ }
1279
+
1280
+ } // namespace adl_test
1281
+
1282
+ #ifdef _MSC_VER
1283
+ # pragma warning(pop)
1284
+ #endif
1285
+
1286
+ } // namespace