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.
- package/LICENSE +21 -0
- package/README.md +92 -0
- package/android/.project +34 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/CMakeLists.txt +69 -0
- package/android/build.gradle +125 -0
- package/android/cpp-adapter.cpp +19 -0
- package/android/gradle.properties +6 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativeleveldb/LeveldbModule.java +57 -0
- package/android/src/main/java/com/reactnativeleveldb/LeveldbPackage.java +28 -0
- package/cpp/leveldb/.appveyor.yml +36 -0
- package/cpp/leveldb/.clang-format +18 -0
- package/cpp/leveldb/.travis.yml +88 -0
- package/cpp/leveldb/AUTHORS +12 -0
- package/cpp/leveldb/CMakeLists.txt +495 -0
- package/cpp/leveldb/CONTRIBUTING.md +36 -0
- package/cpp/leveldb/LICENSE +27 -0
- package/cpp/leveldb/NEWS +17 -0
- package/cpp/leveldb/README.md +231 -0
- package/cpp/leveldb/TODO +14 -0
- package/cpp/leveldb/benchmarks/db_bench.cc +990 -0
- package/cpp/leveldb/benchmarks/db_bench_sqlite3.cc +726 -0
- package/cpp/leveldb/benchmarks/db_bench_tree_db.cc +531 -0
- package/cpp/leveldb/cmake/leveldbConfig.cmake.in +9 -0
- package/cpp/leveldb/db/autocompact_test.cc +115 -0
- package/cpp/leveldb/db/builder.cc +82 -0
- package/cpp/leveldb/db/builder.h +30 -0
- package/cpp/leveldb/db/c.cc +562 -0
- package/cpp/leveldb/db/c_test.c +384 -0
- package/cpp/leveldb/db/corruption_test.cc +367 -0
- package/cpp/leveldb/db/db_impl.cc +1554 -0
- package/cpp/leveldb/db/db_impl.h +217 -0
- package/cpp/leveldb/db/db_iter.cc +318 -0
- package/cpp/leveldb/db/db_iter.h +26 -0
- package/cpp/leveldb/db/db_test.cc +2305 -0
- package/cpp/leveldb/db/dbformat.cc +136 -0
- package/cpp/leveldb/db/dbformat.h +224 -0
- package/cpp/leveldb/db/dbformat_test.cc +133 -0
- package/cpp/leveldb/db/dumpfile.cc +232 -0
- package/cpp/leveldb/db/fault_injection_test.cc +555 -0
- package/cpp/leveldb/db/filename.cc +141 -0
- package/cpp/leveldb/db/filename.h +83 -0
- package/cpp/leveldb/db/filename_test.cc +132 -0
- package/cpp/leveldb/db/leveldbutil.cc +64 -0
- package/cpp/leveldb/db/log_format.h +35 -0
- package/cpp/leveldb/db/log_reader.cc +274 -0
- package/cpp/leveldb/db/log_reader.h +112 -0
- package/cpp/leveldb/db/log_test.cc +563 -0
- package/cpp/leveldb/db/log_writer.cc +111 -0
- package/cpp/leveldb/db/log_writer.h +54 -0
- package/cpp/leveldb/db/memtable.cc +137 -0
- package/cpp/leveldb/db/memtable.h +87 -0
- package/cpp/leveldb/db/recovery_test.cc +339 -0
- package/cpp/leveldb/db/repair.cc +451 -0
- package/cpp/leveldb/db/skiplist.h +382 -0
- package/cpp/leveldb/db/skiplist_test.cc +373 -0
- package/cpp/leveldb/db/snapshot.h +95 -0
- package/cpp/leveldb/db/table_cache.cc +120 -0
- package/cpp/leveldb/db/table_cache.h +57 -0
- package/cpp/leveldb/db/version_edit.cc +257 -0
- package/cpp/leveldb/db/version_edit.h +106 -0
- package/cpp/leveldb/db/version_edit_test.cc +46 -0
- package/cpp/leveldb/db/version_set.cc +1562 -0
- package/cpp/leveldb/db/version_set.h +393 -0
- package/cpp/leveldb/db/version_set_test.cc +336 -0
- package/cpp/leveldb/db/write_batch.cc +150 -0
- package/cpp/leveldb/db/write_batch_internal.h +45 -0
- package/cpp/leveldb/db/write_batch_test.cc +137 -0
- package/cpp/leveldb/doc/benchmark.html +459 -0
- package/cpp/leveldb/doc/impl.md +172 -0
- package/cpp/leveldb/doc/index.md +523 -0
- package/cpp/leveldb/doc/log_format.md +75 -0
- package/cpp/leveldb/doc/table_format.md +107 -0
- package/cpp/leveldb/helpers/memenv/memenv.cc +390 -0
- package/cpp/leveldb/helpers/memenv/memenv.h +22 -0
- package/cpp/leveldb/helpers/memenv/memenv_test.cc +264 -0
- package/cpp/leveldb/include/leveldb/c.h +270 -0
- package/cpp/leveldb/include/leveldb/cache.h +111 -0
- package/cpp/leveldb/include/leveldb/comparator.h +64 -0
- package/cpp/leveldb/include/leveldb/db.h +167 -0
- package/cpp/leveldb/include/leveldb/dumpfile.h +28 -0
- package/cpp/leveldb/include/leveldb/env.h +417 -0
- package/cpp/leveldb/include/leveldb/export.h +33 -0
- package/cpp/leveldb/include/leveldb/filter_policy.h +72 -0
- package/cpp/leveldb/include/leveldb/iterator.h +112 -0
- package/cpp/leveldb/include/leveldb/options.h +187 -0
- package/cpp/leveldb/include/leveldb/slice.h +114 -0
- package/cpp/leveldb/include/leveldb/status.h +122 -0
- package/cpp/leveldb/include/leveldb/table.h +84 -0
- package/cpp/leveldb/include/leveldb/table_builder.h +93 -0
- package/cpp/leveldb/include/leveldb/write_batch.h +83 -0
- package/cpp/leveldb/issues/issue178_test.cc +90 -0
- package/cpp/leveldb/issues/issue200_test.cc +59 -0
- package/cpp/leveldb/issues/issue320_test.cc +131 -0
- package/cpp/leveldb/port/README.md +10 -0
- package/cpp/leveldb/port/port.h +19 -0
- package/cpp/leveldb/port/port_config.h.in +33 -0
- package/cpp/leveldb/port/port_example.h +100 -0
- package/cpp/leveldb/port/port_stdcxx.h +151 -0
- package/cpp/leveldb/port/thread_annotations.h +108 -0
- package/cpp/leveldb/table/block.cc +267 -0
- package/cpp/leveldb/table/block.h +44 -0
- package/cpp/leveldb/table/block_builder.cc +107 -0
- package/cpp/leveldb/table/block_builder.h +54 -0
- package/cpp/leveldb/table/filter_block.cc +106 -0
- package/cpp/leveldb/table/filter_block.h +68 -0
- package/cpp/leveldb/table/filter_block_test.cc +127 -0
- package/cpp/leveldb/table/format.cc +141 -0
- package/cpp/leveldb/table/format.h +99 -0
- package/cpp/leveldb/table/iterator.cc +76 -0
- package/cpp/leveldb/table/iterator_wrapper.h +92 -0
- package/cpp/leveldb/table/merger.cc +191 -0
- package/cpp/leveldb/table/merger.h +26 -0
- package/cpp/leveldb/table/table.cc +271 -0
- package/cpp/leveldb/table/table_builder.cc +265 -0
- package/cpp/leveldb/table/table_test.cc +834 -0
- package/cpp/leveldb/table/two_level_iterator.cc +171 -0
- package/cpp/leveldb/table/two_level_iterator.h +31 -0
- package/cpp/leveldb/third_party/benchmark/.clang-format +5 -0
- package/cpp/leveldb/third_party/benchmark/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- package/cpp/leveldb/third_party/benchmark/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/cpp/leveldb/third_party/benchmark/.github/workflows/build-and-test.yml +38 -0
- package/cpp/leveldb/third_party/benchmark/.github/workflows/pylint.yml +26 -0
- package/cpp/leveldb/third_party/benchmark/.github/workflows/test_bindings.yml +24 -0
- package/cpp/leveldb/third_party/benchmark/.travis-libcxx-setup.sh +28 -0
- package/cpp/leveldb/third_party/benchmark/.travis.yml +231 -0
- package/cpp/leveldb/third_party/benchmark/.ycm_extra_conf.py +115 -0
- package/cpp/leveldb/third_party/benchmark/AUTHORS +58 -0
- package/cpp/leveldb/third_party/benchmark/BUILD.bazel +44 -0
- package/cpp/leveldb/third_party/benchmark/CMakeLists.txt +287 -0
- package/cpp/leveldb/third_party/benchmark/CONTRIBUTING.md +58 -0
- package/cpp/leveldb/third_party/benchmark/CONTRIBUTORS +83 -0
- package/cpp/leveldb/third_party/benchmark/LICENSE +202 -0
- package/cpp/leveldb/third_party/benchmark/README.md +1323 -0
- package/cpp/leveldb/third_party/benchmark/WORKSPACE +51 -0
- package/cpp/leveldb/third_party/benchmark/_config.yml +1 -0
- package/cpp/leveldb/third_party/benchmark/appveyor.yml +50 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/BUILD +3 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/build_defs.bzl +25 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/BUILD +38 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/__init__.py +156 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/benchmark.cc +180 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/google_benchmark/example.py +136 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/pybind11.BUILD +20 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/python_headers.BUILD +6 -0
- package/cpp/leveldb/third_party/benchmark/bindings/python/requirements.txt +2 -0
- package/cpp/leveldb/third_party/benchmark/cmake/AddCXXCompilerFlag.cmake +74 -0
- package/cpp/leveldb/third_party/benchmark/cmake/CXXFeatureCheck.cmake +69 -0
- package/cpp/leveldb/third_party/benchmark/cmake/Config.cmake.in +1 -0
- package/cpp/leveldb/third_party/benchmark/cmake/GetGitVersion.cmake +54 -0
- package/cpp/leveldb/third_party/benchmark/cmake/GoogleTest.cmake +41 -0
- package/cpp/leveldb/third_party/benchmark/cmake/GoogleTest.cmake.in +58 -0
- package/cpp/leveldb/third_party/benchmark/cmake/benchmark.pc.in +12 -0
- package/cpp/leveldb/third_party/benchmark/cmake/gnu_posix_regex.cpp +12 -0
- package/cpp/leveldb/third_party/benchmark/cmake/llvm-toolchain.cmake +8 -0
- package/cpp/leveldb/third_party/benchmark/cmake/posix_regex.cpp +14 -0
- package/cpp/leveldb/third_party/benchmark/cmake/split_list.cmake +3 -0
- package/cpp/leveldb/third_party/benchmark/cmake/std_regex.cpp +10 -0
- package/cpp/leveldb/third_party/benchmark/cmake/steady_clock.cpp +7 -0
- package/cpp/leveldb/third_party/benchmark/cmake/thread_safety_attributes.cpp +4 -0
- package/cpp/leveldb/third_party/benchmark/conan/CMakeLists.txt +7 -0
- package/cpp/leveldb/third_party/benchmark/conan/test_package/CMakeLists.txt +10 -0
- package/cpp/leveldb/third_party/benchmark/conan/test_package/conanfile.py +19 -0
- package/cpp/leveldb/third_party/benchmark/conan/test_package/test_package.cpp +18 -0
- package/cpp/leveldb/third_party/benchmark/conanfile.py +79 -0
- package/cpp/leveldb/third_party/benchmark/dependencies.md +18 -0
- package/cpp/leveldb/third_party/benchmark/docs/AssemblyTests.md +147 -0
- package/cpp/leveldb/third_party/benchmark/docs/_config.yml +1 -0
- package/cpp/leveldb/third_party/benchmark/docs/releasing.md +16 -0
- package/cpp/leveldb/third_party/benchmark/docs/tools.md +203 -0
- package/cpp/leveldb/third_party/benchmark/include/benchmark/benchmark.h +1604 -0
- package/cpp/leveldb/third_party/benchmark/requirements.txt +2 -0
- package/cpp/leveldb/third_party/benchmark/setup.py +140 -0
- package/cpp/leveldb/third_party/benchmark/src/CMakeLists.txt +114 -0
- package/cpp/leveldb/third_party/benchmark/src/arraysize.h +33 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark.cc +499 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_api_internal.cc +15 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_api_internal.h +53 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_main.cc +17 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_name.cc +58 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_register.cc +515 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_register.h +108 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_runner.cc +362 -0
- package/cpp/leveldb/third_party/benchmark/src/benchmark_runner.h +51 -0
- package/cpp/leveldb/third_party/benchmark/src/check.h +82 -0
- package/cpp/leveldb/third_party/benchmark/src/colorprint.cc +188 -0
- package/cpp/leveldb/third_party/benchmark/src/colorprint.h +33 -0
- package/cpp/leveldb/third_party/benchmark/src/commandlineflags.cc +228 -0
- package/cpp/leveldb/third_party/benchmark/src/commandlineflags.h +103 -0
- package/cpp/leveldb/third_party/benchmark/src/complexity.cc +238 -0
- package/cpp/leveldb/third_party/benchmark/src/complexity.h +55 -0
- package/cpp/leveldb/third_party/benchmark/src/console_reporter.cc +177 -0
- package/cpp/leveldb/third_party/benchmark/src/counter.cc +80 -0
- package/cpp/leveldb/third_party/benchmark/src/counter.h +32 -0
- package/cpp/leveldb/third_party/benchmark/src/csv_reporter.cc +154 -0
- package/cpp/leveldb/third_party/benchmark/src/cycleclock.h +211 -0
- package/cpp/leveldb/third_party/benchmark/src/internal_macros.h +102 -0
- package/cpp/leveldb/third_party/benchmark/src/json_reporter.cc +255 -0
- package/cpp/leveldb/third_party/benchmark/src/log.h +74 -0
- package/cpp/leveldb/third_party/benchmark/src/mutex.h +155 -0
- package/cpp/leveldb/third_party/benchmark/src/re.h +158 -0
- package/cpp/leveldb/third_party/benchmark/src/reporter.cc +105 -0
- package/cpp/leveldb/third_party/benchmark/src/sleep.cc +67 -0
- package/cpp/leveldb/third_party/benchmark/src/sleep.h +15 -0
- package/cpp/leveldb/third_party/benchmark/src/statistics.cc +193 -0
- package/cpp/leveldb/third_party/benchmark/src/statistics.h +37 -0
- package/cpp/leveldb/third_party/benchmark/src/string_util.cc +255 -0
- package/cpp/leveldb/third_party/benchmark/src/string_util.h +59 -0
- package/cpp/leveldb/third_party/benchmark/src/sysinfo.cc +716 -0
- package/cpp/leveldb/third_party/benchmark/src/thread_manager.h +64 -0
- package/cpp/leveldb/third_party/benchmark/src/thread_timer.h +86 -0
- package/cpp/leveldb/third_party/benchmark/src/timers.cc +245 -0
- package/cpp/leveldb/third_party/benchmark/src/timers.h +48 -0
- package/cpp/leveldb/third_party/benchmark/test/AssemblyTests.cmake +46 -0
- package/cpp/leveldb/third_party/benchmark/test/BUILD +73 -0
- package/cpp/leveldb/third_party/benchmark/test/CMakeLists.txt +263 -0
- package/cpp/leveldb/third_party/benchmark/test/args_product_test.cc +77 -0
- package/cpp/leveldb/third_party/benchmark/test/basic_test.cc +136 -0
- package/cpp/leveldb/third_party/benchmark/test/benchmark_gtest.cc +134 -0
- package/cpp/leveldb/third_party/benchmark/test/benchmark_name_gtest.cc +74 -0
- package/cpp/leveldb/third_party/benchmark/test/benchmark_test.cc +245 -0
- package/cpp/leveldb/third_party/benchmark/test/clobber_memory_assembly_test.cc +64 -0
- package/cpp/leveldb/third_party/benchmark/test/commandlineflags_gtest.cc +201 -0
- package/cpp/leveldb/third_party/benchmark/test/complexity_test.cc +213 -0
- package/cpp/leveldb/third_party/benchmark/test/cxx03_test.cc +63 -0
- package/cpp/leveldb/third_party/benchmark/test/diagnostics_test.cc +80 -0
- package/cpp/leveldb/third_party/benchmark/test/display_aggregates_only_test.cc +43 -0
- package/cpp/leveldb/third_party/benchmark/test/donotoptimize_assembly_test.cc +163 -0
- package/cpp/leveldb/third_party/benchmark/test/donotoptimize_test.cc +52 -0
- package/cpp/leveldb/third_party/benchmark/test/filter_test.cc +104 -0
- package/cpp/leveldb/third_party/benchmark/test/fixture_test.cc +51 -0
- package/cpp/leveldb/third_party/benchmark/test/internal_threading_test.cc +184 -0
- package/cpp/leveldb/third_party/benchmark/test/link_main_test.cc +8 -0
- package/cpp/leveldb/third_party/benchmark/test/map_test.cc +57 -0
- package/cpp/leveldb/third_party/benchmark/test/memory_manager_test.cc +44 -0
- package/cpp/leveldb/third_party/benchmark/test/multiple_ranges_test.cc +96 -0
- package/cpp/leveldb/third_party/benchmark/test/options_test.cc +75 -0
- package/cpp/leveldb/third_party/benchmark/test/output_test.h +213 -0
- package/cpp/leveldb/third_party/benchmark/test/output_test_helper.cc +515 -0
- package/cpp/leveldb/third_party/benchmark/test/register_benchmark_test.cc +184 -0
- package/cpp/leveldb/third_party/benchmark/test/report_aggregates_only_test.cc +39 -0
- package/cpp/leveldb/third_party/benchmark/test/reporter_output_test.cc +747 -0
- package/cpp/leveldb/third_party/benchmark/test/skip_with_error_test.cc +195 -0
- package/cpp/leveldb/third_party/benchmark/test/state_assembly_test.cc +68 -0
- package/cpp/leveldb/third_party/benchmark/test/statistics_gtest.cc +28 -0
- package/cpp/leveldb/third_party/benchmark/test/string_util_gtest.cc +153 -0
- package/cpp/leveldb/third_party/benchmark/test/templated_fixture_test.cc +28 -0
- package/cpp/leveldb/third_party/benchmark/test/user_counters_tabular_test.cc +285 -0
- package/cpp/leveldb/third_party/benchmark/test/user_counters_test.cc +531 -0
- package/cpp/leveldb/third_party/benchmark/test/user_counters_thousands_test.cc +173 -0
- package/cpp/leveldb/third_party/benchmark/tools/BUILD.bazel +19 -0
- package/cpp/leveldb/third_party/benchmark/tools/compare.py +429 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test1_run1.json +119 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test1_run2.json +119 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test2_run.json +81 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test3_run0.json +65 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/Inputs/test3_run1.json +65 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/__init__.py +8 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/report.py +903 -0
- package/cpp/leveldb/third_party/benchmark/tools/gbench/util.py +163 -0
- package/cpp/leveldb/third_party/benchmark/tools/requirements.txt +1 -0
- package/cpp/leveldb/third_party/benchmark/tools/strip_asm.py +151 -0
- package/cpp/leveldb/third_party/googletest/.clang-format +4 -0
- package/cpp/leveldb/third_party/googletest/.travis.yml +73 -0
- package/cpp/leveldb/third_party/googletest/BUILD.bazel +179 -0
- package/cpp/leveldb/third_party/googletest/CMakeLists.txt +36 -0
- package/cpp/leveldb/third_party/googletest/CONTRIBUTING.md +142 -0
- package/cpp/leveldb/third_party/googletest/LICENSE +28 -0
- package/cpp/leveldb/third_party/googletest/README.md +132 -0
- package/cpp/leveldb/third_party/googletest/WORKSPACE +23 -0
- package/cpp/leveldb/third_party/googletest/appveyor.yml +154 -0
- package/cpp/leveldb/third_party/googletest/ci/build-linux-bazel.sh +37 -0
- package/cpp/leveldb/third_party/googletest/ci/build-platformio.sh +2 -0
- package/cpp/leveldb/third_party/googletest/ci/env-linux.sh +41 -0
- package/cpp/leveldb/third_party/googletest/ci/env-osx.sh +47 -0
- package/cpp/leveldb/third_party/googletest/ci/get-nprocessors.sh +48 -0
- package/cpp/leveldb/third_party/googletest/ci/install-linux.sh +49 -0
- package/cpp/leveldb/third_party/googletest/ci/install-osx.sh +40 -0
- package/cpp/leveldb/third_party/googletest/ci/install-platformio.sh +5 -0
- package/cpp/leveldb/third_party/googletest/ci/log-config.sh +51 -0
- package/cpp/leveldb/third_party/googletest/ci/travis.sh +44 -0
- package/cpp/leveldb/third_party/googletest/googlemock/CMakeLists.txt +233 -0
- package/cpp/leveldb/third_party/googletest/googlemock/CONTRIBUTORS +40 -0
- package/cpp/leveldb/third_party/googletest/googlemock/LICENSE +28 -0
- package/cpp/leveldb/third_party/googletest/googlemock/README.md +44 -0
- package/cpp/leveldb/third_party/googletest/googlemock/cmake/gmock.pc.in +10 -0
- package/cpp/leveldb/third_party/googletest/googlemock/cmake/gmock_main.pc.in +10 -0
- package/cpp/leveldb/third_party/googletest/googlemock/docs/cheat_sheet.md +770 -0
- package/cpp/leveldb/third_party/googletest/googlemock/docs/cook_book.md +4270 -0
- package/cpp/leveldb/third_party/googletest/googlemock/docs/for_dummies.md +700 -0
- package/cpp/leveldb/third_party/googletest/googlemock/docs/gmock_faq.md +396 -0
- package/cpp/leveldb/third_party/googletest/googlemock/docs/pump_manual.md +187 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-actions.h +1193 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-cardinalities.h +157 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-function-mocker.h +276 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h +1884 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h.pump +627 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h +752 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-function-mockers.h.pump +227 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-matchers.h +1097 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-generated-matchers.h.pump +346 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-matchers.h +4591 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-more-actions.h +162 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-more-matchers.h +92 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-nice-strict.h +215 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock-spec-builders.h +1985 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/gmock.h +101 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/README.md +16 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +10 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +12 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-matchers.h +36 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-port.h +39 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h +472 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-port.h +87 -0
- package/cpp/leveldb/third_party/googletest/googlemock/include/gmock/internal/gmock-pp.h +271 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/README.md +5 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/fuse_gmock_files.py +240 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/LICENSE +203 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/README +34 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/README.cppclean +115 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/__init__.py +0 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/ast.py +1761 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py +248 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class_test.py +540 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/keywords.py +56 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/tokenize.py +284 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/cpp/utils.py +37 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/generator/gmock_gen.py +30 -0
- package/cpp/leveldb/third_party/googletest/googlemock/scripts/pump.py +856 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-all.cc +46 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-cardinalities.cc +155 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-internal-utils.cc +200 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-matchers.cc +462 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock-spec-builders.cc +892 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock.cc +213 -0
- package/cpp/leveldb/third_party/googletest/googlemock/src/gmock_main.cc +72 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/BUILD.bazel +110 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-actions_test.cc +1507 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-cardinalities_test.cc +429 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_nc.cc +16 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_nc_test.py +43 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc +696 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-actions_test.cc +1064 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-function-mockers_test.cc +659 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-generated-matchers_test.cc +1323 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-internal-utils_test.cc +732 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-matchers_test.cc +6913 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-more-actions_test.cc +698 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-nice-strict_test.cc +500 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-port_test.cc +42 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-pp-string_test.cc +206 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-pp_test.cc +83 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock-spec-builders_test.cc +2775 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_all_test.cc +49 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_ex_test.cc +80 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_leak_test.py +104 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_leak_test_.cc +99 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link2_test.cc +39 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link_test.cc +39 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_link_test.h +690 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test.py +183 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test_.cc +309 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_output_test_golden.txt +317 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_stress_test.cc +240 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_test.cc +181 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/gmock_test_utils.py +108 -0
- package/cpp/leveldb/third_party/googletest/googlemock/test/pump_test.py +182 -0
- package/cpp/leveldb/third_party/googletest/googletest/CMakeLists.txt +329 -0
- package/cpp/leveldb/third_party/googletest/googletest/CONTRIBUTORS +38 -0
- package/cpp/leveldb/third_party/googletest/googletest/LICENSE +28 -0
- package/cpp/leveldb/third_party/googletest/googletest/README.md +244 -0
- package/cpp/leveldb/third_party/googletest/googletest/cmake/Config.cmake.in +9 -0
- package/cpp/leveldb/third_party/googletest/googletest/cmake/gtest.pc.in +9 -0
- package/cpp/leveldb/third_party/googletest/googletest/cmake/gtest_main.pc.in +10 -0
- package/cpp/leveldb/third_party/googletest/googletest/cmake/internal_utils.cmake +358 -0
- package/cpp/leveldb/third_party/googletest/googletest/cmake/libgtest.la.in +21 -0
- package/cpp/leveldb/third_party/googletest/googletest/docs/advanced.md +2567 -0
- package/cpp/leveldb/third_party/googletest/googletest/docs/faq.md +753 -0
- package/cpp/leveldb/third_party/googletest/googletest/docs/pkgconfig.md +219 -0
- package/cpp/leveldb/third_party/googletest/googletest/docs/primer.md +579 -0
- package/cpp/leveldb/third_party/googletest/googletest/docs/samples.md +22 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-death-test.h +343 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-matchers.h +750 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-message.h +219 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-param-test.h +514 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-printers.h +928 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-spi.h +238 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-test-part.h +184 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest-typed-test.h +337 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest.h +2477 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest_pred_impl.h +359 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/gtest_prod.h +61 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/README.md +56 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest-port.h +37 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/custom/gtest.h +37 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h +304 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-filepath.h +211 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h +1411 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-param-util.h +880 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-port-arch.h +111 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-port.h +2227 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-string.h +171 -0
- package/cpp/leveldb/third_party/googletest/googletest/include/gtest/internal/gtest-type-util.h +183 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/prime_tables.h +126 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample1.cc +66 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample1.h +41 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample10_unittest.cc +139 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample1_unittest.cc +151 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample2.cc +54 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample2.h +81 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample2_unittest.cc +107 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample3-inl.h +172 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample3_unittest.cc +149 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample4.cc +54 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample4.h +53 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample4_unittest.cc +53 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample5_unittest.cc +196 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample6_unittest.cc +224 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample7_unittest.cc +117 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample8_unittest.cc +154 -0
- package/cpp/leveldb/third_party/googletest/googletest/samples/sample9_unittest.cc +156 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/README.md +5 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/common.py +83 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/fuse_gtest_files.py +253 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/gen_gtest_pred_impl.py +734 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/gtest-config.in +274 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/release_docs.py +158 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/run_with_path.py +32 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/upload.py +1402 -0
- package/cpp/leveldb/third_party/googletest/googletest/scripts/upload_gtest.py +78 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-all.cc +48 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-death-test.cc +1653 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-filepath.cc +382 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-internal-inl.h +1211 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-matchers.cc +97 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-port.cc +1399 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-printers.cc +442 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-test-part.cc +108 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest-typed-test.cc +118 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest.cc +6180 -0
- package/cpp/leveldb/third_party/googletest/googletest/src/gtest_main.cc +54 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/BUILD.bazel +529 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py +208 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-break-on-failure-unittest_.cc +86 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-catch-exceptions-test.py +236 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-catch-exceptions-test_.cc +293 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-color-test.py +127 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-color-test_.cc +62 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-death-test-test.cc +1516 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-death-test_ex_test.cc +92 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-env-var-test.py +117 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-env-var-test_.cc +122 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filepath-test.cc +649 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filter-unittest.py +639 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-filter-unittest_.cc +137 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-json-outfiles-test.py +191 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-json-output-unittest.py +778 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-list-tests-unittest.py +205 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-list-tests-unittest_.cc +156 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-listener-test.cc +518 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-message-test.cc +158 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-options-test.cc +216 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test-golden-lin.txt +1137 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test.py +346 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-output-test_.cc +1149 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test.py +63 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test_.cc +50 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test.py +62 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test_.cc +55 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-test.cc +1086 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test-test.h +51 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-param-test2-test.cc +61 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-port-test.cc +1272 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-printers-test.cc +1619 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-shuffle-test.py +323 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-shuffle-test_.cc +101 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-test-part-test.cc +230 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-test2_test.cc +61 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-throw-on-failure-test.py +168 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-throw-on-failure-test_.cc +71 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-uninitialized-test.py +67 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/googletest-uninitialized-test_.cc +42 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test2_test.cc +44 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test_test.cc +462 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest-typed-test_test.h +65 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest-unittest-api_test.cc +341 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_all_test.cc +46 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_assert_by_exception_test.cc +116 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_environment_test.cc +188 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_help_test.py +170 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_help_test_.cc +45 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_json_test_utils.py +60 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_list_output_unittest.py +141 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_list_output_unittest_.cc +51 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_main_unittest.cc +44 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_no_test_unittest.cc +54 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_pred_impl_unittest.cc +2427 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_premature_exit_test.cc +126 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_prod_test.cc +56 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_repeat_test.cc +233 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_check_output_test.py +59 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_environment_check_output_test.py +54 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc +49 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_skip_test.cc +55 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_sole_header_test.cc +56 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_stress_test.cc +248 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_test_macro_stack_footprint_test.cc +89 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_test_utils.py +314 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_testbridge_test.py +63 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_testbridge_test_.cc +43 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_throw_on_failure_ex_test.cc +90 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_unittest.cc +7496 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfile1_test_.cc +43 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfile2_test_.cc +43 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_outfiles_test.py +135 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_output_unittest.py +389 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_output_unittest_.cc +188 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/gtest_xml_test_utils.py +196 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/production.cc +35 -0
- package/cpp/leveldb/third_party/googletest/googletest/test/production.h +54 -0
- package/cpp/leveldb/third_party/googletest/library.json +66 -0
- package/cpp/leveldb/third_party/googletest/platformio.ini +47 -0
- package/cpp/leveldb/util/arena.cc +66 -0
- package/cpp/leveldb/util/arena.h +71 -0
- package/cpp/leveldb/util/arena_test.cc +66 -0
- package/cpp/leveldb/util/bloom.cc +92 -0
- package/cpp/leveldb/util/bloom_test.cc +159 -0
- package/cpp/leveldb/util/cache.cc +401 -0
- package/cpp/leveldb/util/cache_test.cc +229 -0
- package/cpp/leveldb/util/coding.cc +166 -0
- package/cpp/leveldb/util/coding.h +122 -0
- package/cpp/leveldb/util/coding_test.cc +198 -0
- package/cpp/leveldb/util/comparator.cc +75 -0
- package/cpp/leveldb/util/crc32c.cc +380 -0
- package/cpp/leveldb/util/crc32c.h +43 -0
- package/cpp/leveldb/util/crc32c_test.cc +61 -0
- package/cpp/leveldb/util/env.cc +108 -0
- package/cpp/leveldb/util/env_posix.cc +893 -0
- package/cpp/leveldb/util/env_posix_test.cc +353 -0
- package/cpp/leveldb/util/env_posix_test_helper.h +28 -0
- package/cpp/leveldb/util/env_test.cc +240 -0
- package/cpp/leveldb/util/env_windows.cc +796 -0
- package/cpp/leveldb/util/env_windows_test.cc +65 -0
- package/cpp/leveldb/util/env_windows_test_helper.h +25 -0
- package/cpp/leveldb/util/filter_policy.cc +11 -0
- package/cpp/leveldb/util/hash.cc +55 -0
- package/cpp/leveldb/util/hash.h +19 -0
- package/cpp/leveldb/util/hash_test.cc +46 -0
- package/cpp/leveldb/util/histogram.cc +272 -0
- package/cpp/leveldb/util/histogram.h +44 -0
- package/cpp/leveldb/util/logging.cc +82 -0
- package/cpp/leveldb/util/logging.h +44 -0
- package/cpp/leveldb/util/logging_test.cc +145 -0
- package/cpp/leveldb/util/mutexlock.h +39 -0
- package/cpp/leveldb/util/no_destructor.h +46 -0
- package/cpp/leveldb/util/no_destructor_test.cc +49 -0
- package/cpp/leveldb/util/options.cc +14 -0
- package/cpp/leveldb/util/posix_logger.h +130 -0
- package/cpp/leveldb/util/random.h +63 -0
- package/cpp/leveldb/util/status.cc +77 -0
- package/cpp/leveldb/util/status_test.cc +44 -0
- package/cpp/leveldb/util/testutil.cc +51 -0
- package/cpp/leveldb/util/testutil.h +82 -0
- package/cpp/leveldb/util/windows_logger.h +124 -0
- package/cpp/react-native-leveldb.cpp +694 -0
- package/cpp/react-native-leveldb.h +4 -0
- package/ios/Leveldb.h +9 -0
- package/ios/Leveldb.mm +35 -0
- package/ios/Leveldb.xcodeproj/project.pbxproj +288 -0
- package/lib/commonjs/fake.js +181 -0
- package/lib/commonjs/fake.js.map +1 -0
- package/lib/commonjs/fake.test.js +30 -0
- package/lib/commonjs/fake.test.js.map +1 -0
- package/lib/commonjs/index.js +172 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/fake.js +171 -0
- package/lib/module/fake.js.map +1 -0
- package/lib/module/fake.test.js +30 -0
- package/lib/module/fake.test.js.map +1 -0
- package/lib/module/index.js +165 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/fake.d.ts +34 -0
- package/lib/typescript/fake.d.ts.map +1 -0
- package/lib/typescript/fake.test.d.ts +2 -0
- package/lib/typescript/fake.test.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +72 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +157 -0
- package/rn-leveldb.podspec +30 -0
- package/src/fake.test.ts +37 -0
- package/src/fake.ts +203 -0
- package/src/index.ts +291 -0
|
@@ -0,0 +1,1619 @@
|
|
|
1
|
+
// Copyright 2007, Google Inc.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// Redistribution and use in source and binary forms, with or without
|
|
5
|
+
// modification, are permitted provided that the following conditions are
|
|
6
|
+
// met:
|
|
7
|
+
//
|
|
8
|
+
// * Redistributions of source code must retain the above copyright
|
|
9
|
+
// notice, this list of conditions and the following disclaimer.
|
|
10
|
+
// * Redistributions in binary form must reproduce the above
|
|
11
|
+
// copyright notice, this list of conditions and the following disclaimer
|
|
12
|
+
// in the documentation and/or other materials provided with the
|
|
13
|
+
// distribution.
|
|
14
|
+
// * Neither the name of Google Inc. nor the names of its
|
|
15
|
+
// contributors may be used to endorse or promote products derived from
|
|
16
|
+
// this software without specific prior written permission.
|
|
17
|
+
//
|
|
18
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
22
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
23
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
24
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
25
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
26
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// Google Test - The Google C++ Testing and Mocking Framework
|
|
32
|
+
//
|
|
33
|
+
// This file tests the universal value printer.
|
|
34
|
+
|
|
35
|
+
#include <ctype.h>
|
|
36
|
+
#include <limits.h>
|
|
37
|
+
#include <string.h>
|
|
38
|
+
#include <algorithm>
|
|
39
|
+
#include <deque>
|
|
40
|
+
#include <forward_list>
|
|
41
|
+
#include <list>
|
|
42
|
+
#include <map>
|
|
43
|
+
#include <set>
|
|
44
|
+
#include <sstream>
|
|
45
|
+
#include <string>
|
|
46
|
+
#include <unordered_map>
|
|
47
|
+
#include <unordered_set>
|
|
48
|
+
#include <utility>
|
|
49
|
+
#include <vector>
|
|
50
|
+
|
|
51
|
+
#include "gtest/gtest-printers.h"
|
|
52
|
+
#include "gtest/gtest.h"
|
|
53
|
+
|
|
54
|
+
// Some user-defined types for testing the universal value printer.
|
|
55
|
+
|
|
56
|
+
// An anonymous enum type.
|
|
57
|
+
enum AnonymousEnum {
|
|
58
|
+
kAE1 = -1,
|
|
59
|
+
kAE2 = 1
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// An enum without a user-defined printer.
|
|
63
|
+
enum EnumWithoutPrinter {
|
|
64
|
+
kEWP1 = -2,
|
|
65
|
+
kEWP2 = 42
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// An enum with a << operator.
|
|
69
|
+
enum EnumWithStreaming {
|
|
70
|
+
kEWS1 = 10
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
std::ostream& operator<<(std::ostream& os, EnumWithStreaming e) {
|
|
74
|
+
return os << (e == kEWS1 ? "kEWS1" : "invalid");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// An enum with a PrintTo() function.
|
|
78
|
+
enum EnumWithPrintTo {
|
|
79
|
+
kEWPT1 = 1
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
void PrintTo(EnumWithPrintTo e, std::ostream* os) {
|
|
83
|
+
*os << (e == kEWPT1 ? "kEWPT1" : "invalid");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A class implicitly convertible to BiggestInt.
|
|
87
|
+
class BiggestIntConvertible {
|
|
88
|
+
public:
|
|
89
|
+
operator ::testing::internal::BiggestInt() const { return 42; }
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// A user-defined unprintable class template in the global namespace.
|
|
93
|
+
template <typename T>
|
|
94
|
+
class UnprintableTemplateInGlobal {
|
|
95
|
+
public:
|
|
96
|
+
UnprintableTemplateInGlobal() : value_() {}
|
|
97
|
+
private:
|
|
98
|
+
T value_;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// A user-defined streamable type in the global namespace.
|
|
102
|
+
class StreamableInGlobal {
|
|
103
|
+
public:
|
|
104
|
+
virtual ~StreamableInGlobal() {}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {
|
|
108
|
+
os << "StreamableInGlobal";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void operator<<(::std::ostream& os, const StreamableInGlobal* /* x */) {
|
|
112
|
+
os << "StreamableInGlobal*";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
namespace foo {
|
|
116
|
+
|
|
117
|
+
// A user-defined unprintable type in a user namespace.
|
|
118
|
+
class UnprintableInFoo {
|
|
119
|
+
public:
|
|
120
|
+
UnprintableInFoo() : z_(0) { memcpy(xy_, "\xEF\x12\x0\x0\x34\xAB\x0\x0", 8); }
|
|
121
|
+
double z() const { return z_; }
|
|
122
|
+
private:
|
|
123
|
+
char xy_[8];
|
|
124
|
+
double z_;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// A user-defined printable type in a user-chosen namespace.
|
|
128
|
+
struct PrintableViaPrintTo {
|
|
129
|
+
PrintableViaPrintTo() : value() {}
|
|
130
|
+
int value;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
void PrintTo(const PrintableViaPrintTo& x, ::std::ostream* os) {
|
|
134
|
+
*os << "PrintableViaPrintTo: " << x.value;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// A type with a user-defined << for printing its pointer.
|
|
138
|
+
struct PointerPrintable {
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
::std::ostream& operator<<(::std::ostream& os,
|
|
142
|
+
const PointerPrintable* /* x */) {
|
|
143
|
+
return os << "PointerPrintable*";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// A user-defined printable class template in a user-chosen namespace.
|
|
147
|
+
template <typename T>
|
|
148
|
+
class PrintableViaPrintToTemplate {
|
|
149
|
+
public:
|
|
150
|
+
explicit PrintableViaPrintToTemplate(const T& a_value) : value_(a_value) {}
|
|
151
|
+
|
|
152
|
+
const T& value() const { return value_; }
|
|
153
|
+
private:
|
|
154
|
+
T value_;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
template <typename T>
|
|
158
|
+
void PrintTo(const PrintableViaPrintToTemplate<T>& x, ::std::ostream* os) {
|
|
159
|
+
*os << "PrintableViaPrintToTemplate: " << x.value();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// A user-defined streamable class template in a user namespace.
|
|
163
|
+
template <typename T>
|
|
164
|
+
class StreamableTemplateInFoo {
|
|
165
|
+
public:
|
|
166
|
+
StreamableTemplateInFoo() : value_() {}
|
|
167
|
+
|
|
168
|
+
const T& value() const { return value_; }
|
|
169
|
+
private:
|
|
170
|
+
T value_;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
template <typename T>
|
|
174
|
+
inline ::std::ostream& operator<<(::std::ostream& os,
|
|
175
|
+
const StreamableTemplateInFoo<T>& x) {
|
|
176
|
+
return os << "StreamableTemplateInFoo: " << x.value();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// A user-defined streamable but recursivly-defined container type in
|
|
180
|
+
// a user namespace, it mimics therefore std::filesystem::path or
|
|
181
|
+
// boost::filesystem::path.
|
|
182
|
+
class PathLike {
|
|
183
|
+
public:
|
|
184
|
+
struct iterator {
|
|
185
|
+
typedef PathLike value_type;
|
|
186
|
+
|
|
187
|
+
iterator& operator++();
|
|
188
|
+
PathLike& operator*();
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
using value_type = char;
|
|
192
|
+
using const_iterator = iterator;
|
|
193
|
+
|
|
194
|
+
PathLike() {}
|
|
195
|
+
|
|
196
|
+
iterator begin() const { return iterator(); }
|
|
197
|
+
iterator end() const { return iterator(); }
|
|
198
|
+
|
|
199
|
+
friend ::std::ostream& operator<<(::std::ostream& os, const PathLike&) {
|
|
200
|
+
return os << "Streamable-PathLike";
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
} // namespace foo
|
|
205
|
+
|
|
206
|
+
namespace testing {
|
|
207
|
+
namespace gtest_printers_test {
|
|
208
|
+
|
|
209
|
+
using ::std::deque;
|
|
210
|
+
using ::std::list;
|
|
211
|
+
using ::std::make_pair;
|
|
212
|
+
using ::std::map;
|
|
213
|
+
using ::std::multimap;
|
|
214
|
+
using ::std::multiset;
|
|
215
|
+
using ::std::pair;
|
|
216
|
+
using ::std::set;
|
|
217
|
+
using ::std::vector;
|
|
218
|
+
using ::testing::PrintToString;
|
|
219
|
+
using ::testing::internal::FormatForComparisonFailureMessage;
|
|
220
|
+
using ::testing::internal::ImplicitCast_;
|
|
221
|
+
using ::testing::internal::NativeArray;
|
|
222
|
+
using ::testing::internal::RelationToSourceReference;
|
|
223
|
+
using ::testing::internal::Strings;
|
|
224
|
+
using ::testing::internal::UniversalPrint;
|
|
225
|
+
using ::testing::internal::UniversalPrinter;
|
|
226
|
+
using ::testing::internal::UniversalTersePrint;
|
|
227
|
+
using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
|
|
228
|
+
|
|
229
|
+
// Prints a value to a string using the universal value printer. This
|
|
230
|
+
// is a helper for testing UniversalPrinter<T>::Print() for various types.
|
|
231
|
+
template <typename T>
|
|
232
|
+
std::string Print(const T& value) {
|
|
233
|
+
::std::stringstream ss;
|
|
234
|
+
UniversalPrinter<T>::Print(value, &ss);
|
|
235
|
+
return ss.str();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Prints a value passed by reference to a string, using the universal
|
|
239
|
+
// value printer. This is a helper for testing
|
|
240
|
+
// UniversalPrinter<T&>::Print() for various types.
|
|
241
|
+
template <typename T>
|
|
242
|
+
std::string PrintByRef(const T& value) {
|
|
243
|
+
::std::stringstream ss;
|
|
244
|
+
UniversalPrinter<T&>::Print(value, &ss);
|
|
245
|
+
return ss.str();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Tests printing various enum types.
|
|
249
|
+
|
|
250
|
+
TEST(PrintEnumTest, AnonymousEnum) {
|
|
251
|
+
EXPECT_EQ("-1", Print(kAE1));
|
|
252
|
+
EXPECT_EQ("1", Print(kAE2));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
TEST(PrintEnumTest, EnumWithoutPrinter) {
|
|
256
|
+
EXPECT_EQ("-2", Print(kEWP1));
|
|
257
|
+
EXPECT_EQ("42", Print(kEWP2));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
TEST(PrintEnumTest, EnumWithStreaming) {
|
|
261
|
+
EXPECT_EQ("kEWS1", Print(kEWS1));
|
|
262
|
+
EXPECT_EQ("invalid", Print(static_cast<EnumWithStreaming>(0)));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
TEST(PrintEnumTest, EnumWithPrintTo) {
|
|
266
|
+
EXPECT_EQ("kEWPT1", Print(kEWPT1));
|
|
267
|
+
EXPECT_EQ("invalid", Print(static_cast<EnumWithPrintTo>(0)));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Tests printing a class implicitly convertible to BiggestInt.
|
|
271
|
+
|
|
272
|
+
TEST(PrintClassTest, BiggestIntConvertible) {
|
|
273
|
+
EXPECT_EQ("42", Print(BiggestIntConvertible()));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Tests printing various char types.
|
|
277
|
+
|
|
278
|
+
// char.
|
|
279
|
+
TEST(PrintCharTest, PlainChar) {
|
|
280
|
+
EXPECT_EQ("'\\0'", Print('\0'));
|
|
281
|
+
EXPECT_EQ("'\\'' (39, 0x27)", Print('\''));
|
|
282
|
+
EXPECT_EQ("'\"' (34, 0x22)", Print('"'));
|
|
283
|
+
EXPECT_EQ("'?' (63, 0x3F)", Print('?'));
|
|
284
|
+
EXPECT_EQ("'\\\\' (92, 0x5C)", Print('\\'));
|
|
285
|
+
EXPECT_EQ("'\\a' (7)", Print('\a'));
|
|
286
|
+
EXPECT_EQ("'\\b' (8)", Print('\b'));
|
|
287
|
+
EXPECT_EQ("'\\f' (12, 0xC)", Print('\f'));
|
|
288
|
+
EXPECT_EQ("'\\n' (10, 0xA)", Print('\n'));
|
|
289
|
+
EXPECT_EQ("'\\r' (13, 0xD)", Print('\r'));
|
|
290
|
+
EXPECT_EQ("'\\t' (9)", Print('\t'));
|
|
291
|
+
EXPECT_EQ("'\\v' (11, 0xB)", Print('\v'));
|
|
292
|
+
EXPECT_EQ("'\\x7F' (127)", Print('\x7F'));
|
|
293
|
+
EXPECT_EQ("'\\xFF' (255)", Print('\xFF'));
|
|
294
|
+
EXPECT_EQ("' ' (32, 0x20)", Print(' '));
|
|
295
|
+
EXPECT_EQ("'a' (97, 0x61)", Print('a'));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// signed char.
|
|
299
|
+
TEST(PrintCharTest, SignedChar) {
|
|
300
|
+
EXPECT_EQ("'\\0'", Print(static_cast<signed char>('\0')));
|
|
301
|
+
EXPECT_EQ("'\\xCE' (-50)",
|
|
302
|
+
Print(static_cast<signed char>(-50)));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// unsigned char.
|
|
306
|
+
TEST(PrintCharTest, UnsignedChar) {
|
|
307
|
+
EXPECT_EQ("'\\0'", Print(static_cast<unsigned char>('\0')));
|
|
308
|
+
EXPECT_EQ("'b' (98, 0x62)",
|
|
309
|
+
Print(static_cast<unsigned char>('b')));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Tests printing other simple, built-in types.
|
|
313
|
+
|
|
314
|
+
// bool.
|
|
315
|
+
TEST(PrintBuiltInTypeTest, Bool) {
|
|
316
|
+
EXPECT_EQ("false", Print(false));
|
|
317
|
+
EXPECT_EQ("true", Print(true));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// wchar_t.
|
|
321
|
+
TEST(PrintBuiltInTypeTest, Wchar_t) {
|
|
322
|
+
EXPECT_EQ("L'\\0'", Print(L'\0'));
|
|
323
|
+
EXPECT_EQ("L'\\'' (39, 0x27)", Print(L'\''));
|
|
324
|
+
EXPECT_EQ("L'\"' (34, 0x22)", Print(L'"'));
|
|
325
|
+
EXPECT_EQ("L'?' (63, 0x3F)", Print(L'?'));
|
|
326
|
+
EXPECT_EQ("L'\\\\' (92, 0x5C)", Print(L'\\'));
|
|
327
|
+
EXPECT_EQ("L'\\a' (7)", Print(L'\a'));
|
|
328
|
+
EXPECT_EQ("L'\\b' (8)", Print(L'\b'));
|
|
329
|
+
EXPECT_EQ("L'\\f' (12, 0xC)", Print(L'\f'));
|
|
330
|
+
EXPECT_EQ("L'\\n' (10, 0xA)", Print(L'\n'));
|
|
331
|
+
EXPECT_EQ("L'\\r' (13, 0xD)", Print(L'\r'));
|
|
332
|
+
EXPECT_EQ("L'\\t' (9)", Print(L'\t'));
|
|
333
|
+
EXPECT_EQ("L'\\v' (11, 0xB)", Print(L'\v'));
|
|
334
|
+
EXPECT_EQ("L'\\x7F' (127)", Print(L'\x7F'));
|
|
335
|
+
EXPECT_EQ("L'\\xFF' (255)", Print(L'\xFF'));
|
|
336
|
+
EXPECT_EQ("L' ' (32, 0x20)", Print(L' '));
|
|
337
|
+
EXPECT_EQ("L'a' (97, 0x61)", Print(L'a'));
|
|
338
|
+
EXPECT_EQ("L'\\x576' (1398)", Print(static_cast<wchar_t>(0x576)));
|
|
339
|
+
EXPECT_EQ("L'\\xC74D' (51021)", Print(static_cast<wchar_t>(0xC74D)));
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Test that Int64 provides more storage than wchar_t.
|
|
343
|
+
TEST(PrintTypeSizeTest, Wchar_t) {
|
|
344
|
+
EXPECT_LT(sizeof(wchar_t), sizeof(testing::internal::Int64));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Various integer types.
|
|
348
|
+
TEST(PrintBuiltInTypeTest, Integer) {
|
|
349
|
+
EXPECT_EQ("'\\xFF' (255)", Print(static_cast<unsigned char>(255))); // uint8
|
|
350
|
+
EXPECT_EQ("'\\x80' (-128)", Print(static_cast<signed char>(-128))); // int8
|
|
351
|
+
EXPECT_EQ("65535", Print(USHRT_MAX)); // uint16
|
|
352
|
+
EXPECT_EQ("-32768", Print(SHRT_MIN)); // int16
|
|
353
|
+
EXPECT_EQ("4294967295", Print(UINT_MAX)); // uint32
|
|
354
|
+
EXPECT_EQ("-2147483648", Print(INT_MIN)); // int32
|
|
355
|
+
EXPECT_EQ("18446744073709551615",
|
|
356
|
+
Print(static_cast<testing::internal::UInt64>(-1))); // uint64
|
|
357
|
+
EXPECT_EQ("-9223372036854775808",
|
|
358
|
+
Print(static_cast<testing::internal::Int64>(1) << 63)); // int64
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Size types.
|
|
362
|
+
TEST(PrintBuiltInTypeTest, Size_t) {
|
|
363
|
+
EXPECT_EQ("1", Print(sizeof('a'))); // size_t.
|
|
364
|
+
#if !GTEST_OS_WINDOWS
|
|
365
|
+
// Windows has no ssize_t type.
|
|
366
|
+
EXPECT_EQ("-2", Print(static_cast<ssize_t>(-2))); // ssize_t.
|
|
367
|
+
#endif // !GTEST_OS_WINDOWS
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Floating-points.
|
|
371
|
+
TEST(PrintBuiltInTypeTest, FloatingPoints) {
|
|
372
|
+
EXPECT_EQ("1.5", Print(1.5f)); // float
|
|
373
|
+
EXPECT_EQ("-2.5", Print(-2.5)); // double
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Since ::std::stringstream::operator<<(const void *) formats the pointer
|
|
377
|
+
// output differently with different compilers, we have to create the expected
|
|
378
|
+
// output first and use it as our expectation.
|
|
379
|
+
static std::string PrintPointer(const void* p) {
|
|
380
|
+
::std::stringstream expected_result_stream;
|
|
381
|
+
expected_result_stream << p;
|
|
382
|
+
return expected_result_stream.str();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Tests printing C strings.
|
|
386
|
+
|
|
387
|
+
// const char*.
|
|
388
|
+
TEST(PrintCStringTest, Const) {
|
|
389
|
+
const char* p = "World";
|
|
390
|
+
EXPECT_EQ(PrintPointer(p) + " pointing to \"World\"", Print(p));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// char*.
|
|
394
|
+
TEST(PrintCStringTest, NonConst) {
|
|
395
|
+
char p[] = "Hi";
|
|
396
|
+
EXPECT_EQ(PrintPointer(p) + " pointing to \"Hi\"",
|
|
397
|
+
Print(static_cast<char*>(p)));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// NULL C string.
|
|
401
|
+
TEST(PrintCStringTest, Null) {
|
|
402
|
+
const char* p = nullptr;
|
|
403
|
+
EXPECT_EQ("NULL", Print(p));
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Tests that C strings are escaped properly.
|
|
407
|
+
TEST(PrintCStringTest, EscapesProperly) {
|
|
408
|
+
const char* p = "'\"?\\\a\b\f\n\r\t\v\x7F\xFF a";
|
|
409
|
+
EXPECT_EQ(PrintPointer(p) + " pointing to \"'\\\"?\\\\\\a\\b\\f"
|
|
410
|
+
"\\n\\r\\t\\v\\x7F\\xFF a\"",
|
|
411
|
+
Print(p));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// MSVC compiler can be configured to define whar_t as a typedef
|
|
415
|
+
// of unsigned short. Defining an overload for const wchar_t* in that case
|
|
416
|
+
// would cause pointers to unsigned shorts be printed as wide strings,
|
|
417
|
+
// possibly accessing more memory than intended and causing invalid
|
|
418
|
+
// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when
|
|
419
|
+
// wchar_t is implemented as a native type.
|
|
420
|
+
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
|
|
421
|
+
|
|
422
|
+
// const wchar_t*.
|
|
423
|
+
TEST(PrintWideCStringTest, Const) {
|
|
424
|
+
const wchar_t* p = L"World";
|
|
425
|
+
EXPECT_EQ(PrintPointer(p) + " pointing to L\"World\"", Print(p));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// wchar_t*.
|
|
429
|
+
TEST(PrintWideCStringTest, NonConst) {
|
|
430
|
+
wchar_t p[] = L"Hi";
|
|
431
|
+
EXPECT_EQ(PrintPointer(p) + " pointing to L\"Hi\"",
|
|
432
|
+
Print(static_cast<wchar_t*>(p)));
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// NULL wide C string.
|
|
436
|
+
TEST(PrintWideCStringTest, Null) {
|
|
437
|
+
const wchar_t* p = nullptr;
|
|
438
|
+
EXPECT_EQ("NULL", Print(p));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Tests that wide C strings are escaped properly.
|
|
442
|
+
TEST(PrintWideCStringTest, EscapesProperly) {
|
|
443
|
+
const wchar_t s[] = {'\'', '"', '?', '\\', '\a', '\b', '\f', '\n', '\r',
|
|
444
|
+
'\t', '\v', 0xD3, 0x576, 0x8D3, 0xC74D, ' ', 'a', '\0'};
|
|
445
|
+
EXPECT_EQ(PrintPointer(s) + " pointing to L\"'\\\"?\\\\\\a\\b\\f"
|
|
446
|
+
"\\n\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\"",
|
|
447
|
+
Print(static_cast<const wchar_t*>(s)));
|
|
448
|
+
}
|
|
449
|
+
#endif // native wchar_t
|
|
450
|
+
|
|
451
|
+
// Tests printing pointers to other char types.
|
|
452
|
+
|
|
453
|
+
// signed char*.
|
|
454
|
+
TEST(PrintCharPointerTest, SignedChar) {
|
|
455
|
+
signed char* p = reinterpret_cast<signed char*>(0x1234);
|
|
456
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
457
|
+
p = nullptr;
|
|
458
|
+
EXPECT_EQ("NULL", Print(p));
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// const signed char*.
|
|
462
|
+
TEST(PrintCharPointerTest, ConstSignedChar) {
|
|
463
|
+
signed char* p = reinterpret_cast<signed char*>(0x1234);
|
|
464
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
465
|
+
p = nullptr;
|
|
466
|
+
EXPECT_EQ("NULL", Print(p));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// unsigned char*.
|
|
470
|
+
TEST(PrintCharPointerTest, UnsignedChar) {
|
|
471
|
+
unsigned char* p = reinterpret_cast<unsigned char*>(0x1234);
|
|
472
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
473
|
+
p = nullptr;
|
|
474
|
+
EXPECT_EQ("NULL", Print(p));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// const unsigned char*.
|
|
478
|
+
TEST(PrintCharPointerTest, ConstUnsignedChar) {
|
|
479
|
+
const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234);
|
|
480
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
481
|
+
p = nullptr;
|
|
482
|
+
EXPECT_EQ("NULL", Print(p));
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Tests printing pointers to simple, built-in types.
|
|
486
|
+
|
|
487
|
+
// bool*.
|
|
488
|
+
TEST(PrintPointerToBuiltInTypeTest, Bool) {
|
|
489
|
+
bool* p = reinterpret_cast<bool*>(0xABCD);
|
|
490
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
491
|
+
p = nullptr;
|
|
492
|
+
EXPECT_EQ("NULL", Print(p));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// void*.
|
|
496
|
+
TEST(PrintPointerToBuiltInTypeTest, Void) {
|
|
497
|
+
void* p = reinterpret_cast<void*>(0xABCD);
|
|
498
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
499
|
+
p = nullptr;
|
|
500
|
+
EXPECT_EQ("NULL", Print(p));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// const void*.
|
|
504
|
+
TEST(PrintPointerToBuiltInTypeTest, ConstVoid) {
|
|
505
|
+
const void* p = reinterpret_cast<const void*>(0xABCD);
|
|
506
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
507
|
+
p = nullptr;
|
|
508
|
+
EXPECT_EQ("NULL", Print(p));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Tests printing pointers to pointers.
|
|
512
|
+
TEST(PrintPointerToPointerTest, IntPointerPointer) {
|
|
513
|
+
int** p = reinterpret_cast<int**>(0xABCD);
|
|
514
|
+
EXPECT_EQ(PrintPointer(p), Print(p));
|
|
515
|
+
p = nullptr;
|
|
516
|
+
EXPECT_EQ("NULL", Print(p));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Tests printing (non-member) function pointers.
|
|
520
|
+
|
|
521
|
+
void MyFunction(int /* n */) {}
|
|
522
|
+
|
|
523
|
+
TEST(PrintPointerTest, NonMemberFunctionPointer) {
|
|
524
|
+
// We cannot directly cast &MyFunction to const void* because the
|
|
525
|
+
// standard disallows casting between pointers to functions and
|
|
526
|
+
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
|
|
527
|
+
// this limitation.
|
|
528
|
+
EXPECT_EQ(
|
|
529
|
+
PrintPointer(reinterpret_cast<const void*>(
|
|
530
|
+
reinterpret_cast<internal::BiggestInt>(&MyFunction))),
|
|
531
|
+
Print(&MyFunction));
|
|
532
|
+
int (*p)(bool) = NULL; // NOLINT
|
|
533
|
+
EXPECT_EQ("NULL", Print(p));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// An assertion predicate determining whether a one string is a prefix for
|
|
537
|
+
// another.
|
|
538
|
+
template <typename StringType>
|
|
539
|
+
AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
|
|
540
|
+
if (str.find(prefix, 0) == 0)
|
|
541
|
+
return AssertionSuccess();
|
|
542
|
+
|
|
543
|
+
const bool is_wide_string = sizeof(prefix[0]) > 1;
|
|
544
|
+
const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
|
|
545
|
+
return AssertionFailure()
|
|
546
|
+
<< begin_string_quote << prefix << "\" is not a prefix of "
|
|
547
|
+
<< begin_string_quote << str << "\"\n";
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Tests printing member variable pointers. Although they are called
|
|
551
|
+
// pointers, they don't point to a location in the address space.
|
|
552
|
+
// Their representation is implementation-defined. Thus they will be
|
|
553
|
+
// printed as raw bytes.
|
|
554
|
+
|
|
555
|
+
struct Foo {
|
|
556
|
+
public:
|
|
557
|
+
virtual ~Foo() {}
|
|
558
|
+
int MyMethod(char x) { return x + 1; }
|
|
559
|
+
virtual char MyVirtualMethod(int /* n */) { return 'a'; }
|
|
560
|
+
|
|
561
|
+
int value;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
TEST(PrintPointerTest, MemberVariablePointer) {
|
|
565
|
+
EXPECT_TRUE(HasPrefix(Print(&Foo::value),
|
|
566
|
+
Print(sizeof(&Foo::value)) + "-byte object "));
|
|
567
|
+
int Foo::*p = NULL; // NOLINT
|
|
568
|
+
EXPECT_TRUE(HasPrefix(Print(p),
|
|
569
|
+
Print(sizeof(p)) + "-byte object "));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Tests printing member function pointers. Although they are called
|
|
573
|
+
// pointers, they don't point to a location in the address space.
|
|
574
|
+
// Their representation is implementation-defined. Thus they will be
|
|
575
|
+
// printed as raw bytes.
|
|
576
|
+
TEST(PrintPointerTest, MemberFunctionPointer) {
|
|
577
|
+
EXPECT_TRUE(HasPrefix(Print(&Foo::MyMethod),
|
|
578
|
+
Print(sizeof(&Foo::MyMethod)) + "-byte object "));
|
|
579
|
+
EXPECT_TRUE(
|
|
580
|
+
HasPrefix(Print(&Foo::MyVirtualMethod),
|
|
581
|
+
Print(sizeof((&Foo::MyVirtualMethod))) + "-byte object "));
|
|
582
|
+
int (Foo::*p)(char) = NULL; // NOLINT
|
|
583
|
+
EXPECT_TRUE(HasPrefix(Print(p),
|
|
584
|
+
Print(sizeof(p)) + "-byte object "));
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// Tests printing C arrays.
|
|
588
|
+
|
|
589
|
+
// The difference between this and Print() is that it ensures that the
|
|
590
|
+
// argument is a reference to an array.
|
|
591
|
+
template <typename T, size_t N>
|
|
592
|
+
std::string PrintArrayHelper(T (&a)[N]) {
|
|
593
|
+
return Print(a);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// One-dimensional array.
|
|
597
|
+
TEST(PrintArrayTest, OneDimensionalArray) {
|
|
598
|
+
int a[5] = { 1, 2, 3, 4, 5 };
|
|
599
|
+
EXPECT_EQ("{ 1, 2, 3, 4, 5 }", PrintArrayHelper(a));
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// Two-dimensional array.
|
|
603
|
+
TEST(PrintArrayTest, TwoDimensionalArray) {
|
|
604
|
+
int a[2][5] = {
|
|
605
|
+
{ 1, 2, 3, 4, 5 },
|
|
606
|
+
{ 6, 7, 8, 9, 0 }
|
|
607
|
+
};
|
|
608
|
+
EXPECT_EQ("{ { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 0 } }", PrintArrayHelper(a));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Array of const elements.
|
|
612
|
+
TEST(PrintArrayTest, ConstArray) {
|
|
613
|
+
const bool a[1] = { false };
|
|
614
|
+
EXPECT_EQ("{ false }", PrintArrayHelper(a));
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// char array without terminating NUL.
|
|
618
|
+
TEST(PrintArrayTest, CharArrayWithNoTerminatingNul) {
|
|
619
|
+
// Array a contains '\0' in the middle and doesn't end with '\0'.
|
|
620
|
+
char a[] = { 'H', '\0', 'i' };
|
|
621
|
+
EXPECT_EQ("\"H\\0i\" (no terminating NUL)", PrintArrayHelper(a));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// const char array with terminating NUL.
|
|
625
|
+
TEST(PrintArrayTest, ConstCharArrayWithTerminatingNul) {
|
|
626
|
+
const char a[] = "\0Hi";
|
|
627
|
+
EXPECT_EQ("\"\\0Hi\"", PrintArrayHelper(a));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// const wchar_t array without terminating NUL.
|
|
631
|
+
TEST(PrintArrayTest, WCharArrayWithNoTerminatingNul) {
|
|
632
|
+
// Array a contains '\0' in the middle and doesn't end with '\0'.
|
|
633
|
+
const wchar_t a[] = { L'H', L'\0', L'i' };
|
|
634
|
+
EXPECT_EQ("L\"H\\0i\" (no terminating NUL)", PrintArrayHelper(a));
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// wchar_t array with terminating NUL.
|
|
638
|
+
TEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) {
|
|
639
|
+
const wchar_t a[] = L"\0Hi";
|
|
640
|
+
EXPECT_EQ("L\"\\0Hi\"", PrintArrayHelper(a));
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// Array of objects.
|
|
644
|
+
TEST(PrintArrayTest, ObjectArray) {
|
|
645
|
+
std::string a[3] = {"Hi", "Hello", "Ni hao"};
|
|
646
|
+
EXPECT_EQ("{ \"Hi\", \"Hello\", \"Ni hao\" }", PrintArrayHelper(a));
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// Array with many elements.
|
|
650
|
+
TEST(PrintArrayTest, BigArray) {
|
|
651
|
+
int a[100] = { 1, 2, 3 };
|
|
652
|
+
EXPECT_EQ("{ 1, 2, 3, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0 }",
|
|
653
|
+
PrintArrayHelper(a));
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Tests printing ::string and ::std::string.
|
|
657
|
+
|
|
658
|
+
// ::std::string.
|
|
659
|
+
TEST(PrintStringTest, StringInStdNamespace) {
|
|
660
|
+
const char s[] = "'\"?\\\a\b\f\n\0\r\t\v\x7F\xFF a";
|
|
661
|
+
const ::std::string str(s, sizeof(s));
|
|
662
|
+
EXPECT_EQ("\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\\0\"",
|
|
663
|
+
Print(str));
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
TEST(PrintStringTest, StringAmbiguousHex) {
|
|
667
|
+
// "\x6BANANA" is ambiguous, it can be interpreted as starting with either of:
|
|
668
|
+
// '\x6', '\x6B', or '\x6BA'.
|
|
669
|
+
|
|
670
|
+
// a hex escaping sequence following by a decimal digit
|
|
671
|
+
EXPECT_EQ("\"0\\x12\" \"3\"", Print(::std::string("0\x12" "3")));
|
|
672
|
+
// a hex escaping sequence following by a hex digit (lower-case)
|
|
673
|
+
EXPECT_EQ("\"mm\\x6\" \"bananas\"", Print(::std::string("mm\x6" "bananas")));
|
|
674
|
+
// a hex escaping sequence following by a hex digit (upper-case)
|
|
675
|
+
EXPECT_EQ("\"NOM\\x6\" \"BANANA\"", Print(::std::string("NOM\x6" "BANANA")));
|
|
676
|
+
// a hex escaping sequence following by a non-xdigit
|
|
677
|
+
EXPECT_EQ("\"!\\x5-!\"", Print(::std::string("!\x5-!")));
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Tests printing ::std::wstring.
|
|
681
|
+
#if GTEST_HAS_STD_WSTRING
|
|
682
|
+
// ::std::wstring.
|
|
683
|
+
TEST(PrintWideStringTest, StringInStdNamespace) {
|
|
684
|
+
const wchar_t s[] = L"'\"?\\\a\b\f\n\0\r\t\v\xD3\x576\x8D3\xC74D a";
|
|
685
|
+
const ::std::wstring str(s, sizeof(s)/sizeof(wchar_t));
|
|
686
|
+
EXPECT_EQ("L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v"
|
|
687
|
+
"\\xD3\\x576\\x8D3\\xC74D a\\0\"",
|
|
688
|
+
Print(str));
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
TEST(PrintWideStringTest, StringAmbiguousHex) {
|
|
692
|
+
// same for wide strings.
|
|
693
|
+
EXPECT_EQ("L\"0\\x12\" L\"3\"", Print(::std::wstring(L"0\x12" L"3")));
|
|
694
|
+
EXPECT_EQ("L\"mm\\x6\" L\"bananas\"",
|
|
695
|
+
Print(::std::wstring(L"mm\x6" L"bananas")));
|
|
696
|
+
EXPECT_EQ("L\"NOM\\x6\" L\"BANANA\"",
|
|
697
|
+
Print(::std::wstring(L"NOM\x6" L"BANANA")));
|
|
698
|
+
EXPECT_EQ("L\"!\\x5-!\"", Print(::std::wstring(L"!\x5-!")));
|
|
699
|
+
}
|
|
700
|
+
#endif // GTEST_HAS_STD_WSTRING
|
|
701
|
+
|
|
702
|
+
// Tests printing types that support generic streaming (i.e. streaming
|
|
703
|
+
// to std::basic_ostream<Char, CharTraits> for any valid Char and
|
|
704
|
+
// CharTraits types).
|
|
705
|
+
|
|
706
|
+
// Tests printing a non-template type that supports generic streaming.
|
|
707
|
+
|
|
708
|
+
class AllowsGenericStreaming {};
|
|
709
|
+
|
|
710
|
+
template <typename Char, typename CharTraits>
|
|
711
|
+
std::basic_ostream<Char, CharTraits>& operator<<(
|
|
712
|
+
std::basic_ostream<Char, CharTraits>& os,
|
|
713
|
+
const AllowsGenericStreaming& /* a */) {
|
|
714
|
+
return os << "AllowsGenericStreaming";
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
TEST(PrintTypeWithGenericStreamingTest, NonTemplateType) {
|
|
718
|
+
AllowsGenericStreaming a;
|
|
719
|
+
EXPECT_EQ("AllowsGenericStreaming", Print(a));
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Tests printing a template type that supports generic streaming.
|
|
723
|
+
|
|
724
|
+
template <typename T>
|
|
725
|
+
class AllowsGenericStreamingTemplate {};
|
|
726
|
+
|
|
727
|
+
template <typename Char, typename CharTraits, typename T>
|
|
728
|
+
std::basic_ostream<Char, CharTraits>& operator<<(
|
|
729
|
+
std::basic_ostream<Char, CharTraits>& os,
|
|
730
|
+
const AllowsGenericStreamingTemplate<T>& /* a */) {
|
|
731
|
+
return os << "AllowsGenericStreamingTemplate";
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
TEST(PrintTypeWithGenericStreamingTest, TemplateType) {
|
|
735
|
+
AllowsGenericStreamingTemplate<int> a;
|
|
736
|
+
EXPECT_EQ("AllowsGenericStreamingTemplate", Print(a));
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// Tests printing a type that supports generic streaming and can be
|
|
740
|
+
// implicitly converted to another printable type.
|
|
741
|
+
|
|
742
|
+
template <typename T>
|
|
743
|
+
class AllowsGenericStreamingAndImplicitConversionTemplate {
|
|
744
|
+
public:
|
|
745
|
+
operator bool() const { return false; }
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
template <typename Char, typename CharTraits, typename T>
|
|
749
|
+
std::basic_ostream<Char, CharTraits>& operator<<(
|
|
750
|
+
std::basic_ostream<Char, CharTraits>& os,
|
|
751
|
+
const AllowsGenericStreamingAndImplicitConversionTemplate<T>& /* a */) {
|
|
752
|
+
return os << "AllowsGenericStreamingAndImplicitConversionTemplate";
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
TEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {
|
|
756
|
+
AllowsGenericStreamingAndImplicitConversionTemplate<int> a;
|
|
757
|
+
EXPECT_EQ("AllowsGenericStreamingAndImplicitConversionTemplate", Print(a));
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
#if GTEST_HAS_ABSL
|
|
761
|
+
|
|
762
|
+
// Tests printing ::absl::string_view.
|
|
763
|
+
|
|
764
|
+
TEST(PrintStringViewTest, SimpleStringView) {
|
|
765
|
+
const ::absl::string_view sp = "Hello";
|
|
766
|
+
EXPECT_EQ("\"Hello\"", Print(sp));
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
TEST(PrintStringViewTest, UnprintableCharacters) {
|
|
770
|
+
const char str[] = "NUL (\0) and \r\t";
|
|
771
|
+
const ::absl::string_view sp(str, sizeof(str) - 1);
|
|
772
|
+
EXPECT_EQ("\"NUL (\\0) and \\r\\t\"", Print(sp));
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
#endif // GTEST_HAS_ABSL
|
|
776
|
+
|
|
777
|
+
// Tests printing STL containers.
|
|
778
|
+
|
|
779
|
+
TEST(PrintStlContainerTest, EmptyDeque) {
|
|
780
|
+
deque<char> empty;
|
|
781
|
+
EXPECT_EQ("{}", Print(empty));
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
TEST(PrintStlContainerTest, NonEmptyDeque) {
|
|
785
|
+
deque<int> non_empty;
|
|
786
|
+
non_empty.push_back(1);
|
|
787
|
+
non_empty.push_back(3);
|
|
788
|
+
EXPECT_EQ("{ 1, 3 }", Print(non_empty));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
TEST(PrintStlContainerTest, OneElementHashMap) {
|
|
793
|
+
::std::unordered_map<int, char> map1;
|
|
794
|
+
map1[1] = 'a';
|
|
795
|
+
EXPECT_EQ("{ (1, 'a' (97, 0x61)) }", Print(map1));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
TEST(PrintStlContainerTest, HashMultiMap) {
|
|
799
|
+
::std::unordered_multimap<int, bool> map1;
|
|
800
|
+
map1.insert(make_pair(5, true));
|
|
801
|
+
map1.insert(make_pair(5, false));
|
|
802
|
+
|
|
803
|
+
// Elements of hash_multimap can be printed in any order.
|
|
804
|
+
const std::string result = Print(map1);
|
|
805
|
+
EXPECT_TRUE(result == "{ (5, true), (5, false) }" ||
|
|
806
|
+
result == "{ (5, false), (5, true) }")
|
|
807
|
+
<< " where Print(map1) returns \"" << result << "\".";
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
TEST(PrintStlContainerTest, HashSet) {
|
|
813
|
+
::std::unordered_set<int> set1;
|
|
814
|
+
set1.insert(1);
|
|
815
|
+
EXPECT_EQ("{ 1 }", Print(set1));
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
TEST(PrintStlContainerTest, HashMultiSet) {
|
|
819
|
+
const int kSize = 5;
|
|
820
|
+
int a[kSize] = { 1, 1, 2, 5, 1 };
|
|
821
|
+
::std::unordered_multiset<int> set1(a, a + kSize);
|
|
822
|
+
|
|
823
|
+
// Elements of hash_multiset can be printed in any order.
|
|
824
|
+
const std::string result = Print(set1);
|
|
825
|
+
const std::string expected_pattern = "{ d, d, d, d, d }"; // d means a digit.
|
|
826
|
+
|
|
827
|
+
// Verifies the result matches the expected pattern; also extracts
|
|
828
|
+
// the numbers in the result.
|
|
829
|
+
ASSERT_EQ(expected_pattern.length(), result.length());
|
|
830
|
+
std::vector<int> numbers;
|
|
831
|
+
for (size_t i = 0; i != result.length(); i++) {
|
|
832
|
+
if (expected_pattern[i] == 'd') {
|
|
833
|
+
ASSERT_NE(isdigit(static_cast<unsigned char>(result[i])), 0);
|
|
834
|
+
numbers.push_back(result[i] - '0');
|
|
835
|
+
} else {
|
|
836
|
+
EXPECT_EQ(expected_pattern[i], result[i]) << " where result is "
|
|
837
|
+
<< result;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
// Makes sure the result contains the right numbers.
|
|
842
|
+
std::sort(numbers.begin(), numbers.end());
|
|
843
|
+
std::sort(a, a + kSize);
|
|
844
|
+
EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin()));
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
TEST(PrintStlContainerTest, List) {
|
|
849
|
+
const std::string a[] = {"hello", "world"};
|
|
850
|
+
const list<std::string> strings(a, a + 2);
|
|
851
|
+
EXPECT_EQ("{ \"hello\", \"world\" }", Print(strings));
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
TEST(PrintStlContainerTest, Map) {
|
|
855
|
+
map<int, bool> map1;
|
|
856
|
+
map1[1] = true;
|
|
857
|
+
map1[5] = false;
|
|
858
|
+
map1[3] = true;
|
|
859
|
+
EXPECT_EQ("{ (1, true), (3, true), (5, false) }", Print(map1));
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
TEST(PrintStlContainerTest, MultiMap) {
|
|
863
|
+
multimap<bool, int> map1;
|
|
864
|
+
// The make_pair template function would deduce the type as
|
|
865
|
+
// pair<bool, int> here, and since the key part in a multimap has to
|
|
866
|
+
// be constant, without a templated ctor in the pair class (as in
|
|
867
|
+
// libCstd on Solaris), make_pair call would fail to compile as no
|
|
868
|
+
// implicit conversion is found. Thus explicit typename is used
|
|
869
|
+
// here instead.
|
|
870
|
+
map1.insert(pair<const bool, int>(true, 0));
|
|
871
|
+
map1.insert(pair<const bool, int>(true, 1));
|
|
872
|
+
map1.insert(pair<const bool, int>(false, 2));
|
|
873
|
+
EXPECT_EQ("{ (false, 2), (true, 0), (true, 1) }", Print(map1));
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
TEST(PrintStlContainerTest, Set) {
|
|
877
|
+
const unsigned int a[] = { 3, 0, 5 };
|
|
878
|
+
set<unsigned int> set1(a, a + 3);
|
|
879
|
+
EXPECT_EQ("{ 0, 3, 5 }", Print(set1));
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
TEST(PrintStlContainerTest, MultiSet) {
|
|
883
|
+
const int a[] = { 1, 1, 2, 5, 1 };
|
|
884
|
+
multiset<int> set1(a, a + 5);
|
|
885
|
+
EXPECT_EQ("{ 1, 1, 1, 2, 5 }", Print(set1));
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
TEST(PrintStlContainerTest, SinglyLinkedList) {
|
|
890
|
+
int a[] = { 9, 2, 8 };
|
|
891
|
+
const std::forward_list<int> ints(a, a + 3);
|
|
892
|
+
EXPECT_EQ("{ 9, 2, 8 }", Print(ints));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
TEST(PrintStlContainerTest, Pair) {
|
|
896
|
+
pair<const bool, int> p(true, 5);
|
|
897
|
+
EXPECT_EQ("(true, 5)", Print(p));
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
TEST(PrintStlContainerTest, Vector) {
|
|
901
|
+
vector<int> v;
|
|
902
|
+
v.push_back(1);
|
|
903
|
+
v.push_back(2);
|
|
904
|
+
EXPECT_EQ("{ 1, 2 }", Print(v));
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
TEST(PrintStlContainerTest, LongSequence) {
|
|
908
|
+
const int a[100] = { 1, 2, 3 };
|
|
909
|
+
const vector<int> v(a, a + 100);
|
|
910
|
+
EXPECT_EQ("{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "
|
|
911
|
+
"0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }", Print(v));
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
TEST(PrintStlContainerTest, NestedContainer) {
|
|
915
|
+
const int a1[] = { 1, 2 };
|
|
916
|
+
const int a2[] = { 3, 4, 5 };
|
|
917
|
+
const list<int> l1(a1, a1 + 2);
|
|
918
|
+
const list<int> l2(a2, a2 + 3);
|
|
919
|
+
|
|
920
|
+
vector<list<int> > v;
|
|
921
|
+
v.push_back(l1);
|
|
922
|
+
v.push_back(l2);
|
|
923
|
+
EXPECT_EQ("{ { 1, 2 }, { 3, 4, 5 } }", Print(v));
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
TEST(PrintStlContainerTest, OneDimensionalNativeArray) {
|
|
927
|
+
const int a[3] = { 1, 2, 3 };
|
|
928
|
+
NativeArray<int> b(a, 3, RelationToSourceReference());
|
|
929
|
+
EXPECT_EQ("{ 1, 2, 3 }", Print(b));
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
TEST(PrintStlContainerTest, TwoDimensionalNativeArray) {
|
|
933
|
+
const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
|
|
934
|
+
NativeArray<int[3]> b(a, 2, RelationToSourceReference());
|
|
935
|
+
EXPECT_EQ("{ { 1, 2, 3 }, { 4, 5, 6 } }", Print(b));
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// Tests that a class named iterator isn't treated as a container.
|
|
939
|
+
|
|
940
|
+
struct iterator {
|
|
941
|
+
char x;
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
TEST(PrintStlContainerTest, Iterator) {
|
|
945
|
+
iterator it = {};
|
|
946
|
+
EXPECT_EQ("1-byte object <00>", Print(it));
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Tests that a class named const_iterator isn't treated as a container.
|
|
950
|
+
|
|
951
|
+
struct const_iterator {
|
|
952
|
+
char x;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
TEST(PrintStlContainerTest, ConstIterator) {
|
|
956
|
+
const_iterator it = {};
|
|
957
|
+
EXPECT_EQ("1-byte object <00>", Print(it));
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// Tests printing ::std::tuples.
|
|
961
|
+
|
|
962
|
+
// Tuples of various arities.
|
|
963
|
+
TEST(PrintStdTupleTest, VariousSizes) {
|
|
964
|
+
::std::tuple<> t0;
|
|
965
|
+
EXPECT_EQ("()", Print(t0));
|
|
966
|
+
|
|
967
|
+
::std::tuple<int> t1(5);
|
|
968
|
+
EXPECT_EQ("(5)", Print(t1));
|
|
969
|
+
|
|
970
|
+
::std::tuple<char, bool> t2('a', true);
|
|
971
|
+
EXPECT_EQ("('a' (97, 0x61), true)", Print(t2));
|
|
972
|
+
|
|
973
|
+
::std::tuple<bool, int, int> t3(false, 2, 3);
|
|
974
|
+
EXPECT_EQ("(false, 2, 3)", Print(t3));
|
|
975
|
+
|
|
976
|
+
::std::tuple<bool, int, int, int> t4(false, 2, 3, 4);
|
|
977
|
+
EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
|
|
978
|
+
|
|
979
|
+
const char* const str = "8";
|
|
980
|
+
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
|
|
981
|
+
testing::internal::Int64, float, double, const char*, void*,
|
|
982
|
+
std::string>
|
|
983
|
+
t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str, // NOLINT
|
|
984
|
+
nullptr, "10");
|
|
985
|
+
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
|
|
986
|
+
" pointing to \"8\", NULL, \"10\")",
|
|
987
|
+
Print(t10));
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// Nested tuples.
|
|
991
|
+
TEST(PrintStdTupleTest, NestedTuple) {
|
|
992
|
+
::std::tuple< ::std::tuple<int, bool>, char> nested(
|
|
993
|
+
::std::make_tuple(5, true), 'a');
|
|
994
|
+
EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
TEST(PrintNullptrT, Basic) {
|
|
998
|
+
EXPECT_EQ("(nullptr)", Print(nullptr));
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
TEST(PrintReferenceWrapper, Printable) {
|
|
1002
|
+
int x = 5;
|
|
1003
|
+
EXPECT_EQ("@" + PrintPointer(&x) + " 5", Print(std::ref(x)));
|
|
1004
|
+
EXPECT_EQ("@" + PrintPointer(&x) + " 5", Print(std::cref(x)));
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
TEST(PrintReferenceWrapper, Unprintable) {
|
|
1008
|
+
::foo::UnprintableInFoo up;
|
|
1009
|
+
EXPECT_EQ(
|
|
1010
|
+
"@" + PrintPointer(&up) +
|
|
1011
|
+
" 16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
|
|
1012
|
+
Print(std::ref(up)));
|
|
1013
|
+
EXPECT_EQ(
|
|
1014
|
+
"@" + PrintPointer(&up) +
|
|
1015
|
+
" 16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
|
|
1016
|
+
Print(std::cref(up)));
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// Tests printing user-defined unprintable types.
|
|
1020
|
+
|
|
1021
|
+
// Unprintable types in the global namespace.
|
|
1022
|
+
TEST(PrintUnprintableTypeTest, InGlobalNamespace) {
|
|
1023
|
+
EXPECT_EQ("1-byte object <00>",
|
|
1024
|
+
Print(UnprintableTemplateInGlobal<char>()));
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// Unprintable types in a user namespace.
|
|
1028
|
+
TEST(PrintUnprintableTypeTest, InUserNamespace) {
|
|
1029
|
+
EXPECT_EQ("16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
|
|
1030
|
+
Print(::foo::UnprintableInFoo()));
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// Unprintable types are that too big to be printed completely.
|
|
1034
|
+
|
|
1035
|
+
struct Big {
|
|
1036
|
+
Big() { memset(array, 0, sizeof(array)); }
|
|
1037
|
+
char array[257];
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
TEST(PrintUnpritableTypeTest, BigObject) {
|
|
1041
|
+
EXPECT_EQ("257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 "
|
|
1042
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
|
|
1043
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
|
|
1044
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 "
|
|
1045
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
|
|
1046
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 "
|
|
1047
|
+
"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>",
|
|
1048
|
+
Print(Big()));
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// Tests printing user-defined streamable types.
|
|
1052
|
+
|
|
1053
|
+
// Streamable types in the global namespace.
|
|
1054
|
+
TEST(PrintStreamableTypeTest, InGlobalNamespace) {
|
|
1055
|
+
StreamableInGlobal x;
|
|
1056
|
+
EXPECT_EQ("StreamableInGlobal", Print(x));
|
|
1057
|
+
EXPECT_EQ("StreamableInGlobal*", Print(&x));
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// Printable template types in a user namespace.
|
|
1061
|
+
TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {
|
|
1062
|
+
EXPECT_EQ("StreamableTemplateInFoo: 0",
|
|
1063
|
+
Print(::foo::StreamableTemplateInFoo<int>()));
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// Tests printing a user-defined recursive container type that has a <<
|
|
1067
|
+
// operator.
|
|
1068
|
+
TEST(PrintStreamableTypeTest, PathLikeInUserNamespace) {
|
|
1069
|
+
::foo::PathLike x;
|
|
1070
|
+
EXPECT_EQ("Streamable-PathLike", Print(x));
|
|
1071
|
+
const ::foo::PathLike cx;
|
|
1072
|
+
EXPECT_EQ("Streamable-PathLike", Print(cx));
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Tests printing user-defined types that have a PrintTo() function.
|
|
1076
|
+
TEST(PrintPrintableTypeTest, InUserNamespace) {
|
|
1077
|
+
EXPECT_EQ("PrintableViaPrintTo: 0",
|
|
1078
|
+
Print(::foo::PrintableViaPrintTo()));
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// Tests printing a pointer to a user-defined type that has a <<
|
|
1082
|
+
// operator for its pointer.
|
|
1083
|
+
TEST(PrintPrintableTypeTest, PointerInUserNamespace) {
|
|
1084
|
+
::foo::PointerPrintable x;
|
|
1085
|
+
EXPECT_EQ("PointerPrintable*", Print(&x));
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// Tests printing user-defined class template that have a PrintTo() function.
|
|
1089
|
+
TEST(PrintPrintableTypeTest, TemplateInUserNamespace) {
|
|
1090
|
+
EXPECT_EQ("PrintableViaPrintToTemplate: 5",
|
|
1091
|
+
Print(::foo::PrintableViaPrintToTemplate<int>(5)));
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// Tests that the universal printer prints both the address and the
|
|
1095
|
+
// value of a reference.
|
|
1096
|
+
TEST(PrintReferenceTest, PrintsAddressAndValue) {
|
|
1097
|
+
int n = 5;
|
|
1098
|
+
EXPECT_EQ("@" + PrintPointer(&n) + " 5", PrintByRef(n));
|
|
1099
|
+
|
|
1100
|
+
int a[2][3] = {
|
|
1101
|
+
{ 0, 1, 2 },
|
|
1102
|
+
{ 3, 4, 5 }
|
|
1103
|
+
};
|
|
1104
|
+
EXPECT_EQ("@" + PrintPointer(a) + " { { 0, 1, 2 }, { 3, 4, 5 } }",
|
|
1105
|
+
PrintByRef(a));
|
|
1106
|
+
|
|
1107
|
+
const ::foo::UnprintableInFoo x;
|
|
1108
|
+
EXPECT_EQ("@" + PrintPointer(&x) + " 16-byte object "
|
|
1109
|
+
"<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>",
|
|
1110
|
+
PrintByRef(x));
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// Tests that the universal printer prints a function pointer passed by
|
|
1114
|
+
// reference.
|
|
1115
|
+
TEST(PrintReferenceTest, HandlesFunctionPointer) {
|
|
1116
|
+
void (*fp)(int n) = &MyFunction;
|
|
1117
|
+
const std::string fp_pointer_string =
|
|
1118
|
+
PrintPointer(reinterpret_cast<const void*>(&fp));
|
|
1119
|
+
// We cannot directly cast &MyFunction to const void* because the
|
|
1120
|
+
// standard disallows casting between pointers to functions and
|
|
1121
|
+
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
|
|
1122
|
+
// this limitation.
|
|
1123
|
+
const std::string fp_string = PrintPointer(reinterpret_cast<const void*>(
|
|
1124
|
+
reinterpret_cast<internal::BiggestInt>(fp)));
|
|
1125
|
+
EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
|
|
1126
|
+
PrintByRef(fp));
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// Tests that the universal printer prints a member function pointer
|
|
1130
|
+
// passed by reference.
|
|
1131
|
+
TEST(PrintReferenceTest, HandlesMemberFunctionPointer) {
|
|
1132
|
+
int (Foo::*p)(char ch) = &Foo::MyMethod;
|
|
1133
|
+
EXPECT_TRUE(HasPrefix(
|
|
1134
|
+
PrintByRef(p),
|
|
1135
|
+
"@" + PrintPointer(reinterpret_cast<const void*>(&p)) + " " +
|
|
1136
|
+
Print(sizeof(p)) + "-byte object "));
|
|
1137
|
+
|
|
1138
|
+
char (Foo::*p2)(int n) = &Foo::MyVirtualMethod;
|
|
1139
|
+
EXPECT_TRUE(HasPrefix(
|
|
1140
|
+
PrintByRef(p2),
|
|
1141
|
+
"@" + PrintPointer(reinterpret_cast<const void*>(&p2)) + " " +
|
|
1142
|
+
Print(sizeof(p2)) + "-byte object "));
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// Tests that the universal printer prints a member variable pointer
|
|
1146
|
+
// passed by reference.
|
|
1147
|
+
TEST(PrintReferenceTest, HandlesMemberVariablePointer) {
|
|
1148
|
+
int Foo::*p = &Foo::value; // NOLINT
|
|
1149
|
+
EXPECT_TRUE(HasPrefix(
|
|
1150
|
+
PrintByRef(p),
|
|
1151
|
+
"@" + PrintPointer(&p) + " " + Print(sizeof(p)) + "-byte object "));
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// Tests that FormatForComparisonFailureMessage(), which is used to print
|
|
1155
|
+
// an operand in a comparison assertion (e.g. ASSERT_EQ) when the assertion
|
|
1156
|
+
// fails, formats the operand in the desired way.
|
|
1157
|
+
|
|
1158
|
+
// scalar
|
|
1159
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForScalar) {
|
|
1160
|
+
EXPECT_STREQ("123",
|
|
1161
|
+
FormatForComparisonFailureMessage(123, 124).c_str());
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// non-char pointer
|
|
1165
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForNonCharPointer) {
|
|
1166
|
+
int n = 0;
|
|
1167
|
+
EXPECT_EQ(PrintPointer(&n),
|
|
1168
|
+
FormatForComparisonFailureMessage(&n, &n).c_str());
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// non-char array
|
|
1172
|
+
TEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {
|
|
1173
|
+
// In expression 'array == x', 'array' is compared by pointer.
|
|
1174
|
+
// Therefore we want to print an array operand as a pointer.
|
|
1175
|
+
int n[] = { 1, 2, 3 };
|
|
1176
|
+
EXPECT_EQ(PrintPointer(n),
|
|
1177
|
+
FormatForComparisonFailureMessage(n, n).c_str());
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// Tests formatting a char pointer when it's compared with another pointer.
|
|
1181
|
+
// In this case we want to print it as a raw pointer, as the comparison is by
|
|
1182
|
+
// pointer.
|
|
1183
|
+
|
|
1184
|
+
// char pointer vs pointer
|
|
1185
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsPointer) {
|
|
1186
|
+
// In expression 'p == x', where 'p' and 'x' are (const or not) char
|
|
1187
|
+
// pointers, the operands are compared by pointer. Therefore we
|
|
1188
|
+
// want to print 'p' as a pointer instead of a C string (we don't
|
|
1189
|
+
// even know if it's supposed to point to a valid C string).
|
|
1190
|
+
|
|
1191
|
+
// const char*
|
|
1192
|
+
const char* s = "hello";
|
|
1193
|
+
EXPECT_EQ(PrintPointer(s),
|
|
1194
|
+
FormatForComparisonFailureMessage(s, s).c_str());
|
|
1195
|
+
|
|
1196
|
+
// char*
|
|
1197
|
+
char ch = 'a';
|
|
1198
|
+
EXPECT_EQ(PrintPointer(&ch),
|
|
1199
|
+
FormatForComparisonFailureMessage(&ch, &ch).c_str());
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
// wchar_t pointer vs pointer
|
|
1203
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer) {
|
|
1204
|
+
// In expression 'p == x', where 'p' and 'x' are (const or not) char
|
|
1205
|
+
// pointers, the operands are compared by pointer. Therefore we
|
|
1206
|
+
// want to print 'p' as a pointer instead of a wide C string (we don't
|
|
1207
|
+
// even know if it's supposed to point to a valid wide C string).
|
|
1208
|
+
|
|
1209
|
+
// const wchar_t*
|
|
1210
|
+
const wchar_t* s = L"hello";
|
|
1211
|
+
EXPECT_EQ(PrintPointer(s),
|
|
1212
|
+
FormatForComparisonFailureMessage(s, s).c_str());
|
|
1213
|
+
|
|
1214
|
+
// wchar_t*
|
|
1215
|
+
wchar_t ch = L'a';
|
|
1216
|
+
EXPECT_EQ(PrintPointer(&ch),
|
|
1217
|
+
FormatForComparisonFailureMessage(&ch, &ch).c_str());
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// Tests formatting a char pointer when it's compared to a string object.
|
|
1221
|
+
// In this case we want to print the char pointer as a C string.
|
|
1222
|
+
|
|
1223
|
+
// char pointer vs std::string
|
|
1224
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString) {
|
|
1225
|
+
const char* s = "hello \"world";
|
|
1226
|
+
EXPECT_STREQ("\"hello \\\"world\"", // The string content should be escaped.
|
|
1227
|
+
FormatForComparisonFailureMessage(s, ::std::string()).c_str());
|
|
1228
|
+
|
|
1229
|
+
// char*
|
|
1230
|
+
char str[] = "hi\1";
|
|
1231
|
+
char* p = str;
|
|
1232
|
+
EXPECT_STREQ("\"hi\\x1\"", // The string content should be escaped.
|
|
1233
|
+
FormatForComparisonFailureMessage(p, ::std::string()).c_str());
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
#if GTEST_HAS_STD_WSTRING
|
|
1237
|
+
// wchar_t pointer vs std::wstring
|
|
1238
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) {
|
|
1239
|
+
const wchar_t* s = L"hi \"world";
|
|
1240
|
+
EXPECT_STREQ("L\"hi \\\"world\"", // The string content should be escaped.
|
|
1241
|
+
FormatForComparisonFailureMessage(s, ::std::wstring()).c_str());
|
|
1242
|
+
|
|
1243
|
+
// wchar_t*
|
|
1244
|
+
wchar_t str[] = L"hi\1";
|
|
1245
|
+
wchar_t* p = str;
|
|
1246
|
+
EXPECT_STREQ("L\"hi\\x1\"", // The string content should be escaped.
|
|
1247
|
+
FormatForComparisonFailureMessage(p, ::std::wstring()).c_str());
|
|
1248
|
+
}
|
|
1249
|
+
#endif
|
|
1250
|
+
|
|
1251
|
+
// Tests formatting a char array when it's compared with a pointer or array.
|
|
1252
|
+
// In this case we want to print the array as a row pointer, as the comparison
|
|
1253
|
+
// is by pointer.
|
|
1254
|
+
|
|
1255
|
+
// char array vs pointer
|
|
1256
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) {
|
|
1257
|
+
char str[] = "hi \"world\"";
|
|
1258
|
+
char* p = nullptr;
|
|
1259
|
+
EXPECT_EQ(PrintPointer(str),
|
|
1260
|
+
FormatForComparisonFailureMessage(str, p).c_str());
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
// char array vs char array
|
|
1264
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) {
|
|
1265
|
+
const char str[] = "hi \"world\"";
|
|
1266
|
+
EXPECT_EQ(PrintPointer(str),
|
|
1267
|
+
FormatForComparisonFailureMessage(str, str).c_str());
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// wchar_t array vs pointer
|
|
1271
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) {
|
|
1272
|
+
wchar_t str[] = L"hi \"world\"";
|
|
1273
|
+
wchar_t* p = nullptr;
|
|
1274
|
+
EXPECT_EQ(PrintPointer(str),
|
|
1275
|
+
FormatForComparisonFailureMessage(str, p).c_str());
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// wchar_t array vs wchar_t array
|
|
1279
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWCharArray) {
|
|
1280
|
+
const wchar_t str[] = L"hi \"world\"";
|
|
1281
|
+
EXPECT_EQ(PrintPointer(str),
|
|
1282
|
+
FormatForComparisonFailureMessage(str, str).c_str());
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// Tests formatting a char array when it's compared with a string object.
|
|
1286
|
+
// In this case we want to print the array as a C string.
|
|
1287
|
+
|
|
1288
|
+
// char array vs std::string
|
|
1289
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString) {
|
|
1290
|
+
const char str[] = "hi \"world\"";
|
|
1291
|
+
EXPECT_STREQ("\"hi \\\"world\\\"\"", // The content should be escaped.
|
|
1292
|
+
FormatForComparisonFailureMessage(str, ::std::string()).c_str());
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
#if GTEST_HAS_STD_WSTRING
|
|
1296
|
+
// wchar_t array vs std::wstring
|
|
1297
|
+
TEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsStdWString) {
|
|
1298
|
+
const wchar_t str[] = L"hi \"w\0rld\"";
|
|
1299
|
+
EXPECT_STREQ(
|
|
1300
|
+
"L\"hi \\\"w\"", // The content should be escaped.
|
|
1301
|
+
// Embedded NUL terminates the string.
|
|
1302
|
+
FormatForComparisonFailureMessage(str, ::std::wstring()).c_str());
|
|
1303
|
+
}
|
|
1304
|
+
#endif
|
|
1305
|
+
|
|
1306
|
+
// Useful for testing PrintToString(). We cannot use EXPECT_EQ()
|
|
1307
|
+
// there as its implementation uses PrintToString(). The caller must
|
|
1308
|
+
// ensure that 'value' has no side effect.
|
|
1309
|
+
#define EXPECT_PRINT_TO_STRING_(value, expected_string) \
|
|
1310
|
+
EXPECT_TRUE(PrintToString(value) == (expected_string)) \
|
|
1311
|
+
<< " where " #value " prints as " << (PrintToString(value))
|
|
1312
|
+
|
|
1313
|
+
TEST(PrintToStringTest, WorksForScalar) {
|
|
1314
|
+
EXPECT_PRINT_TO_STRING_(123, "123");
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
TEST(PrintToStringTest, WorksForPointerToConstChar) {
|
|
1318
|
+
const char* p = "hello";
|
|
1319
|
+
EXPECT_PRINT_TO_STRING_(p, "\"hello\"");
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
TEST(PrintToStringTest, WorksForPointerToNonConstChar) {
|
|
1323
|
+
char s[] = "hello";
|
|
1324
|
+
char* p = s;
|
|
1325
|
+
EXPECT_PRINT_TO_STRING_(p, "\"hello\"");
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
TEST(PrintToStringTest, EscapesForPointerToConstChar) {
|
|
1329
|
+
const char* p = "hello\n";
|
|
1330
|
+
EXPECT_PRINT_TO_STRING_(p, "\"hello\\n\"");
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
TEST(PrintToStringTest, EscapesForPointerToNonConstChar) {
|
|
1334
|
+
char s[] = "hello\1";
|
|
1335
|
+
char* p = s;
|
|
1336
|
+
EXPECT_PRINT_TO_STRING_(p, "\"hello\\x1\"");
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
TEST(PrintToStringTest, WorksForArray) {
|
|
1340
|
+
int n[3] = { 1, 2, 3 };
|
|
1341
|
+
EXPECT_PRINT_TO_STRING_(n, "{ 1, 2, 3 }");
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
TEST(PrintToStringTest, WorksForCharArray) {
|
|
1345
|
+
char s[] = "hello";
|
|
1346
|
+
EXPECT_PRINT_TO_STRING_(s, "\"hello\"");
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
TEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {
|
|
1350
|
+
const char str_with_nul[] = "hello\0 world";
|
|
1351
|
+
EXPECT_PRINT_TO_STRING_(str_with_nul, "\"hello\\0 world\"");
|
|
1352
|
+
|
|
1353
|
+
char mutable_str_with_nul[] = "hello\0 world";
|
|
1354
|
+
EXPECT_PRINT_TO_STRING_(mutable_str_with_nul, "\"hello\\0 world\"");
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
TEST(PrintToStringTest, ContainsNonLatin) {
|
|
1358
|
+
// Sanity test with valid UTF-8. Prints both in hex and as text.
|
|
1359
|
+
std::string non_ascii_str = ::std::string("오전 4:30");
|
|
1360
|
+
EXPECT_PRINT_TO_STRING_(non_ascii_str,
|
|
1361
|
+
"\"\\xEC\\x98\\xA4\\xEC\\xA0\\x84 4:30\"\n"
|
|
1362
|
+
" As Text: \"오전 4:30\"");
|
|
1363
|
+
non_ascii_str = ::std::string("From ä — ẑ");
|
|
1364
|
+
EXPECT_PRINT_TO_STRING_(non_ascii_str,
|
|
1365
|
+
"\"From \\xC3\\xA4 \\xE2\\x80\\x94 \\xE1\\xBA\\x91\""
|
|
1366
|
+
"\n As Text: \"From ä — ẑ\"");
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
TEST(IsValidUTF8Test, IllFormedUTF8) {
|
|
1370
|
+
// The following test strings are ill-formed UTF-8 and are printed
|
|
1371
|
+
// as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is
|
|
1372
|
+
// expected to fail, thus output does not contain "As Text:".
|
|
1373
|
+
|
|
1374
|
+
static const char *const kTestdata[][2] = {
|
|
1375
|
+
// 2-byte lead byte followed by a single-byte character.
|
|
1376
|
+
{"\xC3\x74", "\"\\xC3t\""},
|
|
1377
|
+
// Valid 2-byte character followed by an orphan trail byte.
|
|
1378
|
+
{"\xC3\x84\xA4", "\"\\xC3\\x84\\xA4\""},
|
|
1379
|
+
// Lead byte without trail byte.
|
|
1380
|
+
{"abc\xC3", "\"abc\\xC3\""},
|
|
1381
|
+
// 3-byte lead byte, single-byte character, orphan trail byte.
|
|
1382
|
+
{"x\xE2\x70\x94", "\"x\\xE2p\\x94\""},
|
|
1383
|
+
// Truncated 3-byte character.
|
|
1384
|
+
{"\xE2\x80", "\"\\xE2\\x80\""},
|
|
1385
|
+
// Truncated 3-byte character followed by valid 2-byte char.
|
|
1386
|
+
{"\xE2\x80\xC3\x84", "\"\\xE2\\x80\\xC3\\x84\""},
|
|
1387
|
+
// Truncated 3-byte character followed by a single-byte character.
|
|
1388
|
+
{"\xE2\x80\x7A", "\"\\xE2\\x80z\""},
|
|
1389
|
+
// 3-byte lead byte followed by valid 3-byte character.
|
|
1390
|
+
{"\xE2\xE2\x80\x94", "\"\\xE2\\xE2\\x80\\x94\""},
|
|
1391
|
+
// 4-byte lead byte followed by valid 3-byte character.
|
|
1392
|
+
{"\xF0\xE2\x80\x94", "\"\\xF0\\xE2\\x80\\x94\""},
|
|
1393
|
+
// Truncated 4-byte character.
|
|
1394
|
+
{"\xF0\xE2\x80", "\"\\xF0\\xE2\\x80\""},
|
|
1395
|
+
// Invalid UTF-8 byte sequences embedded in other chars.
|
|
1396
|
+
{"abc\xE2\x80\x94\xC3\x74xyc", "\"abc\\xE2\\x80\\x94\\xC3txyc\""},
|
|
1397
|
+
{"abc\xC3\x84\xE2\x80\xC3\x84xyz",
|
|
1398
|
+
"\"abc\\xC3\\x84\\xE2\\x80\\xC3\\x84xyz\""},
|
|
1399
|
+
// Non-shortest UTF-8 byte sequences are also ill-formed.
|
|
1400
|
+
// The classics: xC0, xC1 lead byte.
|
|
1401
|
+
{"\xC0\x80", "\"\\xC0\\x80\""},
|
|
1402
|
+
{"\xC1\x81", "\"\\xC1\\x81\""},
|
|
1403
|
+
// Non-shortest sequences.
|
|
1404
|
+
{"\xE0\x80\x80", "\"\\xE0\\x80\\x80\""},
|
|
1405
|
+
{"\xf0\x80\x80\x80", "\"\\xF0\\x80\\x80\\x80\""},
|
|
1406
|
+
// Last valid code point before surrogate range, should be printed as text,
|
|
1407
|
+
// too.
|
|
1408
|
+
{"\xED\x9F\xBF", "\"\\xED\\x9F\\xBF\"\n As Text: \"\""},
|
|
1409
|
+
// Start of surrogate lead. Surrogates are not printed as text.
|
|
1410
|
+
{"\xED\xA0\x80", "\"\\xED\\xA0\\x80\""},
|
|
1411
|
+
// Last non-private surrogate lead.
|
|
1412
|
+
{"\xED\xAD\xBF", "\"\\xED\\xAD\\xBF\""},
|
|
1413
|
+
// First private-use surrogate lead.
|
|
1414
|
+
{"\xED\xAE\x80", "\"\\xED\\xAE\\x80\""},
|
|
1415
|
+
// Last private-use surrogate lead.
|
|
1416
|
+
{"\xED\xAF\xBF", "\"\\xED\\xAF\\xBF\""},
|
|
1417
|
+
// Mid-point of surrogate trail.
|
|
1418
|
+
{"\xED\xB3\xBF", "\"\\xED\\xB3\\xBF\""},
|
|
1419
|
+
// First valid code point after surrogate range, should be printed as text,
|
|
1420
|
+
// too.
|
|
1421
|
+
{"\xEE\x80\x80", "\"\\xEE\\x80\\x80\"\n As Text: \"\""}
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
for (int i = 0; i < int(sizeof(kTestdata)/sizeof(kTestdata[0])); ++i) {
|
|
1425
|
+
EXPECT_PRINT_TO_STRING_(kTestdata[i][0], kTestdata[i][1]);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
#undef EXPECT_PRINT_TO_STRING_
|
|
1430
|
+
|
|
1431
|
+
TEST(UniversalTersePrintTest, WorksForNonReference) {
|
|
1432
|
+
::std::stringstream ss;
|
|
1433
|
+
UniversalTersePrint(123, &ss);
|
|
1434
|
+
EXPECT_EQ("123", ss.str());
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
TEST(UniversalTersePrintTest, WorksForReference) {
|
|
1438
|
+
const int& n = 123;
|
|
1439
|
+
::std::stringstream ss;
|
|
1440
|
+
UniversalTersePrint(n, &ss);
|
|
1441
|
+
EXPECT_EQ("123", ss.str());
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
TEST(UniversalTersePrintTest, WorksForCString) {
|
|
1445
|
+
const char* s1 = "abc";
|
|
1446
|
+
::std::stringstream ss1;
|
|
1447
|
+
UniversalTersePrint(s1, &ss1);
|
|
1448
|
+
EXPECT_EQ("\"abc\"", ss1.str());
|
|
1449
|
+
|
|
1450
|
+
char* s2 = const_cast<char*>(s1);
|
|
1451
|
+
::std::stringstream ss2;
|
|
1452
|
+
UniversalTersePrint(s2, &ss2);
|
|
1453
|
+
EXPECT_EQ("\"abc\"", ss2.str());
|
|
1454
|
+
|
|
1455
|
+
const char* s3 = nullptr;
|
|
1456
|
+
::std::stringstream ss3;
|
|
1457
|
+
UniversalTersePrint(s3, &ss3);
|
|
1458
|
+
EXPECT_EQ("NULL", ss3.str());
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
TEST(UniversalPrintTest, WorksForNonReference) {
|
|
1462
|
+
::std::stringstream ss;
|
|
1463
|
+
UniversalPrint(123, &ss);
|
|
1464
|
+
EXPECT_EQ("123", ss.str());
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
TEST(UniversalPrintTest, WorksForReference) {
|
|
1468
|
+
const int& n = 123;
|
|
1469
|
+
::std::stringstream ss;
|
|
1470
|
+
UniversalPrint(n, &ss);
|
|
1471
|
+
EXPECT_EQ("123", ss.str());
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
TEST(UniversalPrintTest, WorksForCString) {
|
|
1475
|
+
const char* s1 = "abc";
|
|
1476
|
+
::std::stringstream ss1;
|
|
1477
|
+
UniversalPrint(s1, &ss1);
|
|
1478
|
+
EXPECT_EQ(PrintPointer(s1) + " pointing to \"abc\"", std::string(ss1.str()));
|
|
1479
|
+
|
|
1480
|
+
char* s2 = const_cast<char*>(s1);
|
|
1481
|
+
::std::stringstream ss2;
|
|
1482
|
+
UniversalPrint(s2, &ss2);
|
|
1483
|
+
EXPECT_EQ(PrintPointer(s2) + " pointing to \"abc\"", std::string(ss2.str()));
|
|
1484
|
+
|
|
1485
|
+
const char* s3 = nullptr;
|
|
1486
|
+
::std::stringstream ss3;
|
|
1487
|
+
UniversalPrint(s3, &ss3);
|
|
1488
|
+
EXPECT_EQ("NULL", ss3.str());
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
TEST(UniversalPrintTest, WorksForCharArray) {
|
|
1492
|
+
const char str[] = "\"Line\0 1\"\nLine 2";
|
|
1493
|
+
::std::stringstream ss1;
|
|
1494
|
+
UniversalPrint(str, &ss1);
|
|
1495
|
+
EXPECT_EQ("\"\\\"Line\\0 1\\\"\\nLine 2\"", ss1.str());
|
|
1496
|
+
|
|
1497
|
+
const char mutable_str[] = "\"Line\0 1\"\nLine 2";
|
|
1498
|
+
::std::stringstream ss2;
|
|
1499
|
+
UniversalPrint(mutable_str, &ss2);
|
|
1500
|
+
EXPECT_EQ("\"\\\"Line\\0 1\\\"\\nLine 2\"", ss2.str());
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple) {
|
|
1504
|
+
Strings result = UniversalTersePrintTupleFieldsToStrings(::std::make_tuple());
|
|
1505
|
+
EXPECT_EQ(0u, result.size());
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsOneTuple) {
|
|
1509
|
+
Strings result = UniversalTersePrintTupleFieldsToStrings(
|
|
1510
|
+
::std::make_tuple(1));
|
|
1511
|
+
ASSERT_EQ(1u, result.size());
|
|
1512
|
+
EXPECT_EQ("1", result[0]);
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTwoTuple) {
|
|
1516
|
+
Strings result = UniversalTersePrintTupleFieldsToStrings(
|
|
1517
|
+
::std::make_tuple(1, 'a'));
|
|
1518
|
+
ASSERT_EQ(2u, result.size());
|
|
1519
|
+
EXPECT_EQ("1", result[0]);
|
|
1520
|
+
EXPECT_EQ("'a' (97, 0x61)", result[1]);
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
|
|
1524
|
+
const int n = 1;
|
|
1525
|
+
Strings result = UniversalTersePrintTupleFieldsToStrings(
|
|
1526
|
+
::std::tuple<const int&, const char*>(n, "a"));
|
|
1527
|
+
ASSERT_EQ(2u, result.size());
|
|
1528
|
+
EXPECT_EQ("1", result[0]);
|
|
1529
|
+
EXPECT_EQ("\"a\"", result[1]);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
#if GTEST_HAS_ABSL
|
|
1533
|
+
|
|
1534
|
+
TEST(PrintOptionalTest, Basic) {
|
|
1535
|
+
absl::optional<int> value;
|
|
1536
|
+
EXPECT_EQ("(nullopt)", PrintToString(value));
|
|
1537
|
+
value = {7};
|
|
1538
|
+
EXPECT_EQ("(7)", PrintToString(value));
|
|
1539
|
+
EXPECT_EQ("(1.1)", PrintToString(absl::optional<double>{1.1}));
|
|
1540
|
+
EXPECT_EQ("(\"A\")", PrintToString(absl::optional<std::string>{"A"}));
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
struct NonPrintable {
|
|
1544
|
+
unsigned char contents = 17;
|
|
1545
|
+
};
|
|
1546
|
+
|
|
1547
|
+
TEST(PrintOneofTest, Basic) {
|
|
1548
|
+
using Type = absl::variant<int, StreamableInGlobal, NonPrintable>;
|
|
1549
|
+
EXPECT_EQ("('int' with value 7)", PrintToString(Type(7)));
|
|
1550
|
+
EXPECT_EQ("('StreamableInGlobal' with value StreamableInGlobal)",
|
|
1551
|
+
PrintToString(Type(StreamableInGlobal{})));
|
|
1552
|
+
EXPECT_EQ(
|
|
1553
|
+
"('testing::gtest_printers_test::NonPrintable' with value 1-byte object "
|
|
1554
|
+
"<11>)",
|
|
1555
|
+
PrintToString(Type(NonPrintable{})));
|
|
1556
|
+
}
|
|
1557
|
+
#endif // GTEST_HAS_ABSL
|
|
1558
|
+
namespace {
|
|
1559
|
+
class string_ref;
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* This is a synthetic pointer to a fixed size string.
|
|
1563
|
+
*/
|
|
1564
|
+
class string_ptr {
|
|
1565
|
+
public:
|
|
1566
|
+
string_ptr(const char* data, size_t size) : data_(data), size_(size) {}
|
|
1567
|
+
|
|
1568
|
+
string_ptr& operator++() noexcept {
|
|
1569
|
+
data_ += size_;
|
|
1570
|
+
return *this;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
string_ref operator*() const noexcept;
|
|
1574
|
+
|
|
1575
|
+
private:
|
|
1576
|
+
const char* data_;
|
|
1577
|
+
size_t size_;
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* This is a synthetic reference of a fixed size string.
|
|
1582
|
+
*/
|
|
1583
|
+
class string_ref {
|
|
1584
|
+
public:
|
|
1585
|
+
string_ref(const char* data, size_t size) : data_(data), size_(size) {}
|
|
1586
|
+
|
|
1587
|
+
string_ptr operator&() const noexcept { return {data_, size_}; } // NOLINT
|
|
1588
|
+
|
|
1589
|
+
bool operator==(const char* s) const noexcept {
|
|
1590
|
+
if (size_ > 0 && data_[size_ - 1] != 0) {
|
|
1591
|
+
return std::string(data_, size_) == std::string(s);
|
|
1592
|
+
} else {
|
|
1593
|
+
return std::string(data_) == std::string(s);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
private:
|
|
1598
|
+
const char* data_;
|
|
1599
|
+
size_t size_;
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
string_ref string_ptr::operator*() const noexcept { return {data_, size_}; }
|
|
1603
|
+
|
|
1604
|
+
TEST(string_ref, compare) {
|
|
1605
|
+
const char* s = "alex\0davidjohn\0";
|
|
1606
|
+
string_ptr ptr(s, 5);
|
|
1607
|
+
EXPECT_EQ(*ptr, "alex");
|
|
1608
|
+
EXPECT_TRUE(*ptr == "alex");
|
|
1609
|
+
++ptr;
|
|
1610
|
+
EXPECT_EQ(*ptr, "david");
|
|
1611
|
+
EXPECT_TRUE(*ptr == "david");
|
|
1612
|
+
++ptr;
|
|
1613
|
+
EXPECT_EQ(*ptr, "john");
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
} // namespace
|
|
1617
|
+
|
|
1618
|
+
} // namespace gtest_printers_test
|
|
1619
|
+
} // namespace testing
|