rn-leveldb 3.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (595) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/android/.project +34 -0
  4. package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
  5. package/android/CMakeLists.txt +69 -0
  6. package/android/build.gradle +125 -0
  7. package/android/cpp-adapter.cpp +19 -0
  8. package/android/gradle.properties +6 -0
  9. package/android/src/main/AndroidManifest.xml +4 -0
  10. package/android/src/main/java/com/reactnativeleveldb/LeveldbModule.java +57 -0
  11. package/android/src/main/java/com/reactnativeleveldb/LeveldbPackage.java +28 -0
  12. package/cpp/leveldb/.appveyor.yml +36 -0
  13. package/cpp/leveldb/.clang-format +18 -0
  14. package/cpp/leveldb/.travis.yml +88 -0
  15. package/cpp/leveldb/AUTHORS +12 -0
  16. package/cpp/leveldb/CMakeLists.txt +495 -0
  17. package/cpp/leveldb/CONTRIBUTING.md +36 -0
  18. package/cpp/leveldb/LICENSE +27 -0
  19. package/cpp/leveldb/NEWS +17 -0
  20. package/cpp/leveldb/README.md +231 -0
  21. package/cpp/leveldb/TODO +14 -0
  22. package/cpp/leveldb/benchmarks/db_bench.cc +990 -0
  23. package/cpp/leveldb/benchmarks/db_bench_sqlite3.cc +726 -0
  24. package/cpp/leveldb/benchmarks/db_bench_tree_db.cc +531 -0
  25. package/cpp/leveldb/cmake/leveldbConfig.cmake.in +9 -0
  26. package/cpp/leveldb/db/autocompact_test.cc +115 -0
  27. package/cpp/leveldb/db/builder.cc +82 -0
  28. package/cpp/leveldb/db/builder.h +30 -0
  29. package/cpp/leveldb/db/c.cc +562 -0
  30. package/cpp/leveldb/db/c_test.c +384 -0
  31. package/cpp/leveldb/db/corruption_test.cc +367 -0
  32. package/cpp/leveldb/db/db_impl.cc +1554 -0
  33. package/cpp/leveldb/db/db_impl.h +217 -0
  34. package/cpp/leveldb/db/db_iter.cc +318 -0
  35. package/cpp/leveldb/db/db_iter.h +26 -0
  36. package/cpp/leveldb/db/db_test.cc +2305 -0
  37. package/cpp/leveldb/db/dbformat.cc +136 -0
  38. package/cpp/leveldb/db/dbformat.h +224 -0
  39. package/cpp/leveldb/db/dbformat_test.cc +133 -0
  40. package/cpp/leveldb/db/dumpfile.cc +232 -0
  41. package/cpp/leveldb/db/fault_injection_test.cc +555 -0
  42. package/cpp/leveldb/db/filename.cc +141 -0
  43. package/cpp/leveldb/db/filename.h +83 -0
  44. package/cpp/leveldb/db/filename_test.cc +132 -0
  45. package/cpp/leveldb/db/leveldbutil.cc +64 -0
  46. package/cpp/leveldb/db/log_format.h +35 -0
  47. package/cpp/leveldb/db/log_reader.cc +274 -0
  48. package/cpp/leveldb/db/log_reader.h +112 -0
  49. package/cpp/leveldb/db/log_test.cc +563 -0
  50. package/cpp/leveldb/db/log_writer.cc +111 -0
  51. package/cpp/leveldb/db/log_writer.h +54 -0
  52. package/cpp/leveldb/db/memtable.cc +137 -0
  53. package/cpp/leveldb/db/memtable.h +87 -0
  54. package/cpp/leveldb/db/recovery_test.cc +339 -0
  55. package/cpp/leveldb/db/repair.cc +451 -0
  56. package/cpp/leveldb/db/skiplist.h +382 -0
  57. package/cpp/leveldb/db/skiplist_test.cc +373 -0
  58. package/cpp/leveldb/db/snapshot.h +95 -0
  59. package/cpp/leveldb/db/table_cache.cc +120 -0
  60. package/cpp/leveldb/db/table_cache.h +57 -0
  61. package/cpp/leveldb/db/version_edit.cc +257 -0
  62. package/cpp/leveldb/db/version_edit.h +106 -0
  63. package/cpp/leveldb/db/version_edit_test.cc +46 -0
  64. package/cpp/leveldb/db/version_set.cc +1562 -0
  65. package/cpp/leveldb/db/version_set.h +393 -0
  66. package/cpp/leveldb/db/version_set_test.cc +336 -0
  67. package/cpp/leveldb/db/write_batch.cc +150 -0
  68. package/cpp/leveldb/db/write_batch_internal.h +45 -0
  69. package/cpp/leveldb/db/write_batch_test.cc +137 -0
  70. package/cpp/leveldb/doc/benchmark.html +459 -0
  71. package/cpp/leveldb/doc/impl.md +172 -0
  72. package/cpp/leveldb/doc/index.md +523 -0
  73. package/cpp/leveldb/doc/log_format.md +75 -0
  74. package/cpp/leveldb/doc/table_format.md +107 -0
  75. package/cpp/leveldb/helpers/memenv/memenv.cc +390 -0
  76. package/cpp/leveldb/helpers/memenv/memenv.h +22 -0
  77. package/cpp/leveldb/helpers/memenv/memenv_test.cc +264 -0
  78. package/cpp/leveldb/include/leveldb/c.h +270 -0
  79. package/cpp/leveldb/include/leveldb/cache.h +111 -0
  80. package/cpp/leveldb/include/leveldb/comparator.h +64 -0
  81. package/cpp/leveldb/include/leveldb/db.h +167 -0
  82. package/cpp/leveldb/include/leveldb/dumpfile.h +28 -0
  83. package/cpp/leveldb/include/leveldb/env.h +417 -0
  84. package/cpp/leveldb/include/leveldb/export.h +33 -0
  85. package/cpp/leveldb/include/leveldb/filter_policy.h +72 -0
  86. package/cpp/leveldb/include/leveldb/iterator.h +112 -0
  87. package/cpp/leveldb/include/leveldb/options.h +187 -0
  88. package/cpp/leveldb/include/leveldb/slice.h +114 -0
  89. package/cpp/leveldb/include/leveldb/status.h +122 -0
  90. package/cpp/leveldb/include/leveldb/table.h +84 -0
  91. package/cpp/leveldb/include/leveldb/table_builder.h +93 -0
  92. package/cpp/leveldb/include/leveldb/write_batch.h +83 -0
  93. package/cpp/leveldb/issues/issue178_test.cc +90 -0
  94. package/cpp/leveldb/issues/issue200_test.cc +59 -0
  95. package/cpp/leveldb/issues/issue320_test.cc +131 -0
  96. package/cpp/leveldb/port/README.md +10 -0
  97. package/cpp/leveldb/port/port.h +19 -0
  98. package/cpp/leveldb/port/port_config.h.in +33 -0
  99. package/cpp/leveldb/port/port_example.h +100 -0
  100. package/cpp/leveldb/port/port_stdcxx.h +151 -0
  101. package/cpp/leveldb/port/thread_annotations.h +108 -0
  102. package/cpp/leveldb/table/block.cc +267 -0
  103. package/cpp/leveldb/table/block.h +44 -0
  104. package/cpp/leveldb/table/block_builder.cc +107 -0
  105. package/cpp/leveldb/table/block_builder.h +54 -0
  106. package/cpp/leveldb/table/filter_block.cc +106 -0
  107. package/cpp/leveldb/table/filter_block.h +68 -0
  108. package/cpp/leveldb/table/filter_block_test.cc +127 -0
  109. package/cpp/leveldb/table/format.cc +141 -0
  110. package/cpp/leveldb/table/format.h +99 -0
  111. package/cpp/leveldb/table/iterator.cc +76 -0
  112. package/cpp/leveldb/table/iterator_wrapper.h +92 -0
  113. package/cpp/leveldb/table/merger.cc +191 -0
  114. package/cpp/leveldb/table/merger.h +26 -0
  115. package/cpp/leveldb/table/table.cc +271 -0
  116. package/cpp/leveldb/table/table_builder.cc +265 -0
  117. package/cpp/leveldb/table/table_test.cc +834 -0
  118. package/cpp/leveldb/table/two_level_iterator.cc +171 -0
  119. package/cpp/leveldb/table/two_level_iterator.h +31 -0
  120. package/cpp/leveldb/third_party/benchmark/.clang-format +5 -0
  121. package/cpp/leveldb/third_party/benchmark/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  122. package/cpp/leveldb/third_party/benchmark/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  123. package/cpp/leveldb/third_party/benchmark/.github/workflows/build-and-test.yml +38 -0
  124. package/cpp/leveldb/third_party/benchmark/.github/workflows/pylint.yml +26 -0
  125. package/cpp/leveldb/third_party/benchmark/.github/workflows/test_bindings.yml +24 -0
  126. package/cpp/leveldb/third_party/benchmark/.travis-libcxx-setup.sh +28 -0
  127. package/cpp/leveldb/third_party/benchmark/.travis.yml +231 -0
  128. package/cpp/leveldb/third_party/benchmark/.ycm_extra_conf.py +115 -0
  129. package/cpp/leveldb/third_party/benchmark/AUTHORS +58 -0
  130. package/cpp/leveldb/third_party/benchmark/BUILD.bazel +44 -0
  131. package/cpp/leveldb/third_party/benchmark/CMakeLists.txt +287 -0
  132. package/cpp/leveldb/third_party/benchmark/CONTRIBUTING.md +58 -0
  133. package/cpp/leveldb/third_party/benchmark/CONTRIBUTORS +83 -0
  134. package/cpp/leveldb/third_party/benchmark/LICENSE +202 -0
  135. package/cpp/leveldb/third_party/benchmark/README.md +1323 -0
  136. package/cpp/leveldb/third_party/benchmark/WORKSPACE +51 -0
  137. package/cpp/leveldb/third_party/benchmark/_config.yml +1 -0
  138. package/cpp/leveldb/third_party/benchmark/appveyor.yml +50 -0
  139. package/cpp/leveldb/third_party/benchmark/bindings/python/BUILD +3 -0
  140. package/cpp/leveldb/third_party/benchmark/bindings/python/build_defs.bzl +25 -0
  141. package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/BUILD +38 -0
  142. package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/__init__.py +156 -0
  143. package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/benchmark.cc +180 -0
  144. package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/example.py +136 -0
  145. package/cpp/leveldb/third_party/benchmark/bindings/python/pybind11.BUILD +20 -0
  146. package/cpp/leveldb/third_party/benchmark/bindings/python/python_headers.BUILD +6 -0
  147. package/cpp/leveldb/third_party/benchmark/bindings/python/requirements.txt +2 -0
  148. package/cpp/leveldb/third_party/benchmark/cmake/AddCXXCompilerFlag.cmake +74 -0
  149. package/cpp/leveldb/third_party/benchmark/cmake/CXXFeatureCheck.cmake +69 -0
  150. package/cpp/leveldb/third_party/benchmark/cmake/Config.cmake.in +1 -0
  151. package/cpp/leveldb/third_party/benchmark/cmake/GetGitVersion.cmake +54 -0
  152. package/cpp/leveldb/third_party/benchmark/cmake/GoogleTest.cmake +41 -0
  153. package/cpp/leveldb/third_party/benchmark/cmake/GoogleTest.cmake.in +58 -0
  154. package/cpp/leveldb/third_party/benchmark/cmake/benchmark.pc.in +12 -0
  155. package/cpp/leveldb/third_party/benchmark/cmake/gnu_posix_regex.cpp +12 -0
  156. package/cpp/leveldb/third_party/benchmark/cmake/llvm-toolchain.cmake +8 -0
  157. package/cpp/leveldb/third_party/benchmark/cmake/posix_regex.cpp +14 -0
  158. package/cpp/leveldb/third_party/benchmark/cmake/split_list.cmake +3 -0
  159. package/cpp/leveldb/third_party/benchmark/cmake/std_regex.cpp +10 -0
  160. package/cpp/leveldb/third_party/benchmark/cmake/steady_clock.cpp +7 -0
  161. package/cpp/leveldb/third_party/benchmark/cmake/thread_safety_attributes.cpp +4 -0
  162. package/cpp/leveldb/third_party/benchmark/conan/CMakeLists.txt +7 -0
  163. package/cpp/leveldb/third_party/benchmark/conan/test_package/CMakeLists.txt +10 -0
  164. package/cpp/leveldb/third_party/benchmark/conan/test_package/conanfile.py +19 -0
  165. package/cpp/leveldb/third_party/benchmark/conan/test_package/test_package.cpp +18 -0
  166. package/cpp/leveldb/third_party/benchmark/conanfile.py +79 -0
  167. package/cpp/leveldb/third_party/benchmark/dependencies.md +18 -0
  168. package/cpp/leveldb/third_party/benchmark/docs/AssemblyTests.md +147 -0
  169. package/cpp/leveldb/third_party/benchmark/docs/_config.yml +1 -0
  170. package/cpp/leveldb/third_party/benchmark/docs/releasing.md +16 -0
  171. package/cpp/leveldb/third_party/benchmark/docs/tools.md +203 -0
  172. package/cpp/leveldb/third_party/benchmark/include/benchmark/benchmark.h +1604 -0
  173. package/cpp/leveldb/third_party/benchmark/requirements.txt +2 -0
  174. package/cpp/leveldb/third_party/benchmark/setup.py +140 -0
  175. package/cpp/leveldb/third_party/benchmark/src/CMakeLists.txt +114 -0
  176. package/cpp/leveldb/third_party/benchmark/src/arraysize.h +33 -0
  177. package/cpp/leveldb/third_party/benchmark/src/benchmark.cc +499 -0
  178. package/cpp/leveldb/third_party/benchmark/src/benchmark_api_internal.cc +15 -0
  179. package/cpp/leveldb/third_party/benchmark/src/benchmark_api_internal.h +53 -0
  180. package/cpp/leveldb/third_party/benchmark/src/benchmark_main.cc +17 -0
  181. package/cpp/leveldb/third_party/benchmark/src/benchmark_name.cc +58 -0
  182. package/cpp/leveldb/third_party/benchmark/src/benchmark_register.cc +515 -0
  183. package/cpp/leveldb/third_party/benchmark/src/benchmark_register.h +108 -0
  184. package/cpp/leveldb/third_party/benchmark/src/benchmark_runner.cc +362 -0
  185. package/cpp/leveldb/third_party/benchmark/src/benchmark_runner.h +51 -0
  186. package/cpp/leveldb/third_party/benchmark/src/check.h +82 -0
  187. package/cpp/leveldb/third_party/benchmark/src/colorprint.cc +188 -0
  188. package/cpp/leveldb/third_party/benchmark/src/colorprint.h +33 -0
  189. package/cpp/leveldb/third_party/benchmark/src/commandlineflags.cc +228 -0
  190. package/cpp/leveldb/third_party/benchmark/src/commandlineflags.h +103 -0
  191. package/cpp/leveldb/third_party/benchmark/src/complexity.cc +238 -0
  192. package/cpp/leveldb/third_party/benchmark/src/complexity.h +55 -0
  193. package/cpp/leveldb/third_party/benchmark/src/console_reporter.cc +177 -0
  194. package/cpp/leveldb/third_party/benchmark/src/counter.cc +80 -0
  195. package/cpp/leveldb/third_party/benchmark/src/counter.h +32 -0
  196. package/cpp/leveldb/third_party/benchmark/src/csv_reporter.cc +154 -0
  197. package/cpp/leveldb/third_party/benchmark/src/cycleclock.h +211 -0
  198. package/cpp/leveldb/third_party/benchmark/src/internal_macros.h +102 -0
  199. package/cpp/leveldb/third_party/benchmark/src/json_reporter.cc +255 -0
  200. package/cpp/leveldb/third_party/benchmark/src/log.h +74 -0
  201. package/cpp/leveldb/third_party/benchmark/src/mutex.h +155 -0
  202. package/cpp/leveldb/third_party/benchmark/src/re.h +158 -0
  203. package/cpp/leveldb/third_party/benchmark/src/reporter.cc +105 -0
  204. package/cpp/leveldb/third_party/benchmark/src/sleep.cc +67 -0
  205. package/cpp/leveldb/third_party/benchmark/src/sleep.h +15 -0
  206. package/cpp/leveldb/third_party/benchmark/src/statistics.cc +193 -0
  207. package/cpp/leveldb/third_party/benchmark/src/statistics.h +37 -0
  208. package/cpp/leveldb/third_party/benchmark/src/string_util.cc +255 -0
  209. package/cpp/leveldb/third_party/benchmark/src/string_util.h +59 -0
  210. package/cpp/leveldb/third_party/benchmark/src/sysinfo.cc +716 -0
  211. package/cpp/leveldb/third_party/benchmark/src/thread_manager.h +64 -0
  212. package/cpp/leveldb/third_party/benchmark/src/thread_timer.h +86 -0
  213. package/cpp/leveldb/third_party/benchmark/src/timers.cc +245 -0
  214. package/cpp/leveldb/third_party/benchmark/src/timers.h +48 -0
  215. package/cpp/leveldb/third_party/benchmark/test/AssemblyTests.cmake +46 -0
  216. package/cpp/leveldb/third_party/benchmark/test/BUILD +73 -0
  217. package/cpp/leveldb/third_party/benchmark/test/CMakeLists.txt +263 -0
  218. package/cpp/leveldb/third_party/benchmark/test/args_product_test.cc +77 -0
  219. package/cpp/leveldb/third_party/benchmark/test/basic_test.cc +136 -0
  220. package/cpp/leveldb/third_party/benchmark/test/benchmark_gtest.cc +134 -0
  221. package/cpp/leveldb/third_party/benchmark/test/benchmark_name_gtest.cc +74 -0
  222. package/cpp/leveldb/third_party/benchmark/test/benchmark_test.cc +245 -0
  223. package/cpp/leveldb/third_party/benchmark/test/clobber_memory_assembly_test.cc +64 -0
  224. package/cpp/leveldb/third_party/benchmark/test/commandlineflags_gtest.cc +201 -0
  225. package/cpp/leveldb/third_party/benchmark/test/complexity_test.cc +213 -0
  226. package/cpp/leveldb/third_party/benchmark/test/cxx03_test.cc +63 -0
  227. package/cpp/leveldb/third_party/benchmark/test/diagnostics_test.cc +80 -0
  228. package/cpp/leveldb/third_party/benchmark/test/display_aggregates_only_test.cc +43 -0
  229. package/cpp/leveldb/third_party/benchmark/test/donotoptimize_assembly_test.cc +163 -0
  230. package/cpp/leveldb/third_party/benchmark/test/donotoptimize_test.cc +52 -0
  231. package/cpp/leveldb/third_party/benchmark/test/filter_test.cc +104 -0
  232. package/cpp/leveldb/third_party/benchmark/test/fixture_test.cc +51 -0
  233. package/cpp/leveldb/third_party/benchmark/test/internal_threading_test.cc +184 -0
  234. package/cpp/leveldb/third_party/benchmark/test/link_main_test.cc +8 -0
  235. package/cpp/leveldb/third_party/benchmark/test/map_test.cc +57 -0
  236. package/cpp/leveldb/third_party/benchmark/test/memory_manager_test.cc +44 -0
  237. package/cpp/leveldb/third_party/benchmark/test/multiple_ranges_test.cc +96 -0
  238. package/cpp/leveldb/third_party/benchmark/test/options_test.cc +75 -0
  239. package/cpp/leveldb/third_party/benchmark/test/output_test.h +213 -0
  240. package/cpp/leveldb/third_party/benchmark/test/output_test_helper.cc +515 -0
  241. package/cpp/leveldb/third_party/benchmark/test/register_benchmark_test.cc +184 -0
  242. package/cpp/leveldb/third_party/benchmark/test/report_aggregates_only_test.cc +39 -0
  243. package/cpp/leveldb/third_party/benchmark/test/reporter_output_test.cc +747 -0
  244. package/cpp/leveldb/third_party/benchmark/test/skip_with_error_test.cc +195 -0
  245. package/cpp/leveldb/third_party/benchmark/test/state_assembly_test.cc +68 -0
  246. package/cpp/leveldb/third_party/benchmark/test/statistics_gtest.cc +28 -0
  247. package/cpp/leveldb/third_party/benchmark/test/string_util_gtest.cc +153 -0
  248. package/cpp/leveldb/third_party/benchmark/test/templated_fixture_test.cc +28 -0
  249. package/cpp/leveldb/third_party/benchmark/test/user_counters_tabular_test.cc +285 -0
  250. package/cpp/leveldb/third_party/benchmark/test/user_counters_test.cc +531 -0
  251. package/cpp/leveldb/third_party/benchmark/test/user_counters_thousands_test.cc +173 -0
  252. package/cpp/leveldb/third_party/benchmark/tools/BUILD.bazel +19 -0
  253. package/cpp/leveldb/third_party/benchmark/tools/compare.py +429 -0
  254. package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test1_run1.json +119 -0
  255. package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test1_run2.json +119 -0
  256. package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test2_run.json +81 -0
  257. package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test3_run0.json +65 -0
  258. package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test3_run1.json +65 -0
  259. package/cpp/leveldb/third_party/benchmark/tools/gbench/__init__.py +8 -0
  260. package/cpp/leveldb/third_party/benchmark/tools/gbench/report.py +903 -0
  261. package/cpp/leveldb/third_party/benchmark/tools/gbench/util.py +163 -0
  262. package/cpp/leveldb/third_party/benchmark/tools/requirements.txt +1 -0
  263. package/cpp/leveldb/third_party/benchmark/tools/strip_asm.py +151 -0
  264. package/cpp/leveldb/third_party/googletest/.clang-format +4 -0
  265. package/cpp/leveldb/third_party/googletest/.travis.yml +73 -0
  266. package/cpp/leveldb/third_party/googletest/BUILD.bazel +179 -0
  267. package/cpp/leveldb/third_party/googletest/CMakeLists.txt +36 -0
  268. package/cpp/leveldb/third_party/googletest/CONTRIBUTING.md +142 -0
  269. package/cpp/leveldb/third_party/googletest/LICENSE +28 -0
  270. package/cpp/leveldb/third_party/googletest/README.md +132 -0
  271. package/cpp/leveldb/third_party/googletest/WORKSPACE +23 -0
  272. package/cpp/leveldb/third_party/googletest/appveyor.yml +154 -0
  273. package/cpp/leveldb/third_party/googletest/ci/build-linux-bazel.sh +37 -0
  274. package/cpp/leveldb/third_party/googletest/ci/build-platformio.sh +2 -0
  275. package/cpp/leveldb/third_party/googletest/ci/env-linux.sh +41 -0
  276. package/cpp/leveldb/third_party/googletest/ci/env-osx.sh +47 -0
  277. package/cpp/leveldb/third_party/googletest/ci/get-nprocessors.sh +48 -0
  278. package/cpp/leveldb/third_party/googletest/ci/install-linux.sh +49 -0
  279. package/cpp/leveldb/third_party/googletest/ci/install-osx.sh +40 -0
  280. package/cpp/leveldb/third_party/googletest/ci/install-platformio.sh +5 -0
  281. package/cpp/leveldb/third_party/googletest/ci/log-config.sh +51 -0
  282. package/cpp/leveldb/third_party/googletest/ci/travis.sh +44 -0
  283. package/cpp/leveldb/third_party/googletest/googlemock/CMakeLists.txt +233 -0
  284. package/cpp/leveldb/third_party/googletest/googlemock/CONTRIBUTORS +40 -0
  285. package/cpp/leveldb/third_party/googletest/googlemock/LICENSE +28 -0
  286. package/cpp/leveldb/third_party/googletest/googlemock/README.md +44 -0
  287. package/cpp/leveldb/third_party/googletest/googlemock/cmake/gmock.pc.in +10 -0
  288. package/cpp/leveldb/third_party/googletest/googlemock/cmake/gmock_main.pc.in +10 -0
  289. package/cpp/leveldb/third_party/googletest/googlemock/docs/cheat_sheet.md +770 -0
  290. package/cpp/leveldb/third_party/googletest/googlemock/docs/cook_book.md +4270 -0
  291. package/cpp/leveldb/third_party/googletest/googlemock/docs/for_dummies.md +700 -0
  292. package/cpp/leveldb/third_party/googletest/googlemock/docs/gmock_faq.md +396 -0
  293. package/cpp/leveldb/third_party/googletest/googlemock/docs/pump_manual.md +187 -0
  294. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-actions.h +1193 -0
  295. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-cardinalities.h +157 -0
  296. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-function-mocker.h +276 -0
  297. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h +1884 -0
  298. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h.pump +627 -0
  299. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h +752 -0
  300. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +227 -0
  301. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-matchers.h +1097 -0
  302. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-matchers.h.pump +346 -0
  303. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-matchers.h +4591 -0
  304. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-more-actions.h +162 -0
  305. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-more-matchers.h +92 -0
  306. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-nice-strict.h +215 -0
  307. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-spec-builders.h +1985 -0
  308. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock.h +101 -0
  309. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/README.md +16 -0
  310. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +10 -0
  311. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +12 -0
  312. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-matchers.h +36 -0
  313. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-port.h +39 -0
  314. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h +472 -0
  315. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-port.h +87 -0
  316. package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-pp.h +271 -0
  317. package/cpp/leveldb/third_party/googletest/googlemock/scripts/README.md +5 -0
  318. package/cpp/leveldb/third_party/googletest/googlemock/scripts/fuse_gmock_files.py +240 -0
  319. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/LICENSE +203 -0
  320. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/README +34 -0
  321. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/README.cppclean +115 -0
  322. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/__init__.py +0 -0
  323. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/ast.py +1761 -0
  324. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py +248 -0
  325. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class_test.py +540 -0
  326. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/keywords.py +56 -0
  327. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/tokenize.py +284 -0
  328. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/utils.py +37 -0
  329. package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/gmock_gen.py +30 -0
  330. package/cpp/leveldb/third_party/googletest/googlemock/scripts/pump.py +856 -0
  331. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-all.cc +46 -0
  332. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-cardinalities.cc +155 -0
  333. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-internal-utils.cc +200 -0
  334. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-matchers.cc +462 -0
  335. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-spec-builders.cc +892 -0
  336. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock.cc +213 -0
  337. package/cpp/leveldb/third_party/googletest/googlemock/src/gmock_main.cc +72 -0
  338. package/cpp/leveldb/third_party/googletest/googlemock/test/BUILD.bazel +110 -0
  339. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-actions_test.cc +1507 -0
  340. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-cardinalities_test.cc +429 -0
  341. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_nc.cc +16 -0
  342. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_nc_test.py +43 -0
  343. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc +696 -0
  344. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-actions_test.cc +1064 -0
  345. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-function-mockers_test.cc +659 -0
  346. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-matchers_test.cc +1323 -0
  347. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-internal-utils_test.cc +732 -0
  348. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-matchers_test.cc +6913 -0
  349. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-more-actions_test.cc +698 -0
  350. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-nice-strict_test.cc +500 -0
  351. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-port_test.cc +42 -0
  352. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-pp-string_test.cc +206 -0
  353. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-pp_test.cc +83 -0
  354. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-spec-builders_test.cc +2775 -0
  355. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_all_test.cc +49 -0
  356. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_ex_test.cc +80 -0
  357. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_leak_test.py +104 -0
  358. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_leak_test_.cc +99 -0
  359. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link2_test.cc +39 -0
  360. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link_test.cc +39 -0
  361. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link_test.h +690 -0
  362. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test.py +183 -0
  363. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test_.cc +309 -0
  364. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test_golden.txt +317 -0
  365. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_stress_test.cc +240 -0
  366. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_test.cc +181 -0
  367. package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_test_utils.py +108 -0
  368. package/cpp/leveldb/third_party/googletest/googlemock/test/pump_test.py +182 -0
  369. package/cpp/leveldb/third_party/googletest/googletest/CMakeLists.txt +329 -0
  370. package/cpp/leveldb/third_party/googletest/googletest/CONTRIBUTORS +38 -0
  371. package/cpp/leveldb/third_party/googletest/googletest/LICENSE +28 -0
  372. package/cpp/leveldb/third_party/googletest/googletest/README.md +244 -0
  373. package/cpp/leveldb/third_party/googletest/googletest/cmake/Config.cmake.in +9 -0
  374. package/cpp/leveldb/third_party/googletest/googletest/cmake/gtest.pc.in +9 -0
  375. package/cpp/leveldb/third_party/googletest/googletest/cmake/gtest_main.pc.in +10 -0
  376. package/cpp/leveldb/third_party/googletest/googletest/cmake/internal_utils.cmake +358 -0
  377. package/cpp/leveldb/third_party/googletest/googletest/cmake/libgtest.la.in +21 -0
  378. package/cpp/leveldb/third_party/googletest/googletest/docs/advanced.md +2567 -0
  379. package/cpp/leveldb/third_party/googletest/googletest/docs/faq.md +753 -0
  380. package/cpp/leveldb/third_party/googletest/googletest/docs/pkgconfig.md +219 -0
  381. package/cpp/leveldb/third_party/googletest/googletest/docs/primer.md +579 -0
  382. package/cpp/leveldb/third_party/googletest/googletest/docs/samples.md +22 -0
  383. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-death-test.h +343 -0
  384. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-matchers.h +750 -0
  385. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-message.h +219 -0
  386. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-param-test.h +514 -0
  387. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-printers.h +928 -0
  388. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-spi.h +238 -0
  389. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-test-part.h +184 -0
  390. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-typed-test.h +337 -0
  391. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest.h +2477 -0
  392. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest_pred_impl.h +359 -0
  393. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest_prod.h +61 -0
  394. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/README.md +56 -0
  395. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest-port.h +37 -0
  396. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
  397. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest.h +37 -0
  398. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h +304 -0
  399. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-filepath.h +211 -0
  400. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h +1411 -0
  401. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-param-util.h +880 -0
  402. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-port-arch.h +111 -0
  403. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-port.h +2227 -0
  404. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-string.h +171 -0
  405. package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-type-util.h +183 -0
  406. package/cpp/leveldb/third_party/googletest/googletest/samples/prime_tables.h +126 -0
  407. package/cpp/leveldb/third_party/googletest/googletest/samples/sample1.cc +66 -0
  408. package/cpp/leveldb/third_party/googletest/googletest/samples/sample1.h +41 -0
  409. package/cpp/leveldb/third_party/googletest/googletest/samples/sample10_unittest.cc +139 -0
  410. package/cpp/leveldb/third_party/googletest/googletest/samples/sample1_unittest.cc +151 -0
  411. package/cpp/leveldb/third_party/googletest/googletest/samples/sample2.cc +54 -0
  412. package/cpp/leveldb/third_party/googletest/googletest/samples/sample2.h +81 -0
  413. package/cpp/leveldb/third_party/googletest/googletest/samples/sample2_unittest.cc +107 -0
  414. package/cpp/leveldb/third_party/googletest/googletest/samples/sample3-inl.h +172 -0
  415. package/cpp/leveldb/third_party/googletest/googletest/samples/sample3_unittest.cc +149 -0
  416. package/cpp/leveldb/third_party/googletest/googletest/samples/sample4.cc +54 -0
  417. package/cpp/leveldb/third_party/googletest/googletest/samples/sample4.h +53 -0
  418. package/cpp/leveldb/third_party/googletest/googletest/samples/sample4_unittest.cc +53 -0
  419. package/cpp/leveldb/third_party/googletest/googletest/samples/sample5_unittest.cc +196 -0
  420. package/cpp/leveldb/third_party/googletest/googletest/samples/sample6_unittest.cc +224 -0
  421. package/cpp/leveldb/third_party/googletest/googletest/samples/sample7_unittest.cc +117 -0
  422. package/cpp/leveldb/third_party/googletest/googletest/samples/sample8_unittest.cc +154 -0
  423. package/cpp/leveldb/third_party/googletest/googletest/samples/sample9_unittest.cc +156 -0
  424. package/cpp/leveldb/third_party/googletest/googletest/scripts/README.md +5 -0
  425. package/cpp/leveldb/third_party/googletest/googletest/scripts/common.py +83 -0
  426. package/cpp/leveldb/third_party/googletest/googletest/scripts/fuse_gtest_files.py +253 -0
  427. package/cpp/leveldb/third_party/googletest/googletest/scripts/gen_gtest_pred_impl.py +734 -0
  428. package/cpp/leveldb/third_party/googletest/googletest/scripts/gtest-config.in +274 -0
  429. package/cpp/leveldb/third_party/googletest/googletest/scripts/release_docs.py +158 -0
  430. package/cpp/leveldb/third_party/googletest/googletest/scripts/run_with_path.py +32 -0
  431. package/cpp/leveldb/third_party/googletest/googletest/scripts/upload.py +1402 -0
  432. package/cpp/leveldb/third_party/googletest/googletest/scripts/upload_gtest.py +78 -0
  433. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-all.cc +48 -0
  434. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-death-test.cc +1653 -0
  435. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-filepath.cc +382 -0
  436. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-internal-inl.h +1211 -0
  437. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-matchers.cc +97 -0
  438. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-port.cc +1399 -0
  439. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-printers.cc +442 -0
  440. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-test-part.cc +108 -0
  441. package/cpp/leveldb/third_party/googletest/googletest/src/gtest-typed-test.cc +118 -0
  442. package/cpp/leveldb/third_party/googletest/googletest/src/gtest.cc +6180 -0
  443. package/cpp/leveldb/third_party/googletest/googletest/src/gtest_main.cc +54 -0
  444. package/cpp/leveldb/third_party/googletest/googletest/test/BUILD.bazel +529 -0
  445. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py +208 -0
  446. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-break-on-failure-unittest_.cc +86 -0
  447. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-catch-exceptions-test.py +236 -0
  448. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-catch-exceptions-test_.cc +293 -0
  449. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-color-test.py +127 -0
  450. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-color-test_.cc +62 -0
  451. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-death-test-test.cc +1516 -0
  452. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-death-test_ex_test.cc +92 -0
  453. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-env-var-test.py +117 -0
  454. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-env-var-test_.cc +122 -0
  455. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filepath-test.cc +649 -0
  456. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filter-unittest.py +639 -0
  457. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filter-unittest_.cc +137 -0
  458. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-json-outfiles-test.py +191 -0
  459. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-json-output-unittest.py +778 -0
  460. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-list-tests-unittest.py +205 -0
  461. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-list-tests-unittest_.cc +156 -0
  462. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-listener-test.cc +518 -0
  463. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-message-test.cc +158 -0
  464. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-options-test.cc +216 -0
  465. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test-golden-lin.txt +1137 -0
  466. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test.py +346 -0
  467. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test_.cc +1149 -0
  468. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test.py +63 -0
  469. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test_.cc +50 -0
  470. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test.py +62 -0
  471. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test_.cc +55 -0
  472. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-test.cc +1086 -0
  473. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-test.h +51 -0
  474. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test2-test.cc +61 -0
  475. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-port-test.cc +1272 -0
  476. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-printers-test.cc +1619 -0
  477. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-shuffle-test.py +323 -0
  478. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-shuffle-test_.cc +101 -0
  479. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-test-part-test.cc +230 -0
  480. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-test2_test.cc +61 -0
  481. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-throw-on-failure-test.py +168 -0
  482. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-throw-on-failure-test_.cc +71 -0
  483. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-uninitialized-test.py +67 -0
  484. package/cpp/leveldb/third_party/googletest/googletest/test/googletest-uninitialized-test_.cc +42 -0
  485. package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test2_test.cc +44 -0
  486. package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test_test.cc +462 -0
  487. package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test_test.h +65 -0
  488. package/cpp/leveldb/third_party/googletest/googletest/test/gtest-unittest-api_test.cc +341 -0
  489. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_all_test.cc +46 -0
  490. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_assert_by_exception_test.cc +116 -0
  491. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_environment_test.cc +188 -0
  492. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_help_test.py +170 -0
  493. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_help_test_.cc +45 -0
  494. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_json_test_utils.py +60 -0
  495. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_list_output_unittest.py +141 -0
  496. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_list_output_unittest_.cc +51 -0
  497. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_main_unittest.cc +44 -0
  498. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_no_test_unittest.cc +54 -0
  499. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_pred_impl_unittest.cc +2427 -0
  500. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_premature_exit_test.cc +126 -0
  501. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_prod_test.cc +56 -0
  502. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_repeat_test.cc +233 -0
  503. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_check_output_test.py +59 -0
  504. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_environment_check_output_test.py +54 -0
  505. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc +49 -0
  506. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_test.cc +55 -0
  507. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_sole_header_test.cc +56 -0
  508. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_stress_test.cc +248 -0
  509. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_test_macro_stack_footprint_test.cc +89 -0
  510. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_test_utils.py +314 -0
  511. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_testbridge_test.py +63 -0
  512. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_testbridge_test_.cc +43 -0
  513. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_throw_on_failure_ex_test.cc +90 -0
  514. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_unittest.cc +7496 -0
  515. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfile1_test_.cc +43 -0
  516. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfile2_test_.cc +43 -0
  517. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfiles_test.py +135 -0
  518. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_output_unittest.py +389 -0
  519. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_output_unittest_.cc +188 -0
  520. package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_test_utils.py +196 -0
  521. package/cpp/leveldb/third_party/googletest/googletest/test/production.cc +35 -0
  522. package/cpp/leveldb/third_party/googletest/googletest/test/production.h +54 -0
  523. package/cpp/leveldb/third_party/googletest/library.json +66 -0
  524. package/cpp/leveldb/third_party/googletest/platformio.ini +47 -0
  525. package/cpp/leveldb/util/arena.cc +66 -0
  526. package/cpp/leveldb/util/arena.h +71 -0
  527. package/cpp/leveldb/util/arena_test.cc +66 -0
  528. package/cpp/leveldb/util/bloom.cc +92 -0
  529. package/cpp/leveldb/util/bloom_test.cc +159 -0
  530. package/cpp/leveldb/util/cache.cc +401 -0
  531. package/cpp/leveldb/util/cache_test.cc +229 -0
  532. package/cpp/leveldb/util/coding.cc +166 -0
  533. package/cpp/leveldb/util/coding.h +122 -0
  534. package/cpp/leveldb/util/coding_test.cc +198 -0
  535. package/cpp/leveldb/util/comparator.cc +75 -0
  536. package/cpp/leveldb/util/crc32c.cc +380 -0
  537. package/cpp/leveldb/util/crc32c.h +43 -0
  538. package/cpp/leveldb/util/crc32c_test.cc +61 -0
  539. package/cpp/leveldb/util/env.cc +108 -0
  540. package/cpp/leveldb/util/env_posix.cc +893 -0
  541. package/cpp/leveldb/util/env_posix_test.cc +353 -0
  542. package/cpp/leveldb/util/env_posix_test_helper.h +28 -0
  543. package/cpp/leveldb/util/env_test.cc +240 -0
  544. package/cpp/leveldb/util/env_windows.cc +796 -0
  545. package/cpp/leveldb/util/env_windows_test.cc +65 -0
  546. package/cpp/leveldb/util/env_windows_test_helper.h +25 -0
  547. package/cpp/leveldb/util/filter_policy.cc +11 -0
  548. package/cpp/leveldb/util/hash.cc +55 -0
  549. package/cpp/leveldb/util/hash.h +19 -0
  550. package/cpp/leveldb/util/hash_test.cc +46 -0
  551. package/cpp/leveldb/util/histogram.cc +272 -0
  552. package/cpp/leveldb/util/histogram.h +44 -0
  553. package/cpp/leveldb/util/logging.cc +82 -0
  554. package/cpp/leveldb/util/logging.h +44 -0
  555. package/cpp/leveldb/util/logging_test.cc +145 -0
  556. package/cpp/leveldb/util/mutexlock.h +39 -0
  557. package/cpp/leveldb/util/no_destructor.h +46 -0
  558. package/cpp/leveldb/util/no_destructor_test.cc +49 -0
  559. package/cpp/leveldb/util/options.cc +14 -0
  560. package/cpp/leveldb/util/posix_logger.h +130 -0
  561. package/cpp/leveldb/util/random.h +63 -0
  562. package/cpp/leveldb/util/status.cc +77 -0
  563. package/cpp/leveldb/util/status_test.cc +44 -0
  564. package/cpp/leveldb/util/testutil.cc +51 -0
  565. package/cpp/leveldb/util/testutil.h +82 -0
  566. package/cpp/leveldb/util/windows_logger.h +124 -0
  567. package/cpp/react-native-leveldb.cpp +694 -0
  568. package/cpp/react-native-leveldb.h +4 -0
  569. package/ios/Leveldb.h +9 -0
  570. package/ios/Leveldb.mm +35 -0
  571. package/ios/Leveldb.xcodeproj/project.pbxproj +288 -0
  572. package/lib/commonjs/fake.js +181 -0
  573. package/lib/commonjs/fake.js.map +1 -0
  574. package/lib/commonjs/fake.test.js +30 -0
  575. package/lib/commonjs/fake.test.js.map +1 -0
  576. package/lib/commonjs/index.js +172 -0
  577. package/lib/commonjs/index.js.map +1 -0
  578. package/lib/commonjs/package.json +1 -0
  579. package/lib/module/fake.js +171 -0
  580. package/lib/module/fake.js.map +1 -0
  581. package/lib/module/fake.test.js +30 -0
  582. package/lib/module/fake.test.js.map +1 -0
  583. package/lib/module/index.js +165 -0
  584. package/lib/module/index.js.map +1 -0
  585. package/lib/typescript/fake.d.ts +34 -0
  586. package/lib/typescript/fake.d.ts.map +1 -0
  587. package/lib/typescript/fake.test.d.ts +2 -0
  588. package/lib/typescript/fake.test.d.ts.map +1 -0
  589. package/lib/typescript/index.d.ts +72 -0
  590. package/lib/typescript/index.d.ts.map +1 -0
  591. package/package.json +157 -0
  592. package/rn-leveldb.podspec +30 -0
  593. package/src/fake.test.ts +37 -0
  594. package/src/fake.ts +203 -0
  595. package/src/index.ts +291 -0
@@ -0,0 +1,1516 @@
1
+ // Copyright 2005, 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
+ //
31
+ // Tests for death tests.
32
+
33
+ #include "gtest/gtest-death-test.h"
34
+
35
+ #include "gtest/gtest.h"
36
+ #include "gtest/internal/gtest-filepath.h"
37
+
38
+ using testing::internal::AlwaysFalse;
39
+ using testing::internal::AlwaysTrue;
40
+
41
+ #if GTEST_HAS_DEATH_TEST
42
+
43
+ # if GTEST_OS_WINDOWS
44
+ # include <fcntl.h> // For O_BINARY
45
+ # include <direct.h> // For chdir().
46
+ # include <io.h>
47
+ # else
48
+ # include <unistd.h>
49
+ # include <sys/wait.h> // For waitpid.
50
+ # endif // GTEST_OS_WINDOWS
51
+
52
+ # include <limits.h>
53
+ # include <signal.h>
54
+ # include <stdio.h>
55
+
56
+ # if GTEST_OS_LINUX
57
+ # include <sys/time.h>
58
+ # endif // GTEST_OS_LINUX
59
+
60
+ # include "gtest/gtest-spi.h"
61
+ # include "src/gtest-internal-inl.h"
62
+
63
+ namespace posix = ::testing::internal::posix;
64
+
65
+ using testing::ContainsRegex;
66
+ using testing::Matcher;
67
+ using testing::Message;
68
+ using testing::internal::DeathTest;
69
+ using testing::internal::DeathTestFactory;
70
+ using testing::internal::FilePath;
71
+ using testing::internal::GetLastErrnoDescription;
72
+ using testing::internal::GetUnitTestImpl;
73
+ using testing::internal::InDeathTestChild;
74
+ using testing::internal::ParseNaturalNumber;
75
+
76
+ namespace testing {
77
+ namespace internal {
78
+
79
+ // A helper class whose objects replace the death test factory for a
80
+ // single UnitTest object during their lifetimes.
81
+ class ReplaceDeathTestFactory {
82
+ public:
83
+ explicit ReplaceDeathTestFactory(DeathTestFactory* new_factory)
84
+ : unit_test_impl_(GetUnitTestImpl()) {
85
+ old_factory_ = unit_test_impl_->death_test_factory_.release();
86
+ unit_test_impl_->death_test_factory_.reset(new_factory);
87
+ }
88
+
89
+ ~ReplaceDeathTestFactory() {
90
+ unit_test_impl_->death_test_factory_.release();
91
+ unit_test_impl_->death_test_factory_.reset(old_factory_);
92
+ }
93
+ private:
94
+ // Prevents copying ReplaceDeathTestFactory objects.
95
+ ReplaceDeathTestFactory(const ReplaceDeathTestFactory&);
96
+ void operator=(const ReplaceDeathTestFactory&);
97
+
98
+ UnitTestImpl* unit_test_impl_;
99
+ DeathTestFactory* old_factory_;
100
+ };
101
+
102
+ } // namespace internal
103
+ } // namespace testing
104
+
105
+ namespace {
106
+
107
+ void DieWithMessage(const ::std::string& message) {
108
+ fprintf(stderr, "%s", message.c_str());
109
+ fflush(stderr); // Make sure the text is printed before the process exits.
110
+
111
+ // We call _exit() instead of exit(), as the former is a direct
112
+ // system call and thus safer in the presence of threads. exit()
113
+ // will invoke user-defined exit-hooks, which may do dangerous
114
+ // things that conflict with death tests.
115
+ //
116
+ // Some compilers can recognize that _exit() never returns and issue the
117
+ // 'unreachable code' warning for code following this function, unless
118
+ // fooled by a fake condition.
119
+ if (AlwaysTrue())
120
+ _exit(1);
121
+ }
122
+
123
+ void DieInside(const ::std::string& function) {
124
+ DieWithMessage("death inside " + function + "().");
125
+ }
126
+
127
+ // Tests that death tests work.
128
+
129
+ class TestForDeathTest : public testing::Test {
130
+ protected:
131
+ TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {}
132
+
133
+ ~TestForDeathTest() override { posix::ChDir(original_dir_.c_str()); }
134
+
135
+ // A static member function that's expected to die.
136
+ static void StaticMemberFunction() { DieInside("StaticMemberFunction"); }
137
+
138
+ // A method of the test fixture that may die.
139
+ void MemberFunction() {
140
+ if (should_die_)
141
+ DieInside("MemberFunction");
142
+ }
143
+
144
+ // True if and only if MemberFunction() should die.
145
+ bool should_die_;
146
+ const FilePath original_dir_;
147
+ };
148
+
149
+ // A class with a member function that may die.
150
+ class MayDie {
151
+ public:
152
+ explicit MayDie(bool should_die) : should_die_(should_die) {}
153
+
154
+ // A member function that may die.
155
+ void MemberFunction() const {
156
+ if (should_die_)
157
+ DieInside("MayDie::MemberFunction");
158
+ }
159
+
160
+ private:
161
+ // True if and only if MemberFunction() should die.
162
+ bool should_die_;
163
+ };
164
+
165
+ // A global function that's expected to die.
166
+ void GlobalFunction() { DieInside("GlobalFunction"); }
167
+
168
+ // A non-void function that's expected to die.
169
+ int NonVoidFunction() {
170
+ DieInside("NonVoidFunction");
171
+ return 1;
172
+ }
173
+
174
+ // A unary function that may die.
175
+ void DieIf(bool should_die) {
176
+ if (should_die)
177
+ DieInside("DieIf");
178
+ }
179
+
180
+ // A binary function that may die.
181
+ bool DieIfLessThan(int x, int y) {
182
+ if (x < y) {
183
+ DieInside("DieIfLessThan");
184
+ }
185
+ return true;
186
+ }
187
+
188
+ // Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.
189
+ void DeathTestSubroutine() {
190
+ EXPECT_DEATH(GlobalFunction(), "death.*GlobalFunction");
191
+ ASSERT_DEATH(GlobalFunction(), "death.*GlobalFunction");
192
+ }
193
+
194
+ // Death in dbg, not opt.
195
+ int DieInDebugElse12(int* sideeffect) {
196
+ if (sideeffect) *sideeffect = 12;
197
+
198
+ # ifndef NDEBUG
199
+
200
+ DieInside("DieInDebugElse12");
201
+
202
+ # endif // NDEBUG
203
+
204
+ return 12;
205
+ }
206
+
207
+ # if GTEST_OS_WINDOWS
208
+
209
+ // Death in dbg due to Windows CRT assertion failure, not opt.
210
+ int DieInCRTDebugElse12(int* sideeffect) {
211
+ if (sideeffect) *sideeffect = 12;
212
+
213
+ // Create an invalid fd by closing a valid one
214
+ int fdpipe[2];
215
+ EXPECT_EQ(_pipe(fdpipe, 256, O_BINARY), 0);
216
+ EXPECT_EQ(_close(fdpipe[0]), 0);
217
+ EXPECT_EQ(_close(fdpipe[1]), 0);
218
+
219
+ // _dup() should crash in debug mode
220
+ EXPECT_EQ(_dup(fdpipe[0]), -1);
221
+
222
+ return 12;
223
+ }
224
+
225
+ #endif // GTEST_OS_WINDOWS
226
+
227
+ # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
228
+
229
+ // Tests the ExitedWithCode predicate.
230
+ TEST(ExitStatusPredicateTest, ExitedWithCode) {
231
+ // On Windows, the process's exit code is the same as its exit status,
232
+ // so the predicate just compares the its input with its parameter.
233
+ EXPECT_TRUE(testing::ExitedWithCode(0)(0));
234
+ EXPECT_TRUE(testing::ExitedWithCode(1)(1));
235
+ EXPECT_TRUE(testing::ExitedWithCode(42)(42));
236
+ EXPECT_FALSE(testing::ExitedWithCode(0)(1));
237
+ EXPECT_FALSE(testing::ExitedWithCode(1)(0));
238
+ }
239
+
240
+ # else
241
+
242
+ // Returns the exit status of a process that calls _exit(2) with a
243
+ // given exit code. This is a helper function for the
244
+ // ExitStatusPredicateTest test suite.
245
+ static int NormalExitStatus(int exit_code) {
246
+ pid_t child_pid = fork();
247
+ if (child_pid == 0) {
248
+ _exit(exit_code);
249
+ }
250
+ int status;
251
+ waitpid(child_pid, &status, 0);
252
+ return status;
253
+ }
254
+
255
+ // Returns the exit status of a process that raises a given signal.
256
+ // If the signal does not cause the process to die, then it returns
257
+ // instead the exit status of a process that exits normally with exit
258
+ // code 1. This is a helper function for the ExitStatusPredicateTest
259
+ // test suite.
260
+ static int KilledExitStatus(int signum) {
261
+ pid_t child_pid = fork();
262
+ if (child_pid == 0) {
263
+ raise(signum);
264
+ _exit(1);
265
+ }
266
+ int status;
267
+ waitpid(child_pid, &status, 0);
268
+ return status;
269
+ }
270
+
271
+ // Tests the ExitedWithCode predicate.
272
+ TEST(ExitStatusPredicateTest, ExitedWithCode) {
273
+ const int status0 = NormalExitStatus(0);
274
+ const int status1 = NormalExitStatus(1);
275
+ const int status42 = NormalExitStatus(42);
276
+ const testing::ExitedWithCode pred0(0);
277
+ const testing::ExitedWithCode pred1(1);
278
+ const testing::ExitedWithCode pred42(42);
279
+ EXPECT_PRED1(pred0, status0);
280
+ EXPECT_PRED1(pred1, status1);
281
+ EXPECT_PRED1(pred42, status42);
282
+ EXPECT_FALSE(pred0(status1));
283
+ EXPECT_FALSE(pred42(status0));
284
+ EXPECT_FALSE(pred1(status42));
285
+ }
286
+
287
+ // Tests the KilledBySignal predicate.
288
+ TEST(ExitStatusPredicateTest, KilledBySignal) {
289
+ const int status_segv = KilledExitStatus(SIGSEGV);
290
+ const int status_kill = KilledExitStatus(SIGKILL);
291
+ const testing::KilledBySignal pred_segv(SIGSEGV);
292
+ const testing::KilledBySignal pred_kill(SIGKILL);
293
+ EXPECT_PRED1(pred_segv, status_segv);
294
+ EXPECT_PRED1(pred_kill, status_kill);
295
+ EXPECT_FALSE(pred_segv(status_kill));
296
+ EXPECT_FALSE(pred_kill(status_segv));
297
+ }
298
+
299
+ # endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
300
+
301
+ // Tests that the death test macros expand to code which may or may not
302
+ // be followed by operator<<, and that in either case the complete text
303
+ // comprises only a single C++ statement.
304
+ TEST_F(TestForDeathTest, SingleStatement) {
305
+ if (AlwaysFalse())
306
+ // This would fail if executed; this is a compilation test only
307
+ ASSERT_DEATH(return, "");
308
+
309
+ if (AlwaysTrue())
310
+ EXPECT_DEATH(_exit(1), "");
311
+ else
312
+ // This empty "else" branch is meant to ensure that EXPECT_DEATH
313
+ // doesn't expand into an "if" statement without an "else"
314
+ ;
315
+
316
+ if (AlwaysFalse())
317
+ ASSERT_DEATH(return, "") << "did not die";
318
+
319
+ if (AlwaysFalse())
320
+ ;
321
+ else
322
+ EXPECT_DEATH(_exit(1), "") << 1 << 2 << 3;
323
+ }
324
+
325
+ # if GTEST_USES_PCRE
326
+
327
+ void DieWithEmbeddedNul() {
328
+ fprintf(stderr, "Hello%cmy null world.\n", '\0');
329
+ fflush(stderr);
330
+ _exit(1);
331
+ }
332
+
333
+ // Tests that EXPECT_DEATH and ASSERT_DEATH work when the error
334
+ // message has a NUL character in it.
335
+ TEST_F(TestForDeathTest, EmbeddedNulInMessage) {
336
+ EXPECT_DEATH(DieWithEmbeddedNul(), "my null world");
337
+ ASSERT_DEATH(DieWithEmbeddedNul(), "my null world");
338
+ }
339
+
340
+ # endif // GTEST_USES_PCRE
341
+
342
+ // Tests that death test macros expand to code which interacts well with switch
343
+ // statements.
344
+ TEST_F(TestForDeathTest, SwitchStatement) {
345
+ // Microsoft compiler usually complains about switch statements without
346
+ // case labels. We suppress that warning for this test.
347
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4065)
348
+
349
+ switch (0)
350
+ default:
351
+ ASSERT_DEATH(_exit(1), "") << "exit in default switch handler";
352
+
353
+ switch (0)
354
+ case 0:
355
+ EXPECT_DEATH(_exit(1), "") << "exit in switch case";
356
+
357
+ GTEST_DISABLE_MSC_WARNINGS_POP_()
358
+ }
359
+
360
+ // Tests that a static member function can be used in a "fast" style
361
+ // death test.
362
+ TEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {
363
+ testing::GTEST_FLAG(death_test_style) = "fast";
364
+ ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
365
+ }
366
+
367
+ // Tests that a method of the test fixture can be used in a "fast"
368
+ // style death test.
369
+ TEST_F(TestForDeathTest, MemberFunctionFastStyle) {
370
+ testing::GTEST_FLAG(death_test_style) = "fast";
371
+ should_die_ = true;
372
+ EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
373
+ }
374
+
375
+ void ChangeToRootDir() { posix::ChDir(GTEST_PATH_SEP_); }
376
+
377
+ // Tests that death tests work even if the current directory has been
378
+ // changed.
379
+ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
380
+ testing::GTEST_FLAG(death_test_style) = "fast";
381
+
382
+ ChangeToRootDir();
383
+ EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
384
+
385
+ ChangeToRootDir();
386
+ ASSERT_DEATH(_exit(1), "");
387
+ }
388
+
389
+ # if GTEST_OS_LINUX
390
+ void SigprofAction(int, siginfo_t*, void*) { /* no op */ }
391
+
392
+ // Sets SIGPROF action and ITIMER_PROF timer (interval: 1ms).
393
+ void SetSigprofActionAndTimer() {
394
+ struct itimerval timer;
395
+ timer.it_interval.tv_sec = 0;
396
+ timer.it_interval.tv_usec = 1;
397
+ timer.it_value = timer.it_interval;
398
+ ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr));
399
+ struct sigaction signal_action;
400
+ memset(&signal_action, 0, sizeof(signal_action));
401
+ sigemptyset(&signal_action.sa_mask);
402
+ signal_action.sa_sigaction = SigprofAction;
403
+ signal_action.sa_flags = SA_RESTART | SA_SIGINFO;
404
+ ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, nullptr));
405
+ }
406
+
407
+ // Disables ITIMER_PROF timer and ignores SIGPROF signal.
408
+ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {
409
+ struct itimerval timer;
410
+ timer.it_interval.tv_sec = 0;
411
+ timer.it_interval.tv_usec = 0;
412
+ timer.it_value = timer.it_interval;
413
+ ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, nullptr));
414
+ struct sigaction signal_action;
415
+ memset(&signal_action, 0, sizeof(signal_action));
416
+ sigemptyset(&signal_action.sa_mask);
417
+ signal_action.sa_handler = SIG_IGN;
418
+ ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, old_signal_action));
419
+ }
420
+
421
+ // Tests that death tests work when SIGPROF handler and timer are set.
422
+ TEST_F(TestForDeathTest, FastSigprofActionSet) {
423
+ testing::GTEST_FLAG(death_test_style) = "fast";
424
+ SetSigprofActionAndTimer();
425
+ EXPECT_DEATH(_exit(1), "");
426
+ struct sigaction old_signal_action;
427
+ DisableSigprofActionAndTimer(&old_signal_action);
428
+ EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
429
+ }
430
+
431
+ TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
432
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
433
+ SetSigprofActionAndTimer();
434
+ EXPECT_DEATH(_exit(1), "");
435
+ struct sigaction old_signal_action;
436
+ DisableSigprofActionAndTimer(&old_signal_action);
437
+ EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
438
+ }
439
+ # endif // GTEST_OS_LINUX
440
+
441
+ // Repeats a representative sample of death tests in the "threadsafe" style:
442
+
443
+ TEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {
444
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
445
+ ASSERT_DEATH(StaticMemberFunction(), "death.*StaticMember");
446
+ }
447
+
448
+ TEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {
449
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
450
+ should_die_ = true;
451
+ EXPECT_DEATH(MemberFunction(), "inside.*MemberFunction");
452
+ }
453
+
454
+ TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
455
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
456
+
457
+ for (int i = 0; i < 3; ++i)
458
+ EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), "") << ": i = " << i;
459
+ }
460
+
461
+ TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
462
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
463
+
464
+ ChangeToRootDir();
465
+ EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
466
+
467
+ ChangeToRootDir();
468
+ ASSERT_DEATH(_exit(1), "");
469
+ }
470
+
471
+ TEST_F(TestForDeathTest, MixedStyles) {
472
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
473
+ EXPECT_DEATH(_exit(1), "");
474
+ testing::GTEST_FLAG(death_test_style) = "fast";
475
+ EXPECT_DEATH(_exit(1), "");
476
+ }
477
+
478
+ # if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
479
+
480
+ bool pthread_flag;
481
+
482
+ void SetPthreadFlag() {
483
+ pthread_flag = true;
484
+ }
485
+
486
+ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
487
+ if (!testing::GTEST_FLAG(death_test_use_fork)) {
488
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
489
+ pthread_flag = false;
490
+ ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr));
491
+ ASSERT_DEATH(_exit(1), "");
492
+ ASSERT_FALSE(pthread_flag);
493
+ }
494
+ }
495
+
496
+ # endif // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
497
+
498
+ // Tests that a method of another class can be used in a death test.
499
+ TEST_F(TestForDeathTest, MethodOfAnotherClass) {
500
+ const MayDie x(true);
501
+ ASSERT_DEATH(x.MemberFunction(), "MayDie\\:\\:MemberFunction");
502
+ }
503
+
504
+ // Tests that a global function can be used in a death test.
505
+ TEST_F(TestForDeathTest, GlobalFunction) {
506
+ EXPECT_DEATH(GlobalFunction(), "GlobalFunction");
507
+ }
508
+
509
+ // Tests that any value convertible to an RE works as a second
510
+ // argument to EXPECT_DEATH.
511
+ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {
512
+ static const char regex_c_str[] = "GlobalFunction";
513
+ EXPECT_DEATH(GlobalFunction(), regex_c_str);
514
+
515
+ const testing::internal::RE regex(regex_c_str);
516
+ EXPECT_DEATH(GlobalFunction(), regex);
517
+
518
+ # if !GTEST_USES_PCRE
519
+
520
+ const ::std::string regex_std_str(regex_c_str);
521
+ EXPECT_DEATH(GlobalFunction(), regex_std_str);
522
+
523
+ // This one is tricky; a temporary pointer into another temporary. Reference
524
+ // lifetime extension of the pointer is not sufficient.
525
+ EXPECT_DEATH(GlobalFunction(), ::std::string(regex_c_str).c_str());
526
+
527
+ # endif // !GTEST_USES_PCRE
528
+ }
529
+
530
+ // Tests that a non-void function can be used in a death test.
531
+ TEST_F(TestForDeathTest, NonVoidFunction) {
532
+ ASSERT_DEATH(NonVoidFunction(), "NonVoidFunction");
533
+ }
534
+
535
+ // Tests that functions that take parameter(s) can be used in a death test.
536
+ TEST_F(TestForDeathTest, FunctionWithParameter) {
537
+ EXPECT_DEATH(DieIf(true), "DieIf\\(\\)");
538
+ EXPECT_DEATH(DieIfLessThan(2, 3), "DieIfLessThan");
539
+ }
540
+
541
+ // Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.
542
+ TEST_F(TestForDeathTest, OutsideFixture) {
543
+ DeathTestSubroutine();
544
+ }
545
+
546
+ // Tests that death tests can be done inside a loop.
547
+ TEST_F(TestForDeathTest, InsideLoop) {
548
+ for (int i = 0; i < 5; i++) {
549
+ EXPECT_DEATH(DieIfLessThan(-1, i), "DieIfLessThan") << "where i == " << i;
550
+ }
551
+ }
552
+
553
+ // Tests that a compound statement can be used in a death test.
554
+ TEST_F(TestForDeathTest, CompoundStatement) {
555
+ EXPECT_DEATH({ // NOLINT
556
+ const int x = 2;
557
+ const int y = x + 1;
558
+ DieIfLessThan(x, y);
559
+ },
560
+ "DieIfLessThan");
561
+ }
562
+
563
+ // Tests that code that doesn't die causes a death test to fail.
564
+ TEST_F(TestForDeathTest, DoesNotDie) {
565
+ EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(DieIf(false), "DieIf"),
566
+ "failed to die");
567
+ }
568
+
569
+ // Tests that a death test fails when the error message isn't expected.
570
+ TEST_F(TestForDeathTest, ErrorMessageMismatch) {
571
+ EXPECT_NONFATAL_FAILURE({ // NOLINT
572
+ EXPECT_DEATH(DieIf(true), "DieIfLessThan") << "End of death test message.";
573
+ }, "died but not with expected error");
574
+ }
575
+
576
+ // On exit, *aborted will be true if and only if the EXPECT_DEATH()
577
+ // statement aborted the function.
578
+ void ExpectDeathTestHelper(bool* aborted) {
579
+ *aborted = true;
580
+ EXPECT_DEATH(DieIf(false), "DieIf"); // This assertion should fail.
581
+ *aborted = false;
582
+ }
583
+
584
+ // Tests that EXPECT_DEATH doesn't abort the test on failure.
585
+ TEST_F(TestForDeathTest, EXPECT_DEATH) {
586
+ bool aborted = true;
587
+ EXPECT_NONFATAL_FAILURE(ExpectDeathTestHelper(&aborted),
588
+ "failed to die");
589
+ EXPECT_FALSE(aborted);
590
+ }
591
+
592
+ // Tests that ASSERT_DEATH does abort the test on failure.
593
+ TEST_F(TestForDeathTest, ASSERT_DEATH) {
594
+ static bool aborted;
595
+ EXPECT_FATAL_FAILURE({ // NOLINT
596
+ aborted = true;
597
+ ASSERT_DEATH(DieIf(false), "DieIf"); // This assertion should fail.
598
+ aborted = false;
599
+ }, "failed to die");
600
+ EXPECT_TRUE(aborted);
601
+ }
602
+
603
+ // Tests that EXPECT_DEATH evaluates the arguments exactly once.
604
+ TEST_F(TestForDeathTest, SingleEvaluation) {
605
+ int x = 3;
606
+ EXPECT_DEATH(DieIf((++x) == 4), "DieIf");
607
+
608
+ const char* regex = "DieIf";
609
+ const char* regex_save = regex;
610
+ EXPECT_DEATH(DieIfLessThan(3, 4), regex++);
611
+ EXPECT_EQ(regex_save + 1, regex);
612
+ }
613
+
614
+ // Tests that run-away death tests are reported as failures.
615
+ TEST_F(TestForDeathTest, RunawayIsFailure) {
616
+ EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(static_cast<void>(0), "Foo"),
617
+ "failed to die.");
618
+ }
619
+
620
+ // Tests that death tests report executing 'return' in the statement as
621
+ // failure.
622
+ TEST_F(TestForDeathTest, ReturnIsFailure) {
623
+ EXPECT_FATAL_FAILURE(ASSERT_DEATH(return, "Bar"),
624
+ "illegal return in test statement.");
625
+ }
626
+
627
+ // Tests that EXPECT_DEBUG_DEATH works as expected, that is, you can stream a
628
+ // message to it, and in debug mode it:
629
+ // 1. Asserts on death.
630
+ // 2. Has no side effect.
631
+ //
632
+ // And in opt mode, it:
633
+ // 1. Has side effects but does not assert.
634
+ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
635
+ int sideeffect = 0;
636
+
637
+ // Put the regex in a local variable to make sure we don't get an "unused"
638
+ // warning in opt mode.
639
+ const char* regex = "death.*DieInDebugElse12";
640
+
641
+ EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), regex)
642
+ << "Must accept a streamed message";
643
+
644
+ # ifdef NDEBUG
645
+
646
+ // Checks that the assignment occurs in opt mode (sideeffect).
647
+ EXPECT_EQ(12, sideeffect);
648
+
649
+ # else
650
+
651
+ // Checks that the assignment does not occur in dbg mode (no sideeffect).
652
+ EXPECT_EQ(0, sideeffect);
653
+
654
+ # endif
655
+ }
656
+
657
+ # if GTEST_OS_WINDOWS
658
+
659
+ // Tests that EXPECT_DEBUG_DEATH works as expected when in debug mode
660
+ // the Windows CRT crashes the process with an assertion failure.
661
+ // 1. Asserts on death.
662
+ // 2. Has no side effect (doesn't pop up a window or wait for user input).
663
+ //
664
+ // And in opt mode, it:
665
+ // 1. Has side effects but does not assert.
666
+ TEST_F(TestForDeathTest, CRTDebugDeath) {
667
+ int sideeffect = 0;
668
+
669
+ // Put the regex in a local variable to make sure we don't get an "unused"
670
+ // warning in opt mode.
671
+ const char* regex = "dup.* : Assertion failed";
672
+
673
+ EXPECT_DEBUG_DEATH(DieInCRTDebugElse12(&sideeffect), regex)
674
+ << "Must accept a streamed message";
675
+
676
+ # ifdef NDEBUG
677
+
678
+ // Checks that the assignment occurs in opt mode (sideeffect).
679
+ EXPECT_EQ(12, sideeffect);
680
+
681
+ # else
682
+
683
+ // Checks that the assignment does not occur in dbg mode (no sideeffect).
684
+ EXPECT_EQ(0, sideeffect);
685
+
686
+ # endif
687
+ }
688
+
689
+ # endif // GTEST_OS_WINDOWS
690
+
691
+ // Tests that ASSERT_DEBUG_DEATH works as expected, that is, you can stream a
692
+ // message to it, and in debug mode it:
693
+ // 1. Asserts on death.
694
+ // 2. Has no side effect.
695
+ //
696
+ // And in opt mode, it:
697
+ // 1. Has side effects but does not assert.
698
+ TEST_F(TestForDeathTest, TestAssertDebugDeath) {
699
+ int sideeffect = 0;
700
+
701
+ ASSERT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), "death.*DieInDebugElse12")
702
+ << "Must accept a streamed message";
703
+
704
+ # ifdef NDEBUG
705
+
706
+ // Checks that the assignment occurs in opt mode (sideeffect).
707
+ EXPECT_EQ(12, sideeffect);
708
+
709
+ # else
710
+
711
+ // Checks that the assignment does not occur in dbg mode (no sideeffect).
712
+ EXPECT_EQ(0, sideeffect);
713
+
714
+ # endif
715
+ }
716
+
717
+ # ifndef NDEBUG
718
+
719
+ void ExpectDebugDeathHelper(bool* aborted) {
720
+ *aborted = true;
721
+ EXPECT_DEBUG_DEATH(return, "") << "This is expected to fail.";
722
+ *aborted = false;
723
+ }
724
+
725
+ # if GTEST_OS_WINDOWS
726
+ TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {
727
+ printf("This test should be considered failing if it shows "
728
+ "any pop-up dialogs.\n");
729
+ fflush(stdout);
730
+
731
+ EXPECT_DEATH({
732
+ testing::GTEST_FLAG(catch_exceptions) = false;
733
+ abort();
734
+ }, "");
735
+ }
736
+ # endif // GTEST_OS_WINDOWS
737
+
738
+ // Tests that EXPECT_DEBUG_DEATH in debug mode does not abort
739
+ // the function.
740
+ TEST_F(TestForDeathTest, ExpectDebugDeathDoesNotAbort) {
741
+ bool aborted = true;
742
+ EXPECT_NONFATAL_FAILURE(ExpectDebugDeathHelper(&aborted), "");
743
+ EXPECT_FALSE(aborted);
744
+ }
745
+
746
+ void AssertDebugDeathHelper(bool* aborted) {
747
+ *aborted = true;
748
+ GTEST_LOG_(INFO) << "Before ASSERT_DEBUG_DEATH";
749
+ ASSERT_DEBUG_DEATH(GTEST_LOG_(INFO) << "In ASSERT_DEBUG_DEATH"; return, "")
750
+ << "This is expected to fail.";
751
+ GTEST_LOG_(INFO) << "After ASSERT_DEBUG_DEATH";
752
+ *aborted = false;
753
+ }
754
+
755
+ // Tests that ASSERT_DEBUG_DEATH in debug mode aborts the function on
756
+ // failure.
757
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts) {
758
+ static bool aborted;
759
+ aborted = false;
760
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
761
+ EXPECT_TRUE(aborted);
762
+ }
763
+
764
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts2) {
765
+ static bool aborted;
766
+ aborted = false;
767
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
768
+ EXPECT_TRUE(aborted);
769
+ }
770
+
771
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts3) {
772
+ static bool aborted;
773
+ aborted = false;
774
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
775
+ EXPECT_TRUE(aborted);
776
+ }
777
+
778
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts4) {
779
+ static bool aborted;
780
+ aborted = false;
781
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
782
+ EXPECT_TRUE(aborted);
783
+ }
784
+
785
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts5) {
786
+ static bool aborted;
787
+ aborted = false;
788
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
789
+ EXPECT_TRUE(aborted);
790
+ }
791
+
792
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts6) {
793
+ static bool aborted;
794
+ aborted = false;
795
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
796
+ EXPECT_TRUE(aborted);
797
+ }
798
+
799
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts7) {
800
+ static bool aborted;
801
+ aborted = false;
802
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
803
+ EXPECT_TRUE(aborted);
804
+ }
805
+
806
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts8) {
807
+ static bool aborted;
808
+ aborted = false;
809
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
810
+ EXPECT_TRUE(aborted);
811
+ }
812
+
813
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts9) {
814
+ static bool aborted;
815
+ aborted = false;
816
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
817
+ EXPECT_TRUE(aborted);
818
+ }
819
+
820
+ TEST_F(TestForDeathTest, AssertDebugDeathAborts10) {
821
+ static bool aborted;
822
+ aborted = false;
823
+ EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), "");
824
+ EXPECT_TRUE(aborted);
825
+ }
826
+
827
+ # endif // _NDEBUG
828
+
829
+ // Tests the *_EXIT family of macros, using a variety of predicates.
830
+ static void TestExitMacros() {
831
+ EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
832
+ ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), "");
833
+
834
+ # if GTEST_OS_WINDOWS
835
+
836
+ // Of all signals effects on the process exit code, only those of SIGABRT
837
+ // are documented on Windows.
838
+ // See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c.
839
+ EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar";
840
+
841
+ # elif !GTEST_OS_FUCHSIA
842
+
843
+ // Fuchsia has no unix signals.
844
+ EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo";
845
+ ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), "") << "bar";
846
+
847
+ EXPECT_FATAL_FAILURE({ // NOLINT
848
+ ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), "")
849
+ << "This failure is expected, too.";
850
+ }, "This failure is expected, too.");
851
+
852
+ # endif // GTEST_OS_WINDOWS
853
+
854
+ EXPECT_NONFATAL_FAILURE({ // NOLINT
855
+ EXPECT_EXIT(raise(SIGSEGV), testing::ExitedWithCode(0), "")
856
+ << "This failure is expected.";
857
+ }, "This failure is expected.");
858
+ }
859
+
860
+ TEST_F(TestForDeathTest, ExitMacros) {
861
+ TestExitMacros();
862
+ }
863
+
864
+ TEST_F(TestForDeathTest, ExitMacrosUsingFork) {
865
+ testing::GTEST_FLAG(death_test_use_fork) = true;
866
+ TestExitMacros();
867
+ }
868
+
869
+ TEST_F(TestForDeathTest, InvalidStyle) {
870
+ testing::GTEST_FLAG(death_test_style) = "rococo";
871
+ EXPECT_NONFATAL_FAILURE({ // NOLINT
872
+ EXPECT_DEATH(_exit(0), "") << "This failure is expected.";
873
+ }, "This failure is expected.");
874
+ }
875
+
876
+ TEST_F(TestForDeathTest, DeathTestFailedOutput) {
877
+ testing::GTEST_FLAG(death_test_style) = "fast";
878
+ EXPECT_NONFATAL_FAILURE(
879
+ EXPECT_DEATH(DieWithMessage("death\n"),
880
+ "expected message"),
881
+ "Actual msg:\n"
882
+ "[ DEATH ] death\n");
883
+ }
884
+
885
+ TEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {
886
+ testing::GTEST_FLAG(death_test_style) = "fast";
887
+ EXPECT_NONFATAL_FAILURE(
888
+ EXPECT_DEATH({
889
+ fprintf(stderr, "returning\n");
890
+ fflush(stderr);
891
+ return;
892
+ }, ""),
893
+ " Result: illegal return in test statement.\n"
894
+ " Error msg:\n"
895
+ "[ DEATH ] returning\n");
896
+ }
897
+
898
+ TEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {
899
+ testing::GTEST_FLAG(death_test_style) = "fast";
900
+ EXPECT_NONFATAL_FAILURE(
901
+ EXPECT_EXIT(DieWithMessage("exiting with rc 1\n"),
902
+ testing::ExitedWithCode(3),
903
+ "expected message"),
904
+ " Result: died but not with expected exit code:\n"
905
+ " Exited with exit status 1\n"
906
+ "Actual msg:\n"
907
+ "[ DEATH ] exiting with rc 1\n");
908
+ }
909
+
910
+ TEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {
911
+ testing::GTEST_FLAG(death_test_style) = "fast";
912
+ EXPECT_NONFATAL_FAILURE(
913
+ EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
914
+ "line 1\nxyz\nline 3\n"),
915
+ "Actual msg:\n"
916
+ "[ DEATH ] line 1\n"
917
+ "[ DEATH ] line 2\n"
918
+ "[ DEATH ] line 3\n");
919
+ }
920
+
921
+ TEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {
922
+ testing::GTEST_FLAG(death_test_style) = "fast";
923
+ EXPECT_DEATH(DieWithMessage("line 1\nline 2\nline 3\n"),
924
+ "line 1\nline 2\nline 3\n");
925
+ }
926
+
927
+ // A DeathTestFactory that returns MockDeathTests.
928
+ class MockDeathTestFactory : public DeathTestFactory {
929
+ public:
930
+ MockDeathTestFactory();
931
+ bool Create(const char* statement,
932
+ testing::Matcher<const std::string&> matcher, const char* file,
933
+ int line, DeathTest** test) override;
934
+
935
+ // Sets the parameters for subsequent calls to Create.
936
+ void SetParameters(bool create, DeathTest::TestRole role,
937
+ int status, bool passed);
938
+
939
+ // Accessors.
940
+ int AssumeRoleCalls() const { return assume_role_calls_; }
941
+ int WaitCalls() const { return wait_calls_; }
942
+ size_t PassedCalls() const { return passed_args_.size(); }
943
+ bool PassedArgument(int n) const {
944
+ return passed_args_[static_cast<size_t>(n)];
945
+ }
946
+ size_t AbortCalls() const { return abort_args_.size(); }
947
+ DeathTest::AbortReason AbortArgument(int n) const {
948
+ return abort_args_[static_cast<size_t>(n)];
949
+ }
950
+ bool TestDeleted() const { return test_deleted_; }
951
+
952
+ private:
953
+ friend class MockDeathTest;
954
+ // If true, Create will return a MockDeathTest; otherwise it returns
955
+ // NULL.
956
+ bool create_;
957
+ // The value a MockDeathTest will return from its AssumeRole method.
958
+ DeathTest::TestRole role_;
959
+ // The value a MockDeathTest will return from its Wait method.
960
+ int status_;
961
+ // The value a MockDeathTest will return from its Passed method.
962
+ bool passed_;
963
+
964
+ // Number of times AssumeRole was called.
965
+ int assume_role_calls_;
966
+ // Number of times Wait was called.
967
+ int wait_calls_;
968
+ // The arguments to the calls to Passed since the last call to
969
+ // SetParameters.
970
+ std::vector<bool> passed_args_;
971
+ // The arguments to the calls to Abort since the last call to
972
+ // SetParameters.
973
+ std::vector<DeathTest::AbortReason> abort_args_;
974
+ // True if the last MockDeathTest returned by Create has been
975
+ // deleted.
976
+ bool test_deleted_;
977
+ };
978
+
979
+
980
+ // A DeathTest implementation useful in testing. It returns values set
981
+ // at its creation from its various inherited DeathTest methods, and
982
+ // reports calls to those methods to its parent MockDeathTestFactory
983
+ // object.
984
+ class MockDeathTest : public DeathTest {
985
+ public:
986
+ MockDeathTest(MockDeathTestFactory *parent,
987
+ TestRole role, int status, bool passed) :
988
+ parent_(parent), role_(role), status_(status), passed_(passed) {
989
+ }
990
+ ~MockDeathTest() override { parent_->test_deleted_ = true; }
991
+ TestRole AssumeRole() override {
992
+ ++parent_->assume_role_calls_;
993
+ return role_;
994
+ }
995
+ int Wait() override {
996
+ ++parent_->wait_calls_;
997
+ return status_;
998
+ }
999
+ bool Passed(bool exit_status_ok) override {
1000
+ parent_->passed_args_.push_back(exit_status_ok);
1001
+ return passed_;
1002
+ }
1003
+ void Abort(AbortReason reason) override {
1004
+ parent_->abort_args_.push_back(reason);
1005
+ }
1006
+
1007
+ private:
1008
+ MockDeathTestFactory* const parent_;
1009
+ const TestRole role_;
1010
+ const int status_;
1011
+ const bool passed_;
1012
+ };
1013
+
1014
+
1015
+ // MockDeathTestFactory constructor.
1016
+ MockDeathTestFactory::MockDeathTestFactory()
1017
+ : create_(true),
1018
+ role_(DeathTest::OVERSEE_TEST),
1019
+ status_(0),
1020
+ passed_(true),
1021
+ assume_role_calls_(0),
1022
+ wait_calls_(0),
1023
+ passed_args_(),
1024
+ abort_args_() {
1025
+ }
1026
+
1027
+
1028
+ // Sets the parameters for subsequent calls to Create.
1029
+ void MockDeathTestFactory::SetParameters(bool create,
1030
+ DeathTest::TestRole role,
1031
+ int status, bool passed) {
1032
+ create_ = create;
1033
+ role_ = role;
1034
+ status_ = status;
1035
+ passed_ = passed;
1036
+
1037
+ assume_role_calls_ = 0;
1038
+ wait_calls_ = 0;
1039
+ passed_args_.clear();
1040
+ abort_args_.clear();
1041
+ }
1042
+
1043
+
1044
+ // Sets test to NULL (if create_ is false) or to the address of a new
1045
+ // MockDeathTest object with parameters taken from the last call
1046
+ // to SetParameters (if create_ is true). Always returns true.
1047
+ bool MockDeathTestFactory::Create(
1048
+ const char* /*statement*/, testing::Matcher<const std::string&> /*matcher*/,
1049
+ const char* /*file*/, int /*line*/, DeathTest** test) {
1050
+ test_deleted_ = false;
1051
+ if (create_) {
1052
+ *test = new MockDeathTest(this, role_, status_, passed_);
1053
+ } else {
1054
+ *test = nullptr;
1055
+ }
1056
+ return true;
1057
+ }
1058
+
1059
+ // A test fixture for testing the logic of the GTEST_DEATH_TEST_ macro.
1060
+ // It installs a MockDeathTestFactory that is used for the duration
1061
+ // of the test case.
1062
+ class MacroLogicDeathTest : public testing::Test {
1063
+ protected:
1064
+ static testing::internal::ReplaceDeathTestFactory* replacer_;
1065
+ static MockDeathTestFactory* factory_;
1066
+
1067
+ static void SetUpTestSuite() {
1068
+ factory_ = new MockDeathTestFactory;
1069
+ replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);
1070
+ }
1071
+
1072
+ static void TearDownTestSuite() {
1073
+ delete replacer_;
1074
+ replacer_ = nullptr;
1075
+ delete factory_;
1076
+ factory_ = nullptr;
1077
+ }
1078
+
1079
+ // Runs a death test that breaks the rules by returning. Such a death
1080
+ // test cannot be run directly from a test routine that uses a
1081
+ // MockDeathTest, or the remainder of the routine will not be executed.
1082
+ static void RunReturningDeathTest(bool* flag) {
1083
+ ASSERT_DEATH({ // NOLINT
1084
+ *flag = true;
1085
+ return;
1086
+ }, "");
1087
+ }
1088
+ };
1089
+
1090
+ testing::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_ =
1091
+ nullptr;
1092
+ MockDeathTestFactory* MacroLogicDeathTest::factory_ = nullptr;
1093
+
1094
+ // Test that nothing happens when the factory doesn't return a DeathTest:
1095
+ TEST_F(MacroLogicDeathTest, NothingHappens) {
1096
+ bool flag = false;
1097
+ factory_->SetParameters(false, DeathTest::OVERSEE_TEST, 0, true);
1098
+ EXPECT_DEATH(flag = true, "");
1099
+ EXPECT_FALSE(flag);
1100
+ EXPECT_EQ(0, factory_->AssumeRoleCalls());
1101
+ EXPECT_EQ(0, factory_->WaitCalls());
1102
+ EXPECT_EQ(0U, factory_->PassedCalls());
1103
+ EXPECT_EQ(0U, factory_->AbortCalls());
1104
+ EXPECT_FALSE(factory_->TestDeleted());
1105
+ }
1106
+
1107
+ // Test that the parent process doesn't run the death test code,
1108
+ // and that the Passed method returns false when the (simulated)
1109
+ // child process exits with status 0:
1110
+ TEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) {
1111
+ bool flag = false;
1112
+ factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 0, true);
1113
+ EXPECT_DEATH(flag = true, "");
1114
+ EXPECT_FALSE(flag);
1115
+ EXPECT_EQ(1, factory_->AssumeRoleCalls());
1116
+ EXPECT_EQ(1, factory_->WaitCalls());
1117
+ ASSERT_EQ(1U, factory_->PassedCalls());
1118
+ EXPECT_FALSE(factory_->PassedArgument(0));
1119
+ EXPECT_EQ(0U, factory_->AbortCalls());
1120
+ EXPECT_TRUE(factory_->TestDeleted());
1121
+ }
1122
+
1123
+ // Tests that the Passed method was given the argument "true" when
1124
+ // the (simulated) child process exits with status 1:
1125
+ TEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) {
1126
+ bool flag = false;
1127
+ factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 1, true);
1128
+ EXPECT_DEATH(flag = true, "");
1129
+ EXPECT_FALSE(flag);
1130
+ EXPECT_EQ(1, factory_->AssumeRoleCalls());
1131
+ EXPECT_EQ(1, factory_->WaitCalls());
1132
+ ASSERT_EQ(1U, factory_->PassedCalls());
1133
+ EXPECT_TRUE(factory_->PassedArgument(0));
1134
+ EXPECT_EQ(0U, factory_->AbortCalls());
1135
+ EXPECT_TRUE(factory_->TestDeleted());
1136
+ }
1137
+
1138
+ // Tests that the (simulated) child process executes the death test
1139
+ // code, and is aborted with the correct AbortReason if it
1140
+ // executes a return statement.
1141
+ TEST_F(MacroLogicDeathTest, ChildPerformsReturn) {
1142
+ bool flag = false;
1143
+ factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);
1144
+ RunReturningDeathTest(&flag);
1145
+ EXPECT_TRUE(flag);
1146
+ EXPECT_EQ(1, factory_->AssumeRoleCalls());
1147
+ EXPECT_EQ(0, factory_->WaitCalls());
1148
+ EXPECT_EQ(0U, factory_->PassedCalls());
1149
+ EXPECT_EQ(1U, factory_->AbortCalls());
1150
+ EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1151
+ factory_->AbortArgument(0));
1152
+ EXPECT_TRUE(factory_->TestDeleted());
1153
+ }
1154
+
1155
+ // Tests that the (simulated) child process is aborted with the
1156
+ // correct AbortReason if it does not die.
1157
+ TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
1158
+ bool flag = false;
1159
+ factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);
1160
+ EXPECT_DEATH(flag = true, "");
1161
+ EXPECT_TRUE(flag);
1162
+ EXPECT_EQ(1, factory_->AssumeRoleCalls());
1163
+ EXPECT_EQ(0, factory_->WaitCalls());
1164
+ EXPECT_EQ(0U, factory_->PassedCalls());
1165
+ // This time there are two calls to Abort: one since the test didn't
1166
+ // die, and another from the ReturnSentinel when it's destroyed. The
1167
+ // sentinel normally isn't destroyed if a test doesn't die, since
1168
+ // _exit(2) is called in that case by ForkingDeathTest, but not by
1169
+ // our MockDeathTest.
1170
+ ASSERT_EQ(2U, factory_->AbortCalls());
1171
+ EXPECT_EQ(DeathTest::TEST_DID_NOT_DIE,
1172
+ factory_->AbortArgument(0));
1173
+ EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,
1174
+ factory_->AbortArgument(1));
1175
+ EXPECT_TRUE(factory_->TestDeleted());
1176
+ }
1177
+
1178
+ // Tests that a successful death test does not register a successful
1179
+ // test part.
1180
+ TEST(SuccessRegistrationDeathTest, NoSuccessPart) {
1181
+ EXPECT_DEATH(_exit(1), "");
1182
+ EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());
1183
+ }
1184
+
1185
+ TEST(StreamingAssertionsDeathTest, DeathTest) {
1186
+ EXPECT_DEATH(_exit(1), "") << "unexpected failure";
1187
+ ASSERT_DEATH(_exit(1), "") << "unexpected failure";
1188
+ EXPECT_NONFATAL_FAILURE({ // NOLINT
1189
+ EXPECT_DEATH(_exit(0), "") << "expected failure";
1190
+ }, "expected failure");
1191
+ EXPECT_FATAL_FAILURE({ // NOLINT
1192
+ ASSERT_DEATH(_exit(0), "") << "expected failure";
1193
+ }, "expected failure");
1194
+ }
1195
+
1196
+ // Tests that GetLastErrnoDescription returns an empty string when the
1197
+ // last error is 0 and non-empty string when it is non-zero.
1198
+ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {
1199
+ errno = ENOENT;
1200
+ EXPECT_STRNE("", GetLastErrnoDescription().c_str());
1201
+ errno = 0;
1202
+ EXPECT_STREQ("", GetLastErrnoDescription().c_str());
1203
+ }
1204
+
1205
+ # if GTEST_OS_WINDOWS
1206
+ TEST(AutoHandleTest, AutoHandleWorks) {
1207
+ HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
1208
+ ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1209
+
1210
+ // Tests that the AutoHandle is correctly initialized with a handle.
1211
+ testing::internal::AutoHandle auto_handle(handle);
1212
+ EXPECT_EQ(handle, auto_handle.Get());
1213
+
1214
+ // Tests that Reset assigns INVALID_HANDLE_VALUE.
1215
+ // Note that this cannot verify whether the original handle is closed.
1216
+ auto_handle.Reset();
1217
+ EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle.Get());
1218
+
1219
+ // Tests that Reset assigns the new handle.
1220
+ // Note that this cannot verify whether the original handle is closed.
1221
+ handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);
1222
+ ASSERT_NE(INVALID_HANDLE_VALUE, handle);
1223
+ auto_handle.Reset(handle);
1224
+ EXPECT_EQ(handle, auto_handle.Get());
1225
+
1226
+ // Tests that AutoHandle contains INVALID_HANDLE_VALUE by default.
1227
+ testing::internal::AutoHandle auto_handle2;
1228
+ EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());
1229
+ }
1230
+ # endif // GTEST_OS_WINDOWS
1231
+
1232
+ # if GTEST_OS_WINDOWS
1233
+ typedef unsigned __int64 BiggestParsable;
1234
+ typedef signed __int64 BiggestSignedParsable;
1235
+ # else
1236
+ typedef unsigned long long BiggestParsable;
1237
+ typedef signed long long BiggestSignedParsable;
1238
+ # endif // GTEST_OS_WINDOWS
1239
+
1240
+ // We cannot use std::numeric_limits<T>::max() as it clashes with the
1241
+ // max() macro defined by <windows.h>.
1242
+ const BiggestParsable kBiggestParsableMax = ULLONG_MAX;
1243
+ const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;
1244
+
1245
+ TEST(ParseNaturalNumberTest, RejectsInvalidFormat) {
1246
+ BiggestParsable result = 0;
1247
+
1248
+ // Rejects non-numbers.
1249
+ EXPECT_FALSE(ParseNaturalNumber("non-number string", &result));
1250
+
1251
+ // Rejects numbers with whitespace prefix.
1252
+ EXPECT_FALSE(ParseNaturalNumber(" 123", &result));
1253
+
1254
+ // Rejects negative numbers.
1255
+ EXPECT_FALSE(ParseNaturalNumber("-123", &result));
1256
+
1257
+ // Rejects numbers starting with a plus sign.
1258
+ EXPECT_FALSE(ParseNaturalNumber("+123", &result));
1259
+ errno = 0;
1260
+ }
1261
+
1262
+ TEST(ParseNaturalNumberTest, RejectsOverflownNumbers) {
1263
+ BiggestParsable result = 0;
1264
+
1265
+ EXPECT_FALSE(ParseNaturalNumber("99999999999999999999999", &result));
1266
+
1267
+ signed char char_result = 0;
1268
+ EXPECT_FALSE(ParseNaturalNumber("200", &char_result));
1269
+ errno = 0;
1270
+ }
1271
+
1272
+ TEST(ParseNaturalNumberTest, AcceptsValidNumbers) {
1273
+ BiggestParsable result = 0;
1274
+
1275
+ result = 0;
1276
+ ASSERT_TRUE(ParseNaturalNumber("123", &result));
1277
+ EXPECT_EQ(123U, result);
1278
+
1279
+ // Check 0 as an edge case.
1280
+ result = 1;
1281
+ ASSERT_TRUE(ParseNaturalNumber("0", &result));
1282
+ EXPECT_EQ(0U, result);
1283
+
1284
+ result = 1;
1285
+ ASSERT_TRUE(ParseNaturalNumber("00000", &result));
1286
+ EXPECT_EQ(0U, result);
1287
+ }
1288
+
1289
+ TEST(ParseNaturalNumberTest, AcceptsTypeLimits) {
1290
+ Message msg;
1291
+ msg << kBiggestParsableMax;
1292
+
1293
+ BiggestParsable result = 0;
1294
+ EXPECT_TRUE(ParseNaturalNumber(msg.GetString(), &result));
1295
+ EXPECT_EQ(kBiggestParsableMax, result);
1296
+
1297
+ Message msg2;
1298
+ msg2 << kBiggestSignedParsableMax;
1299
+
1300
+ BiggestSignedParsable signed_result = 0;
1301
+ EXPECT_TRUE(ParseNaturalNumber(msg2.GetString(), &signed_result));
1302
+ EXPECT_EQ(kBiggestSignedParsableMax, signed_result);
1303
+
1304
+ Message msg3;
1305
+ msg3 << INT_MAX;
1306
+
1307
+ int int_result = 0;
1308
+ EXPECT_TRUE(ParseNaturalNumber(msg3.GetString(), &int_result));
1309
+ EXPECT_EQ(INT_MAX, int_result);
1310
+
1311
+ Message msg4;
1312
+ msg4 << UINT_MAX;
1313
+
1314
+ unsigned int uint_result = 0;
1315
+ EXPECT_TRUE(ParseNaturalNumber(msg4.GetString(), &uint_result));
1316
+ EXPECT_EQ(UINT_MAX, uint_result);
1317
+ }
1318
+
1319
+ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) {
1320
+ short short_result = 0;
1321
+ ASSERT_TRUE(ParseNaturalNumber("123", &short_result));
1322
+ EXPECT_EQ(123, short_result);
1323
+
1324
+ signed char char_result = 0;
1325
+ ASSERT_TRUE(ParseNaturalNumber("123", &char_result));
1326
+ EXPECT_EQ(123, char_result);
1327
+ }
1328
+
1329
+ # if GTEST_OS_WINDOWS
1330
+ TEST(EnvironmentTest, HandleFitsIntoSizeT) {
1331
+ ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));
1332
+ }
1333
+ # endif // GTEST_OS_WINDOWS
1334
+
1335
+ // Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED trigger
1336
+ // failures when death tests are available on the system.
1337
+ TEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {
1338
+ EXPECT_DEATH_IF_SUPPORTED(DieInside("CondDeathTestExpectMacro"),
1339
+ "death inside CondDeathTestExpectMacro");
1340
+ ASSERT_DEATH_IF_SUPPORTED(DieInside("CondDeathTestAssertMacro"),
1341
+ "death inside CondDeathTestAssertMacro");
1342
+
1343
+ // Empty statement will not crash, which must trigger a failure.
1344
+ EXPECT_NONFATAL_FAILURE(EXPECT_DEATH_IF_SUPPORTED(;, ""), "");
1345
+ EXPECT_FATAL_FAILURE(ASSERT_DEATH_IF_SUPPORTED(;, ""), "");
1346
+ }
1347
+
1348
+ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
1349
+ testing::GTEST_FLAG(death_test_style) = "fast";
1350
+ EXPECT_FALSE(InDeathTestChild());
1351
+ EXPECT_DEATH({
1352
+ fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
1353
+ fflush(stderr);
1354
+ _exit(1);
1355
+ }, "Inside");
1356
+ }
1357
+
1358
+ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
1359
+ testing::GTEST_FLAG(death_test_style) = "threadsafe";
1360
+ EXPECT_FALSE(InDeathTestChild());
1361
+ EXPECT_DEATH({
1362
+ fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
1363
+ fflush(stderr);
1364
+ _exit(1);
1365
+ }, "Inside");
1366
+ }
1367
+
1368
+ void DieWithMessage(const char* message) {
1369
+ fputs(message, stderr);
1370
+ fflush(stderr); // Make sure the text is printed before the process exits.
1371
+ _exit(1);
1372
+ }
1373
+
1374
+ TEST(MatcherDeathTest, DoesNotBreakBareRegexMatching) {
1375
+ // googletest tests this, of course; here we ensure that including googlemock
1376
+ // has not broken it.
1377
+ EXPECT_DEATH(DieWithMessage("O, I die, Horatio."), "I d[aeiou]e");
1378
+ }
1379
+
1380
+ TEST(MatcherDeathTest, MonomorphicMatcherMatches) {
1381
+ EXPECT_DEATH(DieWithMessage("Behind O, I am slain!"),
1382
+ Matcher<const std::string&>(ContainsRegex("I am slain")));
1383
+ }
1384
+
1385
+ TEST(MatcherDeathTest, MonomorphicMatcherDoesNotMatch) {
1386
+ EXPECT_NONFATAL_FAILURE(
1387
+ EXPECT_DEATH(
1388
+ DieWithMessage("Behind O, I am slain!"),
1389
+ Matcher<const std::string&>(ContainsRegex("Ow, I am slain"))),
1390
+ "Expected: contains regular expression \"Ow, I am slain\"");
1391
+ }
1392
+
1393
+ TEST(MatcherDeathTest, PolymorphicMatcherMatches) {
1394
+ EXPECT_DEATH(DieWithMessage("The rest is silence."),
1395
+ ContainsRegex("rest is silence"));
1396
+ }
1397
+
1398
+ TEST(MatcherDeathTest, PolymorphicMatcherDoesNotMatch) {
1399
+ EXPECT_NONFATAL_FAILURE(
1400
+ EXPECT_DEATH(DieWithMessage("The rest is silence."),
1401
+ ContainsRegex("rest is science")),
1402
+ "Expected: contains regular expression \"rest is science\"");
1403
+ }
1404
+
1405
+ } // namespace
1406
+
1407
+ #else // !GTEST_HAS_DEATH_TEST follows
1408
+
1409
+ namespace {
1410
+
1411
+ using testing::internal::CaptureStderr;
1412
+ using testing::internal::GetCapturedStderr;
1413
+
1414
+ // Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED are still
1415
+ // defined but do not trigger failures when death tests are not available on
1416
+ // the system.
1417
+ TEST(ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable) {
1418
+ // Empty statement will not crash, but that should not trigger a failure
1419
+ // when death tests are not supported.
1420
+ CaptureStderr();
1421
+ EXPECT_DEATH_IF_SUPPORTED(;, "");
1422
+ std::string output = GetCapturedStderr();
1423
+ ASSERT_TRUE(NULL != strstr(output.c_str(),
1424
+ "Death tests are not supported on this platform"));
1425
+ ASSERT_TRUE(NULL != strstr(output.c_str(), ";"));
1426
+
1427
+ // The streamed message should not be printed as there is no test failure.
1428
+ CaptureStderr();
1429
+ EXPECT_DEATH_IF_SUPPORTED(;, "") << "streamed message";
1430
+ output = GetCapturedStderr();
1431
+ ASSERT_TRUE(NULL == strstr(output.c_str(), "streamed message"));
1432
+
1433
+ CaptureStderr();
1434
+ ASSERT_DEATH_IF_SUPPORTED(;, ""); // NOLINT
1435
+ output = GetCapturedStderr();
1436
+ ASSERT_TRUE(NULL != strstr(output.c_str(),
1437
+ "Death tests are not supported on this platform"));
1438
+ ASSERT_TRUE(NULL != strstr(output.c_str(), ";"));
1439
+
1440
+ CaptureStderr();
1441
+ ASSERT_DEATH_IF_SUPPORTED(;, "") << "streamed message"; // NOLINT
1442
+ output = GetCapturedStderr();
1443
+ ASSERT_TRUE(NULL == strstr(output.c_str(), "streamed message"));
1444
+ }
1445
+
1446
+ void FuncWithAssert(int* n) {
1447
+ ASSERT_DEATH_IF_SUPPORTED(return;, "");
1448
+ (*n)++;
1449
+ }
1450
+
1451
+ // Tests that ASSERT_DEATH_IF_SUPPORTED does not return from the current
1452
+ // function (as ASSERT_DEATH does) if death tests are not supported.
1453
+ TEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {
1454
+ int n = 0;
1455
+ FuncWithAssert(&n);
1456
+ EXPECT_EQ(1, n);
1457
+ }
1458
+
1459
+ } // namespace
1460
+
1461
+ #endif // !GTEST_HAS_DEATH_TEST
1462
+
1463
+ namespace {
1464
+
1465
+ // Tests that the death test macros expand to code which may or may not
1466
+ // be followed by operator<<, and that in either case the complete text
1467
+ // comprises only a single C++ statement.
1468
+ //
1469
+ // The syntax should work whether death tests are available or not.
1470
+ TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
1471
+ if (AlwaysFalse())
1472
+ // This would fail if executed; this is a compilation test only
1473
+ ASSERT_DEATH_IF_SUPPORTED(return, "");
1474
+
1475
+ if (AlwaysTrue())
1476
+ EXPECT_DEATH_IF_SUPPORTED(_exit(1), "");
1477
+ else
1478
+ // This empty "else" branch is meant to ensure that EXPECT_DEATH
1479
+ // doesn't expand into an "if" statement without an "else"
1480
+ ; // NOLINT
1481
+
1482
+ if (AlwaysFalse())
1483
+ ASSERT_DEATH_IF_SUPPORTED(return, "") << "did not die";
1484
+
1485
+ if (AlwaysFalse())
1486
+ ; // NOLINT
1487
+ else
1488
+ EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << 1 << 2 << 3;
1489
+ }
1490
+
1491
+ // Tests that conditional death test macros expand to code which interacts
1492
+ // well with switch statements.
1493
+ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
1494
+ // Microsoft compiler usually complains about switch statements without
1495
+ // case labels. We suppress that warning for this test.
1496
+ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4065)
1497
+
1498
+ switch (0)
1499
+ default:
1500
+ ASSERT_DEATH_IF_SUPPORTED(_exit(1), "")
1501
+ << "exit in default switch handler";
1502
+
1503
+ switch (0)
1504
+ case 0:
1505
+ EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in switch case";
1506
+
1507
+ GTEST_DISABLE_MSC_WARNINGS_POP_()
1508
+ }
1509
+
1510
+ // Tests that a test case whose name ends with "DeathTest" works fine
1511
+ // on Windows.
1512
+ TEST(NotADeathTest, Test) {
1513
+ SUCCEED();
1514
+ }
1515
+
1516
+ } // namespace