couchbase 4.2.2 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- package/deps/couchbase-cxx-client/.github/workflows/sanitizers.yml +20 -12
- package/deps/couchbase-cxx-client/.github/workflows/tests.yml +5 -3
- package/deps/couchbase-cxx-client/.idea/vcs.xml +2 -0
- package/deps/couchbase-cxx-client/CMakeLists.txt +67 -8
- package/deps/couchbase-cxx-client/README.md +1 -0
- package/deps/couchbase-cxx-client/bin/build-tests +3 -0
- package/deps/couchbase-cxx-client/bin/build-tests.rb +9 -0
- package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
- package/deps/couchbase-cxx-client/bin/init-cluster +84 -12
- package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
- package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
- package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
- package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +12 -4
- package/deps/couchbase-cxx-client/cmake/Documentation.cmake +4 -4
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +147 -7
- package/deps/couchbase-cxx-client/cmake/Testing.cmake +12 -4
- package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +4 -0
- package/deps/couchbase-cxx-client/cmake/VersionInfo.cmake +39 -3
- package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
- package/deps/couchbase-cxx-client/cmake/test_openssl.cxx +7 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +183 -151
- package/deps/couchbase-cxx-client/core/bucket.hxx +23 -1
- package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
- package/deps/couchbase-cxx-client/core/cluster_options.cxx +2 -2
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +4 -7
- package/deps/couchbase-cxx-client/core/cluster_options_fwd.hxx +26 -0
- package/deps/couchbase-cxx-client/core/config_profile.hxx +2 -65
- package/deps/couchbase-cxx-client/core/config_profiles.cxx +79 -0
- package/deps/couchbase-cxx-client/core/config_profiles.hxx +56 -0
- package/deps/couchbase-cxx-client/core/crypto/CMakeLists.txt +5 -1
- package/deps/couchbase-cxx-client/core/error_context/analytics.hxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/http.hxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
- package/deps/couchbase-cxx-client/core/error_context/query.hxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/search.hxx +3 -2
- package/deps/couchbase-cxx-client/core/error_context/view.hxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +237 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +2 -1
- package/deps/couchbase-cxx-client/core/impl/collection_query_index_manager.cxx +3 -3
- package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
- package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/dns_srv_tracker.cxx +5 -3
- package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/get_all_query_indexes.cxx +3 -3
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
- package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
- package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/query.cxx +19 -17
- package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
- package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
- package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
- package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
- package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/subdoc/lookup_in_macro.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/subdoc/mutate_in_macro.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
- package/deps/couchbase-cxx-client/core/impl/transaction_get_result.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/io/dns_client.cxx +225 -0
- package/deps/couchbase-cxx-client/core/io/dns_client.hxx +19 -188
- package/deps/couchbase-cxx-client/core/io/http_context.hxx +1 -1
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +10 -0
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +5 -3
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +79 -35
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
- package/deps/couchbase-cxx-client/core/io/retry_orchestrator.hxx +3 -2
- package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
- package/deps/couchbase-cxx-client/core/meta/CMakeLists.txt +7 -5
- package/deps/couchbase-cxx-client/core/meta/version.cxx +37 -4
- package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
- package/deps/couchbase-cxx-client/core/operations/document_analytics.cxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_analytics.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/document_append.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_decrement.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_exists.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_get.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_get_and_lock.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_get_and_touch.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_get_projected.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_increment.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_insert.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_mutate_in.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_prepend.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/document_query.hxx +6 -0
- package/deps/couchbase-cxx-client/core/operations/document_remove.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_replace.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +9 -3
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +2 -2
- package/deps/couchbase-cxx-client/core/operations/document_touch.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_unlock.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_upsert.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/analytics_problem.hxx +2 -1
- package/deps/couchbase-cxx-client/core/operations/management/eventing_problem.hxx +2 -1
- package/deps/couchbase-cxx-client/core/platform/base64.cc +2 -1
- package/deps/couchbase-cxx-client/core/protocol/client_opcode.hxx +1 -0
- package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
- package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
- package/deps/couchbase-cxx-client/core/protocol/cmd_info.hxx +2 -1
- package/deps/couchbase-cxx-client/core/public_fwd.hxx +21 -0
- package/deps/couchbase-cxx-client/core/tls_verify_mode.hxx +26 -0
- package/deps/couchbase-cxx-client/core/topology/configuration.cxx +15 -2
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +5 -1
- package/deps/couchbase-cxx-client/core/transactions/active_transaction_record.hxx +2 -2
- package/deps/couchbase-cxx-client/core/transactions/atr_cleanup_entry.cxx +1 -0
- package/deps/couchbase-cxx-client/core/transactions/atr_ids.cxx +1 -1
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.cxx +78 -44
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_impl.hxx +90 -59
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.cxx +93 -0
- package/deps/couchbase-cxx-client/core/transactions/attempt_context_testing_hooks.hxx +48 -75
- package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.cxx +52 -0
- package/deps/couchbase-cxx-client/core/transactions/cleanup_testing_hooks.hxx +17 -31
- package/deps/couchbase-cxx-client/core/transactions/exceptions.cxx +0 -1
- package/deps/couchbase-cxx-client/core/transactions/exceptions.hxx +14 -11
- package/deps/couchbase-cxx-client/core/transactions/forward_compat.hxx +2 -2
- package/deps/couchbase-cxx-client/core/transactions/internal/transaction_context.hxx +14 -14
- package/deps/couchbase-cxx-client/core/transactions/internal/transaction_fields.hxx +1 -0
- package/deps/couchbase-cxx-client/core/transactions/internal/transactions_cleanup.hxx +7 -1
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.cxx +1 -1
- package/deps/couchbase-cxx-client/core/transactions/staged_mutation.hxx +12 -2
- package/deps/couchbase-cxx-client/core/transactions/transaction_context.cxx +9 -11
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.cxx +41 -31
- package/deps/couchbase-cxx-client/core/transactions/transaction_get_result.hxx +69 -21
- package/deps/couchbase-cxx-client/core/transactions/transaction_links.hxx +13 -1
- package/deps/couchbase-cxx-client/core/transactions/transactions.cxx +5 -4
- package/deps/couchbase-cxx-client/core/transactions/transactions_cleanup.cxx +144 -155
- package/deps/couchbase-cxx-client/core/transactions/waitable_op_list.hxx +1 -0
- package/deps/couchbase-cxx-client/core/transactions.hxx +1 -1
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +81 -46
- package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +4 -3
- package/deps/couchbase-cxx-client/core/utils/crc32.hxx +3 -2
- package/deps/couchbase-cxx-client/core/utils/json.cxx +4 -1
- package/deps/couchbase-cxx-client/core/utils/json_streaming_lexer.hxx +2 -1
- package/deps/couchbase-cxx-client/core/utils/url_codec.cxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +143 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_meta_data.hxx +155 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_metrics.hxx +163 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_options.hxx +359 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_result.hxx +102 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_scan_consistency.hxx +46 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_status.hxx +41 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_warning.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/behavior_options.hxx +10 -1
- package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +77 -3
- package/deps/couchbase-cxx-client/couchbase/cluster_options.hxx +10 -10
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +22 -17
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/common_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/configuration_profile.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/configuration_profiles_registry.hxx +0 -1
- package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
- package/deps/couchbase-cxx-client/couchbase/create_primary_query_index_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
- package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
- package/deps/couchbase-cxx-client/couchbase/drop_primary_query_index_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/drop_query_index_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
- package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/analytics_status.hxx +76 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/cas.hxx +12 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/durability_level.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/key_value_error_map_attribute.hxx +94 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/key_value_extended_error_info.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/mutation_token.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/query_scan_consistency.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/query_status.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/retry_reason.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/tls_verify_mode.hxx +6 -0
- package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
- package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
- package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/get_all_query_indexes_options.hxx +5 -4
- package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
- package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
- package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
- package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
- package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +4 -2
- package/deps/couchbase-cxx-client/couchbase/query_options.hxx +0 -1
- package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
- package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +74 -1
- package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
- package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
- package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
- package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
- package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
- package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
- package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/array_add_unique.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/array_append.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/array_insert.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/array_prepend.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/count.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/counter.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/exists.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/get.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/insert.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/remove.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdoc/replace.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/subdoc/upsert.hxx +2 -0
- package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
- package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
- package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
- package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
- package/deps/couchbase-cxx-client/couchbase/tracing/request_span.hxx +63 -0
- package/deps/couchbase-cxx-client/couchbase/tracing/request_tracer.hxx +2 -40
- package/deps/couchbase-cxx-client/couchbase/transaction_op_error_context.hxx +4 -4
- package/deps/couchbase-cxx-client/couchbase/transactions/async_attempt_context.hxx +93 -14
- package/deps/couchbase-cxx-client/couchbase/transactions/attempt_context.hxx +88 -15
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_get_result.hxx +55 -35
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_keyspace.hxx +11 -1
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +79 -8
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +128 -15
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_result.hxx +6 -21
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -2
- package/deps/couchbase-cxx-client/couchbase/transactions/transactions_cleanup_config.hxx +5 -3
- package/deps/couchbase-cxx-client/couchbase/transactions/transactions_config.hxx +9 -5
- package/deps/couchbase-cxx-client/couchbase/transactions/transactions_query_config.hxx +6 -3
- package/deps/couchbase-cxx-client/couchbase/transactions.hxx +37 -3
- package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
- package/deps/couchbase-cxx-client/docs/Doxyfile.in +325 -224
- package/deps/couchbase-cxx-client/docs/cbc-analytics.md +171 -0
- package/deps/couchbase-cxx-client/docs/cbc-get.md +161 -0
- package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +168 -0
- package/deps/couchbase-cxx-client/docs/cbc-query.md +179 -0
- package/deps/couchbase-cxx-client/docs/cbc.md +46 -0
- package/deps/couchbase-cxx-client/docs/cli.hxx +33 -0
- package/deps/couchbase-cxx-client/docs/doxygen-awesome.css +474 -89
- package/deps/couchbase-cxx-client/docs/mainpage.hxx +46 -8
- package/deps/couchbase-cxx-client/docs/stability.hxx +15 -0
- package/deps/couchbase-cxx-client/examples/async_game_server.cxx +56 -54
- package/deps/couchbase-cxx-client/examples/distributed_mutex.cxx +2 -0
- package/deps/couchbase-cxx-client/examples/game_server.cxx +9 -10
- package/deps/couchbase-cxx-client/test/CMakeLists.txt +10 -7
- package/deps/couchbase-cxx-client/test/benchmark_helper_integration.hxx +2 -2
- package/deps/couchbase-cxx-client/test/data/search_beers_dataset.json +70 -0
- package/deps/couchbase-cxx-client/test/data/search_beers_index_params.json +108 -0
- package/deps/couchbase-cxx-client/test/test_helper.hxx +6 -6
- package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +314 -16
- package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +19 -2
- package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +11 -5
- package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
- package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +454 -0
- package/deps/couchbase-cxx-client/test/test_integration_management.cxx +162 -94
- package/deps/couchbase-cxx-client/test/test_integration_query.cxx +68 -10
- package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
- package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
- package/deps/couchbase-cxx-client/test/test_integration_search.cxx +621 -0
- package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +62 -11
- package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +5 -0
- package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +13 -5
- package/deps/couchbase-cxx-client/test/test_transaction_context.cxx +550 -0
- package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +195 -0
- package/deps/couchbase-cxx-client/test/test_transaction_public_async_api.cxx +393 -0
- package/deps/couchbase-cxx-client/test/test_transaction_public_blocking_api.cxx +653 -0
- package/deps/couchbase-cxx-client/test/test_transaction_simple.cxx +984 -0
- package/deps/couchbase-cxx-client/test/test_transaction_simple_async.cxx +970 -0
- package/deps/couchbase-cxx-client/test/test_unit_config_profiles.cxx +13 -13
- package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +64 -0
- package/deps/couchbase-cxx-client/test/test_unit_json_transcoder.cxx +4 -0
- package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
- package/deps/couchbase-cxx-client/test/test_unit_transaction_utils.cxx +113 -0
- package/deps/couchbase-cxx-client/test/test_unit_utils.cxx +8 -4
- package/deps/couchbase-cxx-client/test/utils/CMakeLists.txt +13 -9
- package/deps/couchbase-cxx-client/test/utils/integration_shortcuts.hxx +3 -3
- package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +20 -9
- package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
- package/deps/couchbase-cxx-client/test/utils/server_version.hxx +39 -13
- package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
- package/deps/couchbase-cxx-client/test/utils/test_data.cxx +41 -0
- package/deps/couchbase-cxx-client/test/utils/test_data.hxx +29 -0
- package/deps/couchbase-cxx-client/test/utils/wait_until.cxx +61 -0
- package/deps/couchbase-cxx-client/test/utils/wait_until.hxx +8 -1
- package/deps/couchbase-cxx-client/third_party/catch2/.bazelrc +10 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.conan/build.py +4 -4
- package/deps/couchbase-cxx-client/third_party/catch2/.conan/test_package/CMakeLists.txt +5 -4
- package/deps/couchbase-cxx-client/third_party/catch2/.conan/test_package/conanfile.py +3 -2
- package/deps/couchbase-cxx-client/third_party/catch2/.conan/test_package/test_package.cpp +1 -3
- package/deps/couchbase-cxx-client/third_party/catch2/.github/FUNDING.yml +1 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/linux-bazel-builds.yml +24 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/linux-meson-builds.yml +43 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/linux-other-builds.yml +104 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/linux-simple-builds.yml +122 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/mac-builds.yml +52 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/validate-header-guards.yml +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/.github/workflows/windows-simple-builds.yml +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/BUILD.bazel +83 -8
- package/deps/couchbase-cxx-client/third_party/catch2/CMake/CatchConfigOptions.cmake +79 -0
- package/deps/couchbase-cxx-client/third_party/catch2/CMake/CatchMiscFunctions.cmake +120 -0
- package/deps/couchbase-cxx-client/third_party/catch2/CMake/catch2-with-main.pc.in +10 -0
- package/deps/couchbase-cxx-client/third_party/catch2/CMake/catch2.pc.in +5 -1
- package/deps/couchbase-cxx-client/third_party/catch2/CMakeLists.txt +98 -152
- package/deps/couchbase-cxx-client/third_party/catch2/CMakePresets.json +25 -0
- package/deps/couchbase-cxx-client/third_party/catch2/Doxyfile +2484 -0
- package/deps/couchbase-cxx-client/third_party/catch2/README.md +83 -17
- package/deps/couchbase-cxx-client/third_party/catch2/SECURITY.md +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/WORKSPACE.bazel +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/appveyor.yml +55 -73
- package/deps/couchbase-cxx-client/third_party/catch2/codecov.yml +3 -6
- package/deps/couchbase-cxx-client/third_party/catch2/conanfile.py +44 -14
- package/deps/couchbase-cxx-client/third_party/catch2/data/artwork/catch2-logo-small-with-background.png +0 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/Readme.md +18 -16
- package/deps/couchbase-cxx-client/third_party/catch2/docs/assertions.md +45 -64
- package/deps/couchbase-cxx-client/third_party/catch2/docs/benchmarks.md +3 -6
- package/deps/couchbase-cxx-client/third_party/catch2/docs/ci-and-misc.md +27 -29
- package/deps/couchbase-cxx-client/third_party/catch2/docs/cmake-integration.md +157 -35
- package/deps/couchbase-cxx-client/third_party/catch2/docs/command-line.md +232 -65
- package/deps/couchbase-cxx-client/third_party/catch2/docs/commercial-users.md +14 -13
- package/deps/couchbase-cxx-client/third_party/catch2/docs/comparing-floating-point-numbers.md +192 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/configuration.md +48 -54
- package/deps/couchbase-cxx-client/third_party/catch2/docs/contributing.md +150 -38
- package/deps/couchbase-cxx-client/third_party/catch2/docs/deprecations.md +14 -118
- package/deps/couchbase-cxx-client/third_party/catch2/docs/event-listeners.md +31 -62
- package/deps/couchbase-cxx-client/third_party/catch2/docs/faq.md +94 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/generators.md +14 -10
- package/deps/couchbase-cxx-client/third_party/catch2/docs/limitations.md +34 -36
- package/deps/couchbase-cxx-client/third_party/catch2/docs/list-of-examples.md +0 -3
- package/deps/couchbase-cxx-client/third_party/catch2/docs/logging.md +2 -2
- package/deps/couchbase-cxx-client/third_party/catch2/docs/matchers.md +355 -122
- package/deps/couchbase-cxx-client/third_party/catch2/docs/migrate-v2-to-v3.md +98 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/opensource-users.md +43 -13
- package/deps/couchbase-cxx-client/third_party/catch2/docs/other-macros.md +19 -18
- package/deps/couchbase-cxx-client/third_party/catch2/docs/own-main.md +50 -49
- package/deps/couchbase-cxx-client/third_party/catch2/docs/release-notes.md +375 -6
- package/deps/couchbase-cxx-client/third_party/catch2/docs/release-process.md +9 -16
- package/deps/couchbase-cxx-client/third_party/catch2/docs/reporter-events.md +175 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/reporters.md +191 -25
- package/deps/couchbase-cxx-client/third_party/catch2/docs/skipping-passing-failing.md +129 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/test-cases-and-sections.md +91 -20
- package/deps/couchbase-cxx-client/third_party/catch2/docs/test-fixtures.md +28 -9
- package/deps/couchbase-cxx-client/third_party/catch2/docs/tostring.md +3 -3
- package/deps/couchbase-cxx-client/third_party/catch2/docs/tutorial.md +87 -139
- package/deps/couchbase-cxx-client/third_party/catch2/docs/usage-tips.md +100 -0
- package/deps/couchbase-cxx-client/third_party/catch2/docs/why-catch.md +24 -11
- package/deps/couchbase-cxx-client/third_party/catch2/examples/010-TestCase.cpp +4 -7
- package/deps/couchbase-cxx-client/third_party/catch2/examples/020-TestCase-1.cpp +3 -9
- package/deps/couchbase-cxx-client/third_party/catch2/examples/020-TestCase-2.cpp +2 -2
- package/deps/couchbase-cxx-client/third_party/catch2/examples/030-Asn-Require-Check.cpp +5 -5
- package/deps/couchbase-cxx-client/third_party/catch2/examples/100-Fix-Section.cpp +5 -4
- package/deps/couchbase-cxx-client/third_party/catch2/examples/110-Fix-ClassFixture.cpp +7 -4
- package/deps/couchbase-cxx-client/third_party/catch2/examples/120-Bdd-ScenarioGivenWhenThen.cpp +4 -4
- package/deps/couchbase-cxx-client/third_party/catch2/examples/210-Evt-EventListeners.cpp +51 -44
- package/deps/couchbase-cxx-client/third_party/catch2/examples/231-Cfg-OutputStreams.cpp +3 -4
- package/deps/couchbase-cxx-client/third_party/catch2/examples/300-Gen-OwnGenerator.cpp +13 -3
- package/deps/couchbase-cxx-client/third_party/catch2/examples/301-Gen-MapTypeConversion.cpp +9 -7
- package/deps/couchbase-cxx-client/third_party/catch2/examples/302-Gen-Table.cpp +4 -3
- package/deps/couchbase-cxx-client/third_party/catch2/examples/310-Gen-VariablesInGenerators.cpp +3 -1
- package/deps/couchbase-cxx-client/third_party/catch2/examples/311-Gen-CustomCapture.cpp +3 -1
- package/deps/couchbase-cxx-client/third_party/catch2/examples/CMakeLists.txt +29 -126
- package/deps/couchbase-cxx-client/third_party/catch2/extras/Catch.cmake +279 -0
- package/deps/couchbase-cxx-client/third_party/catch2/extras/CatchAddTests.cmake +187 -0
- package/deps/couchbase-cxx-client/third_party/catch2/extras/CatchShardTests.cmake +74 -0
- package/deps/couchbase-cxx-client/third_party/catch2/extras/CatchShardTestsImpl.cmake +52 -0
- package/deps/couchbase-cxx-client/third_party/catch2/extras/catch_amalgamated.cpp +10655 -0
- package/deps/couchbase-cxx-client/third_party/catch2/extras/catch_amalgamated.hpp +12972 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/CMakeLists.txt +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/NullOStream.cpp +10 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/NullOStream.h +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/build_fuzzers.sh +33 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/fuzz_TestSpecParser.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/fuzz_XmlWriter.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/fuzzing/fuzz_textflow.cpp +47 -0
- package/deps/couchbase-cxx-client/third_party/catch2/mdsnippets.json +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/meson.build +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/CMakeLists.txt +510 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_benchmark.hpp +147 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_benchmark_all.hpp +46 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_chronometer.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_chronometer.hpp +74 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_clock.hpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_constructor.hpp +82 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_environment.hpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_estimate.hpp +30 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_execution_plan.hpp +58 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_optimizer.hpp +78 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_outlier_classification.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/catch_sample_analysis.hpp +49 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_analyse.hpp +79 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_benchmark_function.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_benchmark_function.hpp +107 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_benchmark_stats.hpp +64 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp +23 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_complete_invoke.hpp +58 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_estimate_clock.hpp +121 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_measure.hpp +32 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_repeat.hpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_run_for_at_least.cpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_run_for_at_least.hpp +65 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_stats.cpp +257 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_stats.hpp +144 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/benchmark/detail/catch_timing.hpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_all.hpp +127 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_approx.cpp +85 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_approx.hpp +128 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_assertion_info.hpp +28 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_assertion_result.cpp +105 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_assertion_result.hpp +60 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_config.cpp +247 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_config.hpp +153 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_get_random_seed.cpp +18 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_get_random_seed.hpp +18 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_message.cpp +116 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_message.hpp +148 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_registry_hub.cpp +105 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_section_info.hpp +42 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_session.cpp +363 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_session.hpp +62 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_tag_alias.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_tag_alias_autoregistrar.cpp +24 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_tag_alias_autoregistrar.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_template_test_macros.hpp +124 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_test_case_info.cpp +247 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_test_case_info.hpp +131 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_test_macros.hpp +226 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_test_spec.cpp +138 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_test_spec.hpp +119 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_timer.cpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_timer.hpp +27 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_tostring.cpp +254 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_tostring.hpp +668 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_totals.cpp +65 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_totals.hpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_translate_exception.cpp +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_translate_exception.hpp +88 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_user_config.hpp.in +210 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_version.cpp +43 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_version.hpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/catch_version_macros.hpp +15 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generator_exception.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generator_exception.hpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators.cpp +42 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators.hpp +250 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators_adapters.hpp +241 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators_all.hpp +30 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators_random.cpp +13 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators_random.hpp +98 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/generators/catch_generators_range.hpp +110 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_all.hpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_capture.cpp +13 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_capture.hpp +109 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_config.cpp +13 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_config.hpp +100 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp +47 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_exception.cpp +14 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_exception.hpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_generatortracker.cpp +32 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_generatortracker.hpp +90 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_registry_hub.cpp +14 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_registry_hub.hpp +66 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_reporter.cpp +101 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_reporter.hpp +224 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp +14 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_test_invoker.hpp +21 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_testcase.cpp +13 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/interfaces/catch_interfaces_testcase.hpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_assertion_handler.cpp +82 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_assertion_handler.hpp +68 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_case_insensitive_comparisons.cpp +35 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_case_insensitive_comparisons.hpp +30 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_case_sensitive.hpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_clara.cpp +448 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_clara.hpp +702 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_commandline.cpp +313 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_commandline.hpp +21 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_compare_traits.hpp +75 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_compiler_capabilities.hpp +430 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_config_android_logwrite.hpp +33 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_config_counter.hpp +32 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_config_uncaught_exceptions.hpp +44 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_config_wchar.hpp +33 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_console_colour.cpp +282 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_console_colour.hpp +141 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_console_width.hpp +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_container_nonmembers.hpp +73 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_context.cpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_context.hpp +51 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_debug_console.cpp +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_debug_console.hpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_debugger.cpp +120 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_debugger.hpp +67 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_decomposer.cpp +23 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_decomposer.hpp +340 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_enforce.cpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_enforce.hpp +54 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_enum_values_registry.cpp +73 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_enum_values_registry.hpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_errno_guard.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_errno_guard.hpp +27 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_exception_translator_registry.cpp +84 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_exception_translator_registry.hpp +30 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_fatal_condition_handler.cpp +243 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_fatal_condition_handler.hpp +69 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_floating_point_helpers.cpp +32 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_floating_point_helpers.hpp +103 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_getenv.cpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_getenv.hpp +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_is_permutation.hpp +138 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_istream.cpp +159 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_istream.hpp +54 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_lazy_expr.cpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_lazy_expr.hpp +40 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_leak_detector.cpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_leak_detector.hpp +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_list.cpp +123 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_list.hpp +43 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_logical_traits.hpp +44 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_main.cpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_message_info.cpp +25 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_message_info.hpp +42 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_meta.hpp +47 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_move_and_forward.hpp +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_noncopyable.hpp +28 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_optional.hpp +100 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_output_redirect.cpp +146 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_output_redirect.hpp +118 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_parse_numbers.cpp +52 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_parse_numbers.hpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_platform.hpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_polyfills.cpp +34 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_polyfills.hpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_preprocessor.hpp +237 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_preprocessor_remove_parens.hpp +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_random_number_generator.cpp +70 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_random_number_generator.hpp +59 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_random_seed_generation.cpp +34 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_random_seed_generation.hpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reporter_registry.cpp +88 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reporter_registry.hpp +55 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reporter_spec_parser.cpp +173 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reporter_spec_parser.hpp +85 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_result_type.cpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_result_type.hpp +57 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reusable_string_stream.cpp +62 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_reusable_string_stream.hpp +57 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_run_context.cpp +688 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_run_context.hpp +160 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_section.cpp +60 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_section.hpp +53 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_sharding.hpp +42 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_singletons.cpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_singletons.hpp +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_source_line_info.cpp +33 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_source_line_info.hpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_startup_exception_registry.cpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_startup_exception_registry.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_stdstreams.cpp +24 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_stdstreams.hpp +22 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_stream_end_stop.hpp +30 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_string_manip.cpp +104 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_string_manip.hpp +61 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_stringref.cpp +66 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_stringref.hpp +121 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_tag_alias_registry.cpp +55 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_tag_alias_registry.hpp +33 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_template_test_registry.hpp +337 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_info_hasher.cpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_info_hasher.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_registry_impl.cpp +146 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_registry_impl.hpp +62 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_tracker.cpp +239 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_case_tracker.hpp +244 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_failure_exception.cpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_failure_exception.hpp +34 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_macro_impl.hpp +159 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_registry.cpp +82 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_registry.hpp +132 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_run_info.hpp +22 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_spec_parser.cpp +239 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_test_spec_parser.hpp +81 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_textflow.cpp +255 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_textflow.hpp +169 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_to_string.hpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_uncaught_exceptions.cpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_uncaught_exceptions.hpp +15 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_unique_name.hpp +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_unique_ptr.hpp +118 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_void_type.hpp +25 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_wildcard_pattern.cpp +47 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_wildcard_pattern.hpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_windows_h_proxy.hpp +28 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_xmlwriter.cpp +348 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/internal/catch_xmlwriter.hpp +152 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers.cpp +25 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers.hpp +237 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_all.hpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_container_properties.cpp +34 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_container_properties.hpp +90 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_contains.hpp +102 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_exception.cpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_exception.hpp +61 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_floating_point.cpp +241 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_floating_point.hpp +94 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_predicate.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_predicate.hpp +59 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_quantifiers.cpp +24 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_quantifiers.hpp +165 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_range_equals.hpp +144 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_string.cpp +114 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_string.hpp +85 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_templated.cpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_templated.hpp +296 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/catch_matchers_vector.hpp +194 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/internal/catch_matchers_impl.cpp +25 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/matchers/internal/catch_matchers_impl.hpp +83 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/meson.build +368 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_automake.cpp +37 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_automake.hpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_common_base.cpp +49 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_common_base.hpp +79 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_compact.cpp +254 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_compact.hpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_console.cpp +656 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_console.hpp +67 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_cumulative_base.cpp +159 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_cumulative_base.hpp +151 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_event_listener.cpp +40 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_event_listener.hpp +60 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_helpers.cpp +343 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_helpers.hpp +95 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_junit.cpp +309 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_junit.hpp +58 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_multi.cpp +197 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_multi.hpp +72 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_registrars.cpp +36 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_registrars.hpp +131 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_sonarqube.cpp +162 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_sonarqube.hpp +61 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_streaming_base.cpp +23 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_streaming_base.hpp +73 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_tap.cpp +229 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_tap.hpp +43 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_teamcity.cpp +177 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_teamcity.hpp +66 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_xml.cpp +336 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporter_xml.hpp +66 -0
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch2/reporters/catch_reporters_all.hpp +40 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/CMakeLists.txt +665 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/CMakeLists.txt +554 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/ToDo.txt +10 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X01-PrefixedMacros.cpp +97 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X02-DisabledMacros.cpp +65 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp +39 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp +40 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X05-DeferredStaticChecks.cpp +21 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X10-FallbackStringifier.cpp +35 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X11-DisableStringification.cpp +27 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X12-CustomDebugBreakMacro.cpp +26 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X21-PartialTestCaseEvents.cpp +74 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp +79 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X23-CasingInReporterNames.cpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X24-ListenerStdoutCaptureInMultireporter.cpp +40 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X25-ListenerCanAskForCapturedStdout.cpp +47 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp +52 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp +82 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp +99 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp +59 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X30-BazelReporter.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X31-DuplicatedTestCases.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X32-DuplicatedTestCasesDifferentTags.cpp +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X33-DuplicatedTestCaseMethods.cpp +22 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp +27 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X35-DuplicatedReporterNames.cpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X90-WindowsHeaderInclusion.cpp +21 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X91-AmalgamatedCatch.cpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X92-NoTests.cpp +11 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/ExtraTests/X93-AllSkipped.cpp +16 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/automake.sw.approved.txt +420 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +409 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/compact.sw.approved.txt +2544 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +2533 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/console.std.approved.txt +1538 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/console.sw.approved.txt +18236 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/console.sw.multi.approved.txt +18225 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/console.swa4.approved.txt +956 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/default.sw.multi.approved.txt +11 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/junit.sw.approved.txt +2052 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +2051 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +2071 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +2070 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/tap.sw.approved.txt +4481 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +4470 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/teamcity.sw.approved.txt +998 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +997 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/xml.sw.approved.txt +21208 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +21207 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Algorithms.tests.cpp +94 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Clara.tests.cpp +73 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +467 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp +111 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/ColourImpl.tests.cpp +64 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +131 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp +74 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +546 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp +447 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Parse.tests.cpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +254 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp +62 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +328 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Sharding.tests.cpp +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Stream.tests.cpp +32 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/String.tests.cpp +212 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp +83 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp +104 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/TestCaseInfoHasher.tests.cpp +72 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp +365 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/TestSpecParser.tests.cpp +55 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp +200 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp +97 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Traits.tests.cpp +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/UniquePtr.tests.cpp +141 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp +183 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/TestRegistrations.cpp +181 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/TimingTests/Sleep.tests.cpp +24 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Approx.tests.cpp +218 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/BDD.tests.cpp +106 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Benchmark.tests.cpp +173 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Class.tests.cpp +133 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Compilation.tests.cpp +355 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Condition.tests.cpp +334 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Decomposition.tests.cpp +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/EnumToString.tests.cpp +108 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Exception.tests.cpp +204 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Generators.tests.cpp +313 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Matchers.tests.cpp +1144 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +917 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Message.tests.cpp +287 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Misc.tests.cpp +553 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Skip.tests.cpp +73 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringByte.tests.cpp +23 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringChrono.tests.cpp +51 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp +211 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringOptional.tests.cpp +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringPair.tests.cpp +38 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp +54 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringVariant.tests.cpp +99 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringVector.tests.cpp +94 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/ToStringWhich.tests.cpp +186 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/Tricky.tests.cpp +380 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/UsageTests/VariadicMacros.tests.cpp +29 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/helpers/parse_test_spec.cpp +22 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/helpers/parse_test_spec.hpp +20 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/helpers/range_test_helpers.hpp +210 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/SelfTest/helpers/type_with_lit_0_comparisons.hpp +44 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/ConfigureTestsCommon.py +75 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testBazelReporter.py +104 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testBazelSharding.py +75 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testConfigureDefaultReporter.py +41 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testConfigureDisable.py +48 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testConfigureDisableStringification.py +44 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testConfigureExperimentalRedirect.py +49 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testPartialTestCaseEvent.py +79 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testRandomOrder.py +77 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/TestScripts/testSharding.py +165 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tests/meson.build +76 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/misc/appveyorBuildConfigurationScript.bat +21 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/misc/appveyorMergeCoverageScript.py +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/misc/appveyorTestRunScript.bat +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/misc/coverage-helper.cpp +142 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/misc/installOpenCppCoverage.ps1 +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/approvalTests.py +243 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/approve.py +31 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/buildAndTest.cmd +17 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/buildAndTest.sh +19 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/checkConvenienceHeaders.py +151 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/checkDuplicateFilenames.py +14 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/checkLicense.py +45 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/developBuild.py +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/extractFeaturesFromReleaseNotes.py +92 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/fixWhitespace.py +51 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/generateAmalgamatedFiles.py +129 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/majorRelease.py +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/minorRelease.py +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/patchRelease.py +9 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/releaseCommon.py +143 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/scriptCommon.py +4 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/updateDocumentSnippets.py +23 -0
- package/deps/couchbase-cxx-client/third_party/catch2/tools/scripts/updateDocumentToC.py +447 -0
- package/deps/couchbase-cxx-client/third_party/snappy/.github/workflows/build.yml +135 -0
- package/deps/couchbase-cxx-client/third_party/snappy/.gitmodules +6 -0
- package/deps/couchbase-cxx-client/third_party/snappy/CMakeLists.txt +150 -27
- package/deps/couchbase-cxx-client/third_party/snappy/CONTRIBUTING.md +9 -4
- package/deps/couchbase-cxx-client/third_party/snappy/NEWS +12 -0
- package/deps/couchbase-cxx-client/third_party/snappy/README.md +52 -35
- package/deps/couchbase-cxx-client/third_party/snappy/cmake/config.h.in +28 -24
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-internal.h +189 -25
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-sinksource.cc +26 -9
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-sinksource.h +11 -11
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-stubs-internal.cc +1 -1
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-stubs-internal.h +227 -308
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-stubs-public.h.in +0 -11
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-test.cc +88 -198
- package/deps/couchbase-cxx-client/third_party/snappy/snappy-test.h +102 -285
- package/deps/couchbase-cxx-client/third_party/snappy/snappy.cc +1176 -410
- package/deps/couchbase-cxx-client/third_party/snappy/snappy.h +19 -4
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_benchmark.cc +378 -0
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_compress_fuzzer.cc +3 -2
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_test_data.cc +57 -0
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_test_data.h +68 -0
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_test_tool.cc +471 -0
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_uncompress_fuzzer.cc +3 -2
- package/deps/couchbase-cxx-client/third_party/snappy/snappy_unittest.cc +170 -666
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.github/workflows/build-and-test.yml +38 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.github/workflows/pylint.yml +26 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.github/workflows/test_bindings.yml +24 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.travis-libcxx-setup.sh +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.travis.yml +231 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/.ycm_extra_conf.py +115 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/AUTHORS +58 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/BUILD.bazel +44 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/CMakeLists.txt +287 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/CONTRIBUTING.md +58 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/CONTRIBUTORS +83 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/LICENSE +202 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/README.md +1323 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/WORKSPACE +51 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/_config.yml +1 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/appveyor.yml +50 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/BUILD +3 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/build_defs.bzl +25 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/google_benchmark/BUILD +38 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/google_benchmark/__init__.py +156 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/google_benchmark/benchmark.cc +180 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/google_benchmark/example.py +136 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/pybind11.BUILD +20 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/python_headers.BUILD +6 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/bindings/python/requirements.txt +2 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/AddCXXCompilerFlag.cmake +74 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/CXXFeatureCheck.cmake +69 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/Config.cmake.in +1 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/GetGitVersion.cmake +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/GoogleTest.cmake +41 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/GoogleTest.cmake.in +58 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/benchmark.pc.in +12 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/gnu_posix_regex.cpp +12 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/llvm-toolchain.cmake +8 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/posix_regex.cpp +14 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/split_list.cmake +3 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/std_regex.cpp +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/steady_clock.cpp +7 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/cmake/thread_safety_attributes.cpp +4 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/conan/CMakeLists.txt +7 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/conan/test_package/CMakeLists.txt +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/conan/test_package/conanfile.py +19 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/conan/test_package/test_package.cpp +18 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/conanfile.py +79 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/dependencies.md +18 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/docs/AssemblyTests.md +147 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/docs/_config.yml +1 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/docs/releasing.md +16 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/docs/tools.md +203 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/include/benchmark/benchmark.h +1604 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/requirements.txt +2 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/setup.py +140 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/CMakeLists.txt +114 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/arraysize.h +33 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark.cc +499 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_api_internal.cc +15 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_api_internal.h +53 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_main.cc +17 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_name.cc +58 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_register.cc +515 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_register.h +108 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_runner.cc +362 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/benchmark_runner.h +51 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/check.h +82 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/colorprint.cc +188 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/colorprint.h +33 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/commandlineflags.cc +228 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/commandlineflags.h +103 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/complexity.cc +238 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/complexity.h +55 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/console_reporter.cc +177 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/counter.cc +80 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/counter.h +32 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/csv_reporter.cc +154 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/cycleclock.h +211 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/internal_macros.h +102 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/json_reporter.cc +255 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/log.h +74 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/mutex.h +155 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/re.h +158 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/reporter.cc +105 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/sleep.cc +67 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/sleep.h +15 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/statistics.cc +193 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/statistics.h +37 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/string_util.cc +255 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/string_util.h +59 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/sysinfo.cc +716 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/thread_manager.h +64 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/thread_timer.h +86 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/timers.cc +245 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/src/timers.h +48 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/AssemblyTests.cmake +46 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/BUILD +73 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/CMakeLists.txt +263 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/args_product_test.cc +77 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/basic_test.cc +136 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/benchmark_gtest.cc +134 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/benchmark_name_gtest.cc +74 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/benchmark_test.cc +245 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/clobber_memory_assembly_test.cc +64 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/commandlineflags_gtest.cc +201 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/complexity_test.cc +213 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/cxx03_test.cc +63 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/diagnostics_test.cc +80 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/display_aggregates_only_test.cc +43 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/donotoptimize_assembly_test.cc +163 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/donotoptimize_test.cc +52 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/filter_test.cc +104 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/fixture_test.cc +51 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/internal_threading_test.cc +184 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/link_main_test.cc +8 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/map_test.cc +57 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/memory_manager_test.cc +44 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/multiple_ranges_test.cc +96 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/options_test.cc +75 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/output_test.h +213 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/output_test_helper.cc +515 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/register_benchmark_test.cc +184 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/report_aggregates_only_test.cc +39 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/reporter_output_test.cc +747 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/skip_with_error_test.cc +195 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/state_assembly_test.cc +68 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/statistics_gtest.cc +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/string_util_gtest.cc +153 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/templated_fixture_test.cc +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/user_counters_tabular_test.cc +285 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/user_counters_test.cc +531 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/test/user_counters_thousands_test.cc +173 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/BUILD.bazel +19 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/compare.py +429 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/Inputs/test1_run1.json +119 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/Inputs/test1_run2.json +119 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/Inputs/test2_run.json +81 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/Inputs/test3_run0.json +65 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/Inputs/test3_run1.json +65 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/__init__.py +8 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/report.py +903 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/gbench/util.py +163 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/requirements.txt +1 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/benchmark/tools/strip_asm.py +151 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/.travis.yml +65 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/BUILD.bazel +182 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/CMakeLists.txt +32 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/CONTRIBUTING.md +142 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/LICENSE +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/README.md +135 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/WORKSPACE +30 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/appveyor.yml +156 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/build-linux-bazel.sh +36 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/build-platformio.sh +2 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/env-linux.sh +41 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/env-osx.sh +41 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/get-nprocessors.sh +48 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/install-linux.sh +49 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/install-osx.sh +39 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/install-platformio.sh +5 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/log-config.sh +47 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/ci/travis.sh +29 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/CMakeLists.txt +219 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/CONTRIBUTORS +40 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/LICENSE +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/README.md +44 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/cmake/gmock.pc.in +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/cmake/gmock_main.pc.in +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/cheat_sheet.md +786 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/community_created_documentation.md +9 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/cook_book.md +4276 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/for_dummies.md +702 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/gmock_faq.md +398 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/docs/pump_manual.md +189 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-actions.h +1688 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-cardinalities.h +157 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-function-mocker.h +479 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h +577 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-generated-actions.h.pump +390 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-matchers.h +5394 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-more-matchers.h +92 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-nice-strict.h +230 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock-spec-builders.h +2030 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/gmock.h +98 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/custom/README.md +16 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h.pump +12 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-matchers.h +36 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/custom/gmock-port.h +39 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/gmock-internal-utils.h +459 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/gmock-port.h +87 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/include/gmock/internal/gmock-pp.h +279 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/README.md +5 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/fuse_gmock_files.py +257 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/LICENSE +203 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/README +34 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/README.cppclean +115 -0
- package/deps/couchbase-cxx-client/{core/CMakeLists.txt → third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/__init__.py} +0 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/ast.py +1772 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class.py +245 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/gmock_class_test.py +552 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/keywords.py +56 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/tokenize.py +284 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/cpp/utils.py +37 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/generator/gmock_gen.py +30 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/scripts/pump.py +856 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock-all.cc +46 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock-cardinalities.cc +155 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock-internal-utils.cc +200 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock-matchers.cc +459 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock-spec-builders.cc +908 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock.cc +213 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/src/gmock_main.cc +72 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/BUILD.bazel +111 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-actions_test.cc +1583 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-cardinalities_test.cc +429 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-function-mocker_nc.cc +16 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-function-mocker_nc_test.py +43 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-function-mocker_test.cc +974 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-generated-actions_test.cc +1036 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-internal-utils_test.cc +720 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-matchers_test.cc +8562 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-more-actions_test.cc +725 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-nice-strict_test.cc +500 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-port_test.cc +42 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-pp-string_test.cc +206 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-pp_test.cc +83 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock-spec-builders_test.cc +2775 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_all_test.cc +47 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_ex_test.cc +80 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_leak_test.py +104 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_leak_test_.cc +99 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_link2_test.cc +39 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_link_test.cc +39 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_link_test.h +690 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_output_test.py +183 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_output_test_.cc +309 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_output_test_golden.txt +317 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_stress_test.cc +240 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_test.cc +181 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/gmock_test_utils.py +108 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googlemock/test/pump_test.py +182 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/CMakeLists.txt +320 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/CONTRIBUTORS +38 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/LICENSE +28 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/README.md +262 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/cmake/Config.cmake.in +9 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/cmake/gtest.pc.in +9 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/cmake/gtest_main.pc.in +10 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/cmake/internal_utils.cmake +341 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/cmake/libgtest.la.in +21 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/docs/advanced.md +2640 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/docs/faq.md +771 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/docs/pkgconfig.md +150 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/docs/primer.md +583 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/docs/samples.md +22 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-death-test.h +342 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-matchers.h +756 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-message.h +219 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-param-test.h +512 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-printers.h +903 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-spi.h +238 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-test-part.h +184 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest-typed-test.h +337 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest.h +2491 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest_pred_impl.h +359 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/gtest_prod.h +61 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/custom/README.md +56 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/custom/gtest-port.h +37 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/custom/gtest.h +37 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h +304 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-filepath.h +211 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h +1564 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-param-util.h +947 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-port-arch.h +112 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-port.h +2371 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-string.h +175 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/include/gtest/internal/gtest-type-util.h +187 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/prime_tables.h +126 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample1.cc +66 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample1.h +41 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample10_unittest.cc +139 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample1_unittest.cc +151 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample2.cc +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample2.h +81 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample2_unittest.cc +107 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample3-inl.h +172 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample3_unittest.cc +149 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample4.cc +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample4.h +53 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample4_unittest.cc +53 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample5_unittest.cc +196 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample6_unittest.cc +224 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample7_unittest.cc +117 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample8_unittest.cc +154 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/samples/sample9_unittest.cc +156 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/README.md +5 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/common.py +83 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/fuse_gtest_files.py +253 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/gen_gtest_pred_impl.py +733 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/gtest-config.in +274 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/release_docs.py +158 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/run_with_path.py +32 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/upload.py +1402 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/scripts/upload_gtest.py +78 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-all.cc +48 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-death-test.cc +1644 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-filepath.cc +368 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-internal-inl.h +1228 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-matchers.cc +97 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-port.cc +1404 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-printers.cc +444 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-test-part.cc +108 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest-typed-test.cc +111 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest.cc +6606 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/src/gtest_main.cc +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/BUILD.bazel +562 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-break-on-failure-unittest.py +208 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-break-on-failure-unittest_.cc +86 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-catch-exceptions-test.py +236 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-catch-exceptions-test_.cc +293 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-color-test.py +127 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-color-test_.cc +62 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-death-test-test.cc +1542 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-death-test_ex_test.cc +92 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-env-var-test.py +120 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-env-var-test_.cc +132 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-failfast-unittest.py +410 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-failfast-unittest_.cc +167 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-filepath-test.cc +649 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-filter-unittest.py +639 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-filter-unittest_.cc +137 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-json-outfiles-test.py +191 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-json-output-unittest.py +804 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-list-tests-unittest.py +205 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-list-tests-unittest_.cc +156 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-listener-test.cc +518 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-message-test.cc +158 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-options-test.cc +216 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-output-test-golden-lin.txt +1180 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-output-test.py +346 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-output-test_.cc +1126 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test.py +63 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-invalid-name1-test_.cc +50 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test.py +62 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-invalid-name2-test_.cc +55 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-test.cc +1119 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test-test.h +51 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-param-test2-test.cc +61 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-port-test.cc +1280 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-printers-test.cc +1847 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-setuptestsuite-test.py +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-setuptestsuite-test_.cc +49 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-shuffle-test.py +323 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-shuffle-test_.cc +101 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-test-part-test.cc +230 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-throw-on-failure-test.py +168 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-throw-on-failure-test_.cc +71 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-uninitialized-test.py +67 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/googletest-uninitialized-test_.cc +42 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest-typed-test2_test.cc +44 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest-typed-test_test.cc +462 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest-typed-test_test.h +65 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest-unittest-api_test.cc +341 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_all_test.cc +46 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_assert_by_exception_test.cc +116 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_environment_test.cc +188 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_help_test.py +171 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_help_test_.cc +45 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_json_test_utils.py +60 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_list_output_unittest.py +286 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_list_output_unittest_.cc +81 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_main_unittest.cc +44 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_no_test_unittest.cc +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_pred_impl_unittest.cc +2422 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_premature_exit_test.cc +126 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_prod_test.cc +56 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_repeat_test.cc +233 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_skip_check_output_test.py +59 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_skip_environment_check_output_test.py +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc +49 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_skip_test.cc +55 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_sole_header_test.cc +56 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_stress_test.cc +248 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_test_macro_stack_footprint_test.cc +89 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_test_utils.py +312 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_testbridge_test.py +63 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_testbridge_test_.cc +43 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_throw_on_failure_ex_test.cc +90 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_unittest.cc +7792 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_outfile1_test_.cc +43 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_outfile2_test_.cc +43 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_outfiles_test.py +135 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_output_unittest.py +405 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_output_unittest_.cc +197 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/gtest_xml_test_utils.py +197 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/production.cc +35 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/googletest/test/production.h +54 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/library.json +62 -0
- package/deps/couchbase-cxx-client/third_party/snappy/third_party/googletest/platformio.ini +47 -0
- package/deps/couchbase-cxx-client/tools/CMakeLists.txt +2 -0
- package/deps/couchbase-cxx-client/tools/analytics.cxx +375 -0
- package/deps/couchbase-cxx-client/tools/analytics.hxx +26 -0
- package/deps/couchbase-cxx-client/tools/cbc.cxx +11 -4
- package/deps/couchbase-cxx-client/tools/command_registry.cxx +4 -0
- package/deps/couchbase-cxx-client/tools/get.cxx +36 -39
- package/deps/couchbase-cxx-client/tools/get.hxx +1 -1
- package/deps/couchbase-cxx-client/tools/pillowfight.cxx +496 -0
- package/deps/couchbase-cxx-client/tools/pillowfight.hxx +26 -0
- package/deps/couchbase-cxx-client/tools/query.cxx +97 -101
- package/deps/couchbase-cxx-client/tools/query.hxx +1 -1
- package/deps/couchbase-cxx-client/tools/utils.cxx +15 -1
- package/deps/couchbase-cxx-client/tools/utils.hxx +3 -0
- package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
- package/deps/couchbase-cxx-client/tools/version.hxx +1 -1
- package/dist/authenticators.d.ts +1 -1
- package/dist/binding.d.ts +25 -10
- package/dist/bindingutilities.d.ts +6 -2
- package/dist/bindingutilities.js +39 -7
- package/dist/cluster.d.ts +27 -0
- package/dist/cluster.js +88 -56
- package/dist/collection.js +6 -6
- package/dist/configProfile.js +16 -10
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +2 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +4 -4
- package/dist/scope.js +6 -6
- package/dist/sdspecs.js +11 -11
- package/dist/searchquery.d.ts +1 -1
- package/dist/streamablepromises.d.ts +1 -1
- package/dist/transactions.js +5 -1
- package/dist/usermanager.js +9 -9
- package/dist/viewindexmanager.js +8 -8
- package/package.json +1 -1
- package/src/binding.cpp +2 -0
- package/src/jstocbpp_autogen.hpp +3 -6
- package/src/jstocbpp_basic.hpp +8 -2
- package/src/jstocbpp_errors.hpp +35 -0
- package/src/jstocbpp_transactions.hpp +61 -9
- package/src/transaction.cpp +1 -1
- package/deps/couchbase-cxx-client/core/config_profile.cxx +0 -25
- package/deps/couchbase-cxx-client/core/topology/error_map_fmt.hxx +0 -94
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_context.cxx +0 -550
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_async_api.cxx +0 -392
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_public_blocking_api.cxx +0 -643
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_simple.cxx +0 -899
- package/deps/couchbase-cxx-client/test/test_transaction_transaction_simple_async.cxx +0 -972
- package/deps/couchbase-cxx-client/test/tools/CMakeLists.txt +0 -10
- package/deps/couchbase-cxx-client/test/tools/tool_kv_loader.cxx +0 -349
- package/deps/couchbase-cxx-client/test/utils/uniq_id.cxx +0 -29
- package/deps/couchbase-cxx-client/test/utils/uniq_id.hxx +0 -26
- package/deps/couchbase-cxx-client/third_party/catch2/.travis.yml +0 -335
- package/deps/couchbase-cxx-client/third_party/catch2/CMake/MiscFunctions.cmake +0 -26
- package/deps/couchbase-cxx-client/third_party/catch2/WORKSPACE +0 -0
- package/deps/couchbase-cxx-client/third_party/catch2/contrib/Catch.cmake +0 -206
- package/deps/couchbase-cxx-client/third_party/catch2/contrib/CatchAddTests.cmake +0 -135
- package/deps/couchbase-cxx-client/third_party/catch2/docs/slow-compiles.md +0 -106
- package/deps/couchbase-cxx-client/third_party/catch2/examples/000-CatchMain.cpp +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/examples/200-Rpt-CatchMain.cpp +0 -27
- package/deps/couchbase-cxx-client/third_party/catch2/examples/207-Rpt-TeamCityReporter.cpp +0 -171
- package/deps/couchbase-cxx-client/third_party/catch2/include/catch.hpp +0 -496
- package/deps/couchbase-cxx-client/third_party/catch2/include/catch_with_main.hpp +0 -14
- package/deps/couchbase-cxx-client/third_party/catch2/include/external/clara.hpp +0 -1268
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_benchmark.hpp +0 -122
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_benchmarking_all.hpp +0 -29
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_chronometer.hpp +0 -71
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_clock.hpp +0 -40
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_constructor.hpp +0 -79
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_environment.hpp +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_estimate.hpp +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_execution_plan.hpp +0 -59
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_optimizer.hpp +0 -68
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_outlier_classification.hpp +0 -29
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/catch_sample_analysis.hpp +0 -50
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_analyse.hpp +0 -78
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_benchmark_function.hpp +0 -105
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_complete_invoke.hpp +0 -68
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_estimate_clock.hpp +0 -115
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_measure.hpp +0 -35
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_repeat.hpp +0 -37
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_run_for_at_least.hpp +0 -65
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_stats.cpp +0 -224
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_stats.hpp +0 -160
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/benchmark/detail/catch_timing.hpp +0 -33
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_approx.cpp +0 -88
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_approx.h +0 -132
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_assertionhandler.cpp +0 -122
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_assertionhandler.h +0 -88
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_assertioninfo.h +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_assertionresult.cpp +0 -104
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_assertionresult.h +0 -59
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_capture.hpp +0 -159
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_capture_matchers.cpp +0 -24
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_capture_matchers.h +0 -88
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_clara.h +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_commandline.cpp +0 -230
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_commandline.h +0 -20
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_common.cpp +0 -43
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_common.h +0 -92
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_compiler_capabilities.h +0 -377
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_config.cpp +0 -86
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_config.hpp +0 -133
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_config_uncaught_exceptions.hpp +0 -44
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_console_colour.cpp +0 -243
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_console_colour.h +0 -69
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_context.cpp +0 -70
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_context.h +0 -64
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_debug_console.cpp +0 -41
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_debug_console.h +0 -17
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_debugger.cpp +0 -122
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_debugger.h +0 -65
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_decomposer.cpp +0 -24
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_decomposer.h +0 -259
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_default_main.hpp +0 -47
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_enforce.cpp +0 -40
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_enforce.h +0 -53
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_enum_values_registry.cpp +0 -75
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_enum_values_registry.h +0 -35
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_errno_guard.cpp +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_errno_guard.h +0 -22
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_exception_translator_registry.cpp +0 -89
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_exception_translator_registry.h +0 -30
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_external_interfaces.h +0 -20
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_fatal_condition.cpp +0 -244
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_fatal_condition.h +0 -68
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_generators.cpp +0 -32
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_generators.hpp +0 -219
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_generators_generic.hpp +0 -237
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_generators_specific.hpp +0 -175
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_impl.hpp +0 -33
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_capture.cpp +0 -5
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_capture.h +0 -100
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_config.cpp +0 -5
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_config.h +0 -92
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_enum_values_registry.h +0 -46
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_exception.cpp +0 -6
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_exception.h +0 -88
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_generatortracker.h +0 -39
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_registry_hub.cpp +0 -6
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_registry_hub.h +0 -61
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_reporter.cpp +0 -114
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_reporter.h +0 -272
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_runner.cpp +0 -5
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_runner.h +0 -19
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_tag_alias_registry.h +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_testcase.cpp +0 -6
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_interfaces_testcase.h +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_leak_detector.cpp +0 -37
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_leak_detector.h +0 -18
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_list.cpp +0 -173
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_list.h +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers.cpp +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers.h +0 -174
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_exception.cpp +0 -30
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_exception.hpp +0 -36
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_floating.cpp +0 -237
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_floating.h +0 -70
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_generic.cpp +0 -9
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_generic.hpp +0 -58
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_string.cpp +0 -118
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_string.h +0 -80
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_matchers_vector.h +0 -180
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_message.cpp +0 -142
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_message.h +0 -99
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_meta.hpp +0 -50
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_objc.hpp +0 -215
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_objc_arc.hpp +0 -51
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_option.hpp +0 -73
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_output_redirect.cpp +0 -147
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_output_redirect.h +0 -116
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_platform.h +0 -30
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_polyfills.cpp +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_polyfills.hpp +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_preprocessor.hpp +0 -237
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_random_number_generator.cpp +0 -73
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_random_number_generator.h +0 -58
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_reenable_warnings.h +0 -21
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_registry_hub.cpp +0 -99
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_reporter_registrars.hpp +0 -78
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_reporter_registry.cpp +0 -34
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_reporter_registry.h +0 -37
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_result_type.cpp +0 -27
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_result_type.h +0 -55
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_run_context.cpp +0 -595
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_run_context.h +0 -159
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_section.cpp +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_section.h +0 -51
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_section_info.cpp +0 -19
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_section_info.h +0 -42
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_session.cpp +0 -313
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_session.h +0 -62
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_singletons.cpp +0 -36
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_singletons.hpp +0 -44
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_startup_exception_registry.cpp +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_startup_exception_registry.h +0 -29
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_stream.cpp +0 -187
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_stream.h +0 -51
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_string_manip.cpp +0 -109
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_string_manip.h +0 -45
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_stringref.cpp +0 -50
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_stringref.h +0 -104
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_suppress_warnings.h +0 -27
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias.cpp +0 -5
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias.h +0 -26
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias_autoregistrar.cpp +0 -16
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias_autoregistrar.h +0 -26
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias_registry.cpp +0 -58
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tag_alias_registry.h +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_info.cpp +0 -186
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_info.h +0 -90
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_registry_impl.cpp +0 -176
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_registry_impl.h +0 -71
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_tracker.cpp +0 -254
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_case_tracker.h +0 -180
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_registry.cpp +0 -37
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_registry.h +0 -402
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_spec.cpp +0 -99
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_spec.h +0 -94
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_spec_parser.cpp +0 -240
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_test_spec_parser.h +0 -79
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_text.h +0 -17
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_timer.cpp +0 -74
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_timer.h +0 -30
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_to_string.hpp +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tostring.cpp +0 -265
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_tostring.h +0 -675
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_totals.cpp +0 -61
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_totals.h +0 -41
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_uncaught_exceptions.cpp +0 -25
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_uncaught_exceptions.h +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_user_interfaces.h +0 -18
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_version.cpp +0 -44
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_version.h +0 -39
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_wildcard_pattern.cpp +0 -47
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_wildcard_pattern.h +0 -38
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_windows_h_proxy.h +0 -39
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_xmlwriter.cpp +0 -334
- package/deps/couchbase-cxx-client/third_party/catch2/include/internal/catch_xmlwriter.h +0 -116
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_automake.hpp +0 -62
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_bases.cpp +0 -84
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_bases.hpp +0 -285
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_compact.cpp +0 -290
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_compact.h +0 -39
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_console.cpp +0 -700
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_console.h +0 -89
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_junit.cpp +0 -300
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_junit.h +0 -62
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_listening.cpp +0 -164
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_listening.h +0 -63
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_sonarqube.hpp +0 -181
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_tap.hpp +0 -254
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_teamcity.hpp +0 -219
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_xml.cpp +0 -281
- package/deps/couchbase-cxx-client/third_party/catch2/include/reporters/catch_reporter_xml.h +0 -68
- package/deps/couchbase-cxx-client/third_party/catch2/misc/appveyorBuildConfigurationScript.bat +0 -22
- package/deps/couchbase-cxx-client/third_party/catch2/misc/appveyorMergeCoverageScript.py +0 -9
- package/deps/couchbase-cxx-client/third_party/catch2/misc/appveyorTestRunScript.bat +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/misc/coverage-helper.cpp +0 -142
- package/deps/couchbase-cxx-client/third_party/catch2/misc/installOpenCppCoverage.ps1 +0 -19
- package/deps/couchbase-cxx-client/third_party/catch2/projects/CMakeLists.txt +0 -492
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/CMakeLists.txt +0 -201
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/ToDo.txt +0 -11
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X01-PrefixedMacros.cpp +0 -84
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X02-DisabledMacros.cpp +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp +0 -23
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp +0 -33
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X10-FallbackStringifier.cpp +0 -23
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X11-DisableStringification.cpp +0 -16
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X12-CustomDebugBreakMacro.cpp +0 -17
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X20-BenchmarkingMacros.cpp +0 -125
- package/deps/couchbase-cxx-client/third_party/catch2/projects/ExtraTests/X90-WindowsHeaderInclusion.cpp +0 -12
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/compact.sw.approved.txt +0 -1903
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/console.std.approved.txt +0 -1425
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/console.sw.approved.txt +0 -14183
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/console.swa4.approved.txt +0 -936
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/junit.sw.approved.txt +0 -1773
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/sonarqube.sw.approved.txt +0 -1777
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/Baselines/xml.sw.approved.txt +0 -16767
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/CompileTimePerfTests/10.tests.cpp +0 -13
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/CompileTimePerfTests/100.tests.cpp +0 -13
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/CompileTimePerfTests/All.tests.cpp +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +0 -582
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/Details.tests.cpp +0 -23
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +0 -352
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp +0 -405
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +0 -253
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp +0 -45
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/String.tests.cpp +0 -150
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/StringManip.tests.cpp +0 -67
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp +0 -54
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/ToString.tests.cpp +0 -53
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/IntrospectiveTests/Xml.tests.cpp +0 -114
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_console_colour.cpp +0 -3
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_debugger.cpp +0 -2
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp +0 -2
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_option.cpp +0 -3
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_stream.cpp +0 -3
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp +0 -2
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_test_spec.cpp +0 -3
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/SurrogateCpps/catch_xmlwriter.cpp +0 -4
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/TestMain.cpp +0 -34
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/TimingTests/Sleep.tests.cpp +0 -23
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Approx.tests.cpp +0 -215
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/BDD.tests.cpp +0 -110
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Benchmark.tests.cpp +0 -144
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Class.tests.cpp +0 -137
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Compilation.tests.cpp +0 -269
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Condition.tests.cpp +0 -347
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Decomposition.tests.cpp +0 -39
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/EnumToString.tests.cpp +0 -99
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Exception.tests.cpp +0 -210
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Generators.tests.cpp +0 -271
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Matchers.tests.cpp +0 -676
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Message.tests.cpp +0 -269
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Misc.tests.cpp +0 -493
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringByte.tests.cpp +0 -15
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringChrono.tests.cpp +0 -44
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp +0 -210
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringOptional.tests.cpp +0 -23
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringPair.tests.cpp +0 -30
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringTuple.tests.cpp +0 -47
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp +0 -91
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringVector.tests.cpp +0 -86
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/ToStringWhich.tests.cpp +0 -193
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/Tricky.tests.cpp +0 -429
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/UsageTests/VariadicMacros.tests.cpp +0 -29
- package/deps/couchbase-cxx-client/third_party/catch2/projects/SelfTest/WarnAboutNoTests.cmake +0 -19
- package/deps/couchbase-cxx-client/third_party/catch2/projects/TestScripts/testRandomOrder.py +0 -59
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/CatchOCTestCase.h +0 -25
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/CatchOCTestCase.mm +0 -87
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/Main.mm +0 -2
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/OCTest.1 +0 -79
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/OCTest.mm +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/TestObj.h +0 -28
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest/TestObj.m +0 -25
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest.xcodeproj/project.pbxproj +0 -294
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/deps/couchbase-cxx-client/third_party/catch2/projects/XCode/OCTest/catch_objc_impl.mm +0 -69
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/approvalTests.py +0 -217
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/approve.py +0 -33
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/benchmarkCompile.py +0 -148
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/benchmarkRunner.py +0 -56
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/developBuild.py +0 -10
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/embed.py +0 -63
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/embedClara.py +0 -27
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/extractFeaturesFromReleaseNotes.py +0 -94
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/fixWhitespace.py +0 -52
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/generateSingleHeader.py +0 -151
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/majorRelease.py +0 -10
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/minorRelease.py +0 -10
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/patchRelease.py +0 -10
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/releaseCommon.py +0 -168
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/releaseNotes.py +0 -65
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/scriptCommon.py +0 -31
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/updateDocumentToC.py +0 -449
- package/deps/couchbase-cxx-client/third_party/catch2/scripts/updateWandbox.py +0 -53
- package/deps/couchbase-cxx-client/third_party/catch2/single_include/catch2/catch.hpp +0 -17959
- package/deps/couchbase-cxx-client/third_party/catch2/single_include/catch2/catch_reporter_automake.hpp +0 -62
- package/deps/couchbase-cxx-client/third_party/catch2/single_include/catch2/catch_reporter_sonarqube.hpp +0 -181
- package/deps/couchbase-cxx-client/third_party/catch2/single_include/catch2/catch_reporter_tap.hpp +0 -254
- package/deps/couchbase-cxx-client/third_party/catch2/single_include/catch2/catch_reporter_teamcity.hpp +0 -219
- package/deps/couchbase-cxx-client/third_party/catch2/src/catch_with_main.cpp +0 -2
- package/deps/couchbase-cxx-client/third_party/snappy/.appveyor.yml +0 -36
- package/deps/couchbase-cxx-client/third_party/snappy/.travis.yml +0 -94
- /package/deps/couchbase-cxx-client/third_party/catch2/{artwork → data/artwork}/catch2-c-logo.png +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{artwork → data/artwork}/catch2-hand-logo.png +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{artwork → data/artwork}/catch2-logo-small.png +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{contrib → extras}/ParseAndAddCatchTests.cmake +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{contrib → extras}/gdbinit +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{contrib → extras}/lldbinit +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{projects → tests}/SelfTest/Baselines/automake.std.approved.txt +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{projects → tests}/SelfTest/Misc/invalid-test-names.input +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{projects → tests}/SelfTest/Misc/plain-old-tests.input +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{projects → tests}/SelfTest/Misc/special-characters-in-file.input +0 -0
- /package/deps/couchbase-cxx-client/third_party/catch2/{misc → tools/misc}/CMakeLists.txt +0 -0
@@ -0,0 +1,4276 @@
|
|
1
|
+
# gMock Cookbook
|
2
|
+
|
3
|
+
<!-- GOOGLETEST_CM0012 DO NOT DELETE -->
|
4
|
+
|
5
|
+
You can find recipes for using gMock here. If you haven't yet, please read
|
6
|
+
[the dummy guide](for_dummies.md) first to make sure you understand the basics.
|
7
|
+
|
8
|
+
**Note:** gMock lives in the `testing` name space. For readability, it is
|
9
|
+
recommended to write `using ::testing::Foo;` once in your file before using the
|
10
|
+
name `Foo` defined by gMock. We omit such `using` statements in this section for
|
11
|
+
brevity, but you should do it in your own code.
|
12
|
+
|
13
|
+
<!-- GOOGLETEST_CM0035 DO NOT DELETE -->
|
14
|
+
|
15
|
+
## Creating Mock Classes
|
16
|
+
|
17
|
+
Mock classes are defined as normal classes, using the `MOCK_METHOD` macro to
|
18
|
+
generate mocked methods. The macro gets 3 or 4 parameters:
|
19
|
+
|
20
|
+
```cpp
|
21
|
+
class MyMock {
|
22
|
+
public:
|
23
|
+
MOCK_METHOD(ReturnType, MethodName, (Args...));
|
24
|
+
MOCK_METHOD(ReturnType, MethodName, (Args...), (Specs...));
|
25
|
+
};
|
26
|
+
```
|
27
|
+
|
28
|
+
The first 3 parameters are simply the method declaration, split into 3 parts.
|
29
|
+
The 4th parameter accepts a closed list of qualifiers, which affect the
|
30
|
+
generated method:
|
31
|
+
|
32
|
+
* **`const`** - Makes the mocked method a `const` method. Required if
|
33
|
+
overriding a `const` method.
|
34
|
+
* **`override`** - Marks the method with `override`. Recommended if overriding
|
35
|
+
a `virtual` method.
|
36
|
+
* **`noexcept`** - Marks the method with `noexcept`. Required if overriding a
|
37
|
+
`noexcept` method.
|
38
|
+
* **`Calltype(...)`** - Sets the call type for the method (e.g. to
|
39
|
+
`STDMETHODCALLTYPE`), useful in Windows.
|
40
|
+
* **`ref(...)`** - Marks the method with the reference qualification
|
41
|
+
specified. Required if overriding a method that has reference
|
42
|
+
qualifications. Eg `ref(&)` or `ref(&&)`.
|
43
|
+
|
44
|
+
### Dealing with unprotected commas
|
45
|
+
|
46
|
+
Unprotected commas, i.e. commas which are not surrounded by parentheses, prevent
|
47
|
+
`MOCK_METHOD` from parsing its arguments correctly:
|
48
|
+
|
49
|
+
```cpp {.bad}
|
50
|
+
class MockFoo {
|
51
|
+
public:
|
52
|
+
MOCK_METHOD(std::pair<bool, int>, GetPair, ()); // Won't compile!
|
53
|
+
MOCK_METHOD(bool, CheckMap, (std::map<int, double>, bool)); // Won't compile!
|
54
|
+
};
|
55
|
+
```
|
56
|
+
|
57
|
+
Solution 1 - wrap with parentheses:
|
58
|
+
|
59
|
+
```cpp {.good}
|
60
|
+
class MockFoo {
|
61
|
+
public:
|
62
|
+
MOCK_METHOD((std::pair<bool, int>), GetPair, ());
|
63
|
+
MOCK_METHOD(bool, CheckMap, ((std::map<int, double>), bool));
|
64
|
+
};
|
65
|
+
```
|
66
|
+
|
67
|
+
Note that wrapping a return or argument type with parentheses is, in general,
|
68
|
+
invalid C++. `MOCK_METHOD` removes the parentheses.
|
69
|
+
|
70
|
+
Solution 2 - define an alias:
|
71
|
+
|
72
|
+
```cpp {.good}
|
73
|
+
class MockFoo {
|
74
|
+
public:
|
75
|
+
using BoolAndInt = std::pair<bool, int>;
|
76
|
+
MOCK_METHOD(BoolAndInt, GetPair, ());
|
77
|
+
using MapIntDouble = std::map<int, double>;
|
78
|
+
MOCK_METHOD(bool, CheckMap, (MapIntDouble, bool));
|
79
|
+
};
|
80
|
+
```
|
81
|
+
|
82
|
+
### Mocking Private or Protected Methods
|
83
|
+
|
84
|
+
You must always put a mock method definition (`MOCK_METHOD`) in a `public:`
|
85
|
+
section of the mock class, regardless of the method being mocked being `public`,
|
86
|
+
`protected`, or `private` in the base class. This allows `ON_CALL` and
|
87
|
+
`EXPECT_CALL` to reference the mock function from outside of the mock class.
|
88
|
+
(Yes, C++ allows a subclass to change the access level of a virtual function in
|
89
|
+
the base class.) Example:
|
90
|
+
|
91
|
+
```cpp
|
92
|
+
class Foo {
|
93
|
+
public:
|
94
|
+
...
|
95
|
+
virtual bool Transform(Gadget* g) = 0;
|
96
|
+
|
97
|
+
protected:
|
98
|
+
virtual void Resume();
|
99
|
+
|
100
|
+
private:
|
101
|
+
virtual int GetTimeOut();
|
102
|
+
};
|
103
|
+
|
104
|
+
class MockFoo : public Foo {
|
105
|
+
public:
|
106
|
+
...
|
107
|
+
MOCK_METHOD(bool, Transform, (Gadget* g), (override));
|
108
|
+
|
109
|
+
// The following must be in the public section, even though the
|
110
|
+
// methods are protected or private in the base class.
|
111
|
+
MOCK_METHOD(void, Resume, (), (override));
|
112
|
+
MOCK_METHOD(int, GetTimeOut, (), (override));
|
113
|
+
};
|
114
|
+
```
|
115
|
+
|
116
|
+
### Mocking Overloaded Methods
|
117
|
+
|
118
|
+
You can mock overloaded functions as usual. No special attention is required:
|
119
|
+
|
120
|
+
```cpp
|
121
|
+
class Foo {
|
122
|
+
...
|
123
|
+
|
124
|
+
// Must be virtual as we'll inherit from Foo.
|
125
|
+
virtual ~Foo();
|
126
|
+
|
127
|
+
// Overloaded on the types and/or numbers of arguments.
|
128
|
+
virtual int Add(Element x);
|
129
|
+
virtual int Add(int times, Element x);
|
130
|
+
|
131
|
+
// Overloaded on the const-ness of this object.
|
132
|
+
virtual Bar& GetBar();
|
133
|
+
virtual const Bar& GetBar() const;
|
134
|
+
};
|
135
|
+
|
136
|
+
class MockFoo : public Foo {
|
137
|
+
...
|
138
|
+
MOCK_METHOD(int, Add, (Element x), (override));
|
139
|
+
MOCK_METHOD(int, Add, (int times, Element x), (override));
|
140
|
+
|
141
|
+
MOCK_METHOD(Bar&, GetBar, (), (override));
|
142
|
+
MOCK_METHOD(const Bar&, GetBar, (), (const, override));
|
143
|
+
};
|
144
|
+
```
|
145
|
+
|
146
|
+
**Note:** if you don't mock all versions of the overloaded method, the compiler
|
147
|
+
will give you a warning about some methods in the base class being hidden. To
|
148
|
+
fix that, use `using` to bring them in scope:
|
149
|
+
|
150
|
+
```cpp
|
151
|
+
class MockFoo : public Foo {
|
152
|
+
...
|
153
|
+
using Foo::Add;
|
154
|
+
MOCK_METHOD(int, Add, (Element x), (override));
|
155
|
+
// We don't want to mock int Add(int times, Element x);
|
156
|
+
...
|
157
|
+
};
|
158
|
+
```
|
159
|
+
|
160
|
+
### Mocking Class Templates
|
161
|
+
|
162
|
+
You can mock class templates just like any class.
|
163
|
+
|
164
|
+
```cpp
|
165
|
+
template <typename Elem>
|
166
|
+
class StackInterface {
|
167
|
+
...
|
168
|
+
// Must be virtual as we'll inherit from StackInterface.
|
169
|
+
virtual ~StackInterface();
|
170
|
+
|
171
|
+
virtual int GetSize() const = 0;
|
172
|
+
virtual void Push(const Elem& x) = 0;
|
173
|
+
};
|
174
|
+
|
175
|
+
template <typename Elem>
|
176
|
+
class MockStack : public StackInterface<Elem> {
|
177
|
+
...
|
178
|
+
MOCK_METHOD(int, GetSize, (), (override));
|
179
|
+
MOCK_METHOD(void, Push, (const Elem& x), (override));
|
180
|
+
};
|
181
|
+
```
|
182
|
+
|
183
|
+
### Mocking Non-virtual Methods {#MockingNonVirtualMethods}
|
184
|
+
|
185
|
+
gMock can mock non-virtual functions to be used in Hi-perf dependency
|
186
|
+
injection.<!-- GOOGLETEST_CM0017 DO NOT DELETE -->
|
187
|
+
|
188
|
+
In this case, instead of sharing a common base class with the real class, your
|
189
|
+
mock class will be *unrelated* to the real class, but contain methods with the
|
190
|
+
same signatures. The syntax for mocking non-virtual methods is the *same* as
|
191
|
+
mocking virtual methods (just don't add `override`):
|
192
|
+
|
193
|
+
```cpp
|
194
|
+
// A simple packet stream class. None of its members is virtual.
|
195
|
+
class ConcretePacketStream {
|
196
|
+
public:
|
197
|
+
void AppendPacket(Packet* new_packet);
|
198
|
+
const Packet* GetPacket(size_t packet_number) const;
|
199
|
+
size_t NumberOfPackets() const;
|
200
|
+
...
|
201
|
+
};
|
202
|
+
|
203
|
+
// A mock packet stream class. It inherits from no other, but defines
|
204
|
+
// GetPacket() and NumberOfPackets().
|
205
|
+
class MockPacketStream {
|
206
|
+
public:
|
207
|
+
MOCK_METHOD(const Packet*, GetPacket, (size_t packet_number), (const));
|
208
|
+
MOCK_METHOD(size_t, NumberOfPackets, (), (const));
|
209
|
+
...
|
210
|
+
};
|
211
|
+
```
|
212
|
+
|
213
|
+
Note that the mock class doesn't define `AppendPacket()`, unlike the real class.
|
214
|
+
That's fine as long as the test doesn't need to call it.
|
215
|
+
|
216
|
+
Next, you need a way to say that you want to use `ConcretePacketStream` in
|
217
|
+
production code, and use `MockPacketStream` in tests. Since the functions are
|
218
|
+
not virtual and the two classes are unrelated, you must specify your choice at
|
219
|
+
*compile time* (as opposed to run time).
|
220
|
+
|
221
|
+
One way to do it is to templatize your code that needs to use a packet stream.
|
222
|
+
More specifically, you will give your code a template type argument for the type
|
223
|
+
of the packet stream. In production, you will instantiate your template with
|
224
|
+
`ConcretePacketStream` as the type argument. In tests, you will instantiate the
|
225
|
+
same template with `MockPacketStream`. For example, you may write:
|
226
|
+
|
227
|
+
```cpp
|
228
|
+
template <class PacketStream>
|
229
|
+
void CreateConnection(PacketStream* stream) { ... }
|
230
|
+
|
231
|
+
template <class PacketStream>
|
232
|
+
class PacketReader {
|
233
|
+
public:
|
234
|
+
void ReadPackets(PacketStream* stream, size_t packet_num);
|
235
|
+
};
|
236
|
+
```
|
237
|
+
|
238
|
+
Then you can use `CreateConnection<ConcretePacketStream>()` and
|
239
|
+
`PacketReader<ConcretePacketStream>` in production code, and use
|
240
|
+
`CreateConnection<MockPacketStream>()` and `PacketReader<MockPacketStream>` in
|
241
|
+
tests.
|
242
|
+
|
243
|
+
```cpp
|
244
|
+
MockPacketStream mock_stream;
|
245
|
+
EXPECT_CALL(mock_stream, ...)...;
|
246
|
+
.. set more expectations on mock_stream ...
|
247
|
+
PacketReader<MockPacketStream> reader(&mock_stream);
|
248
|
+
... exercise reader ...
|
249
|
+
```
|
250
|
+
|
251
|
+
### Mocking Free Functions
|
252
|
+
|
253
|
+
It's possible to use gMock to mock a free function (i.e. a C-style function or a
|
254
|
+
static method). You just need to rewrite your code to use an interface (abstract
|
255
|
+
class).
|
256
|
+
|
257
|
+
Instead of calling a free function (say, `OpenFile`) directly, introduce an
|
258
|
+
interface for it and have a concrete subclass that calls the free function:
|
259
|
+
|
260
|
+
```cpp
|
261
|
+
class FileInterface {
|
262
|
+
public:
|
263
|
+
...
|
264
|
+
virtual bool Open(const char* path, const char* mode) = 0;
|
265
|
+
};
|
266
|
+
|
267
|
+
class File : public FileInterface {
|
268
|
+
public:
|
269
|
+
...
|
270
|
+
virtual bool Open(const char* path, const char* mode) {
|
271
|
+
return OpenFile(path, mode);
|
272
|
+
}
|
273
|
+
};
|
274
|
+
```
|
275
|
+
|
276
|
+
Your code should talk to `FileInterface` to open a file. Now it's easy to mock
|
277
|
+
out the function.
|
278
|
+
|
279
|
+
This may seem like a lot of hassle, but in practice you often have multiple
|
280
|
+
related functions that you can put in the same interface, so the per-function
|
281
|
+
syntactic overhead will be much lower.
|
282
|
+
|
283
|
+
If you are concerned about the performance overhead incurred by virtual
|
284
|
+
functions, and profiling confirms your concern, you can combine this with the
|
285
|
+
recipe for [mocking non-virtual methods](#MockingNonVirtualMethods).
|
286
|
+
|
287
|
+
### Old-Style `MOCK_METHODn` Macros
|
288
|
+
|
289
|
+
Before the generic `MOCK_METHOD` macro
|
290
|
+
[was introduced in 2018](https://github.com/google/googletest/commit/c5f08bf91944ce1b19bcf414fa1760e69d20afc2),
|
291
|
+
mocks where created using a family of macros collectively called `MOCK_METHODn`.
|
292
|
+
These macros are still supported, though migration to the new `MOCK_METHOD` is
|
293
|
+
recommended.
|
294
|
+
|
295
|
+
The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`:
|
296
|
+
|
297
|
+
* The general structure is `MOCK_METHODn(MethodName, ReturnType(Args))`,
|
298
|
+
instead of `MOCK_METHOD(ReturnType, MethodName, (Args))`.
|
299
|
+
* The number `n` must equal the number of arguments.
|
300
|
+
* When mocking a const method, one must use `MOCK_CONST_METHODn`.
|
301
|
+
* When mocking a class template, the macro name must be suffixed with `_T`.
|
302
|
+
* In order to specify the call type, the macro name must be suffixed with
|
303
|
+
`_WITH_CALLTYPE`, and the call type is the first macro argument.
|
304
|
+
|
305
|
+
Old macros and their new equivalents:
|
306
|
+
|
307
|
+
<a name="table99"></a>
|
308
|
+
<table border="1" cellspacing="0" cellpadding="1">
|
309
|
+
<tr> <th colspan=2> Simple </th></tr>
|
310
|
+
<tr> <td> Old </td> <td> `MOCK_METHOD1(Foo, bool(int))` </td> </tr>
|
311
|
+
<tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int))` </td> </tr>
|
312
|
+
|
313
|
+
<tr> <th colspan=2> Const Method </th></tr> <tr> <td> Old </td> <td>
|
314
|
+
`MOCK_CONST_METHOD1(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td>
|
315
|
+
`MOCK_METHOD(bool, Foo, (int), (const))` </td> </tr>
|
316
|
+
|
317
|
+
<tr> <th colspan=2> Method in a Class Template </th></tr> <tr> <td> Old </td>
|
318
|
+
<td> `MOCK_METHOD1_T(Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td>
|
319
|
+
`MOCK_METHOD(bool, Foo, (int))` </td> </tr>
|
320
|
+
|
321
|
+
<tr> <th colspan=2> Const Method in a Class Template </th></tr> <tr> <td> Old
|
322
|
+
</td> <td> `MOCK_CONST_METHOD1_T(Foo, bool(int))` </td> </tr> <tr> <td> New
|
323
|
+
</td> <td> `MOCK_METHOD(bool, Foo, (int), (const))` </td> </tr>
|
324
|
+
|
325
|
+
<tr> <th colspan=2> Method with Call Type </th></tr> <tr> <td> Old </td> <td>
|
326
|
+
`MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td> </tr> <tr>
|
327
|
+
<td> New </td> <td> `MOCK_METHOD(bool, Foo, (int),
|
328
|
+
(Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
329
|
+
|
330
|
+
<tr> <th colspan=2> Const Method with Call Type </th></tr> <tr> <td> Old</td>
|
331
|
+
<td> `MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int))` </td>
|
332
|
+
</tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int), (const,
|
333
|
+
Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
334
|
+
|
335
|
+
<tr> <th colspan=2> Method with Call Type in a Class Template </th></tr> <tr>
|
336
|
+
<td> Old </td> <td> `MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo,
|
337
|
+
bool(int))` </td> </tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo, (int),
|
338
|
+
(Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
339
|
+
|
340
|
+
<tr> <th colspan=2> Const Method with Call Type in a Class Template </th></tr>
|
341
|
+
<tr> <td> Old </td> <td> `MOCK_CONST_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE,
|
342
|
+
Foo, bool(int))` </td> </tr> <tr> <td> New </td> <td> `MOCK_METHOD(bool, Foo,
|
343
|
+
(int), (const, Calltype(STDMETHODCALLTYPE)))` </td> </tr>
|
344
|
+
|
345
|
+
</table>
|
346
|
+
|
347
|
+
### The Nice, the Strict, and the Naggy {#NiceStrictNaggy}
|
348
|
+
|
349
|
+
If a mock method has no `EXPECT_CALL` spec but is called, we say that it's an
|
350
|
+
"uninteresting call", and the default action (which can be specified using
|
351
|
+
`ON_CALL()`) of the method will be taken. Currently, an uninteresting call will
|
352
|
+
also by default cause gMock to print a warning. (In the future, we might remove
|
353
|
+
this warning by default.)
|
354
|
+
|
355
|
+
However, sometimes you may want to ignore these uninteresting calls, and
|
356
|
+
sometimes you may want to treat them as errors. gMock lets you make the decision
|
357
|
+
on a per-mock-object basis.
|
358
|
+
|
359
|
+
Suppose your test uses a mock class `MockFoo`:
|
360
|
+
|
361
|
+
```cpp
|
362
|
+
TEST(...) {
|
363
|
+
MockFoo mock_foo;
|
364
|
+
EXPECT_CALL(mock_foo, DoThis());
|
365
|
+
... code that uses mock_foo ...
|
366
|
+
}
|
367
|
+
```
|
368
|
+
|
369
|
+
If a method of `mock_foo` other than `DoThis()` is called, you will get a
|
370
|
+
warning. However, if you rewrite your test to use `NiceMock<MockFoo>` instead,
|
371
|
+
you can suppress the warning:
|
372
|
+
|
373
|
+
```cpp
|
374
|
+
using ::testing::NiceMock;
|
375
|
+
|
376
|
+
TEST(...) {
|
377
|
+
NiceMock<MockFoo> mock_foo;
|
378
|
+
EXPECT_CALL(mock_foo, DoThis());
|
379
|
+
... code that uses mock_foo ...
|
380
|
+
}
|
381
|
+
```
|
382
|
+
|
383
|
+
`NiceMock<MockFoo>` is a subclass of `MockFoo`, so it can be used wherever
|
384
|
+
`MockFoo` is accepted.
|
385
|
+
|
386
|
+
It also works if `MockFoo`'s constructor takes some arguments, as
|
387
|
+
`NiceMock<MockFoo>` "inherits" `MockFoo`'s constructors:
|
388
|
+
|
389
|
+
```cpp
|
390
|
+
using ::testing::NiceMock;
|
391
|
+
|
392
|
+
TEST(...) {
|
393
|
+
NiceMock<MockFoo> mock_foo(5, "hi"); // Calls MockFoo(5, "hi").
|
394
|
+
EXPECT_CALL(mock_foo, DoThis());
|
395
|
+
... code that uses mock_foo ...
|
396
|
+
}
|
397
|
+
```
|
398
|
+
|
399
|
+
The usage of `StrictMock` is similar, except that it makes all uninteresting
|
400
|
+
calls failures:
|
401
|
+
|
402
|
+
```cpp
|
403
|
+
using ::testing::StrictMock;
|
404
|
+
|
405
|
+
TEST(...) {
|
406
|
+
StrictMock<MockFoo> mock_foo;
|
407
|
+
EXPECT_CALL(mock_foo, DoThis());
|
408
|
+
... code that uses mock_foo ...
|
409
|
+
|
410
|
+
// The test will fail if a method of mock_foo other than DoThis()
|
411
|
+
// is called.
|
412
|
+
}
|
413
|
+
```
|
414
|
+
|
415
|
+
NOTE: `NiceMock` and `StrictMock` only affects *uninteresting* calls (calls of
|
416
|
+
*methods* with no expectations); they do not affect *unexpected* calls (calls of
|
417
|
+
methods with expectations, but they don't match). See
|
418
|
+
[Understanding Uninteresting vs Unexpected Calls](#uninteresting-vs-unexpected).
|
419
|
+
|
420
|
+
There are some caveats though (sadly they are side effects of C++'s
|
421
|
+
limitations):
|
422
|
+
|
423
|
+
1. `NiceMock<MockFoo>` and `StrictMock<MockFoo>` only work for mock methods
|
424
|
+
defined using the `MOCK_METHOD` macro **directly** in the `MockFoo` class.
|
425
|
+
If a mock method is defined in a **base class** of `MockFoo`, the "nice" or
|
426
|
+
"strict" modifier may not affect it, depending on the compiler. In
|
427
|
+
particular, nesting `NiceMock` and `StrictMock` (e.g.
|
428
|
+
`NiceMock<StrictMock<MockFoo> >`) is **not** supported.
|
429
|
+
2. `NiceMock<MockFoo>` and `StrictMock<MockFoo>` may not work correctly if the
|
430
|
+
destructor of `MockFoo` is not virtual. We would like to fix this, but it
|
431
|
+
requires cleaning up existing tests.
|
432
|
+
3. During the constructor or destructor of `MockFoo`, the mock object is *not*
|
433
|
+
nice or strict. This may cause surprises if the constructor or destructor
|
434
|
+
calls a mock method on `this` object. (This behavior, however, is consistent
|
435
|
+
with C++'s general rule: if a constructor or destructor calls a virtual
|
436
|
+
method of `this` object, that method is treated as non-virtual. In other
|
437
|
+
words, to the base class's constructor or destructor, `this` object behaves
|
438
|
+
like an instance of the base class, not the derived class. This rule is
|
439
|
+
required for safety. Otherwise a base constructor may use members of a
|
440
|
+
derived class before they are initialized, or a base destructor may use
|
441
|
+
members of a derived class after they have been destroyed.)
|
442
|
+
|
443
|
+
Finally, you should be **very cautious** about when to use naggy or strict
|
444
|
+
mocks, as they tend to make tests more brittle and harder to maintain. When you
|
445
|
+
refactor your code without changing its externally visible behavior, ideally you
|
446
|
+
shouldn't need to update any tests. If your code interacts with a naggy mock,
|
447
|
+
however, you may start to get spammed with warnings as the result of your
|
448
|
+
change. Worse, if your code interacts with a strict mock, your tests may start
|
449
|
+
to fail and you'll be forced to fix them. Our general recommendation is to use
|
450
|
+
nice mocks (not yet the default) most of the time, use naggy mocks (the current
|
451
|
+
default) when developing or debugging tests, and use strict mocks only as the
|
452
|
+
last resort.
|
453
|
+
|
454
|
+
### Simplifying the Interface without Breaking Existing Code {#SimplerInterfaces}
|
455
|
+
|
456
|
+
Sometimes a method has a long list of arguments that is mostly uninteresting.
|
457
|
+
For example:
|
458
|
+
|
459
|
+
```cpp
|
460
|
+
class LogSink {
|
461
|
+
public:
|
462
|
+
...
|
463
|
+
virtual void send(LogSeverity severity, const char* full_filename,
|
464
|
+
const char* base_filename, int line,
|
465
|
+
const struct tm* tm_time,
|
466
|
+
const char* message, size_t message_len) = 0;
|
467
|
+
};
|
468
|
+
```
|
469
|
+
|
470
|
+
This method's argument list is lengthy and hard to work with (the `message`
|
471
|
+
argument is not even 0-terminated). If we mock it as is, using the mock will be
|
472
|
+
awkward. If, however, we try to simplify this interface, we'll need to fix all
|
473
|
+
clients depending on it, which is often infeasible.
|
474
|
+
|
475
|
+
The trick is to redispatch the method in the mock class:
|
476
|
+
|
477
|
+
```cpp
|
478
|
+
class ScopedMockLog : public LogSink {
|
479
|
+
public:
|
480
|
+
...
|
481
|
+
virtual void send(LogSeverity severity, const char* full_filename,
|
482
|
+
const char* base_filename, int line, const tm* tm_time,
|
483
|
+
const char* message, size_t message_len) {
|
484
|
+
// We are only interested in the log severity, full file name, and
|
485
|
+
// log message.
|
486
|
+
Log(severity, full_filename, std::string(message, message_len));
|
487
|
+
}
|
488
|
+
|
489
|
+
// Implements the mock method:
|
490
|
+
//
|
491
|
+
// void Log(LogSeverity severity,
|
492
|
+
// const string& file_path,
|
493
|
+
// const string& message);
|
494
|
+
MOCK_METHOD(void, Log,
|
495
|
+
(LogSeverity severity, const string& file_path,
|
496
|
+
const string& message));
|
497
|
+
};
|
498
|
+
```
|
499
|
+
|
500
|
+
By defining a new mock method with a trimmed argument list, we make the mock
|
501
|
+
class more user-friendly.
|
502
|
+
|
503
|
+
This technique may also be applied to make overloaded methods more amenable to
|
504
|
+
mocking. For example, when overloads have been used to implement default
|
505
|
+
arguments:
|
506
|
+
|
507
|
+
```cpp
|
508
|
+
class MockTurtleFactory : public TurtleFactory {
|
509
|
+
public:
|
510
|
+
Turtle* MakeTurtle(int length, int weight) override { ... }
|
511
|
+
Turtle* MakeTurtle(int length, int weight, int speed) override { ... }
|
512
|
+
|
513
|
+
// the above methods delegate to this one:
|
514
|
+
MOCK_METHOD(Turtle*, DoMakeTurtle, ());
|
515
|
+
};
|
516
|
+
```
|
517
|
+
|
518
|
+
This allows tests that don't care which overload was invoked to avoid specifying
|
519
|
+
argument matchers:
|
520
|
+
|
521
|
+
```cpp
|
522
|
+
ON_CALL(factory, DoMakeTurtle)
|
523
|
+
.WillByDefault(Return(MakeMockTurtle()));
|
524
|
+
```
|
525
|
+
|
526
|
+
### Alternative to Mocking Concrete Classes
|
527
|
+
|
528
|
+
Often you may find yourself using classes that don't implement interfaces. In
|
529
|
+
order to test your code that uses such a class (let's call it `Concrete`), you
|
530
|
+
may be tempted to make the methods of `Concrete` virtual and then mock it.
|
531
|
+
|
532
|
+
Try not to do that.
|
533
|
+
|
534
|
+
Making a non-virtual function virtual is a big decision. It creates an extension
|
535
|
+
point where subclasses can tweak your class' behavior. This weakens your control
|
536
|
+
on the class because now it's harder to maintain the class invariants. You
|
537
|
+
should make a function virtual only when there is a valid reason for a subclass
|
538
|
+
to override it.
|
539
|
+
|
540
|
+
Mocking concrete classes directly is problematic as it creates a tight coupling
|
541
|
+
between the class and the tests - any small change in the class may invalidate
|
542
|
+
your tests and make test maintenance a pain.
|
543
|
+
|
544
|
+
To avoid such problems, many programmers have been practicing "coding to
|
545
|
+
interfaces": instead of talking to the `Concrete` class, your code would define
|
546
|
+
an interface and talk to it. Then you implement that interface as an adaptor on
|
547
|
+
top of `Concrete`. In tests, you can easily mock that interface to observe how
|
548
|
+
your code is doing.
|
549
|
+
|
550
|
+
This technique incurs some overhead:
|
551
|
+
|
552
|
+
* You pay the cost of virtual function calls (usually not a problem).
|
553
|
+
* There is more abstraction for the programmers to learn.
|
554
|
+
|
555
|
+
However, it can also bring significant benefits in addition to better
|
556
|
+
testability:
|
557
|
+
|
558
|
+
* `Concrete`'s API may not fit your problem domain very well, as you may not
|
559
|
+
be the only client it tries to serve. By designing your own interface, you
|
560
|
+
have a chance to tailor it to your need - you may add higher-level
|
561
|
+
functionalities, rename stuff, etc instead of just trimming the class. This
|
562
|
+
allows you to write your code (user of the interface) in a more natural way,
|
563
|
+
which means it will be more readable, more maintainable, and you'll be more
|
564
|
+
productive.
|
565
|
+
* If `Concrete`'s implementation ever has to change, you don't have to rewrite
|
566
|
+
everywhere it is used. Instead, you can absorb the change in your
|
567
|
+
implementation of the interface, and your other code and tests will be
|
568
|
+
insulated from this change.
|
569
|
+
|
570
|
+
Some people worry that if everyone is practicing this technique, they will end
|
571
|
+
up writing lots of redundant code. This concern is totally understandable.
|
572
|
+
However, there are two reasons why it may not be the case:
|
573
|
+
|
574
|
+
* Different projects may need to use `Concrete` in different ways, so the best
|
575
|
+
interfaces for them will be different. Therefore, each of them will have its
|
576
|
+
own domain-specific interface on top of `Concrete`, and they will not be the
|
577
|
+
same code.
|
578
|
+
* If enough projects want to use the same interface, they can always share it,
|
579
|
+
just like they have been sharing `Concrete`. You can check in the interface
|
580
|
+
and the adaptor somewhere near `Concrete` (perhaps in a `contrib`
|
581
|
+
sub-directory) and let many projects use it.
|
582
|
+
|
583
|
+
You need to weigh the pros and cons carefully for your particular problem, but
|
584
|
+
I'd like to assure you that the Java community has been practicing this for a
|
585
|
+
long time and it's a proven effective technique applicable in a wide variety of
|
586
|
+
situations. :-)
|
587
|
+
|
588
|
+
### Delegating Calls to a Fake {#DelegatingToFake}
|
589
|
+
|
590
|
+
Some times you have a non-trivial fake implementation of an interface. For
|
591
|
+
example:
|
592
|
+
|
593
|
+
```cpp
|
594
|
+
class Foo {
|
595
|
+
public:
|
596
|
+
virtual ~Foo() {}
|
597
|
+
virtual char DoThis(int n) = 0;
|
598
|
+
virtual void DoThat(const char* s, int* p) = 0;
|
599
|
+
};
|
600
|
+
|
601
|
+
class FakeFoo : public Foo {
|
602
|
+
public:
|
603
|
+
char DoThis(int n) override {
|
604
|
+
return (n > 0) ? '+' :
|
605
|
+
(n < 0) ? '-' : '0';
|
606
|
+
}
|
607
|
+
|
608
|
+
void DoThat(const char* s, int* p) override {
|
609
|
+
*p = strlen(s);
|
610
|
+
}
|
611
|
+
};
|
612
|
+
```
|
613
|
+
|
614
|
+
Now you want to mock this interface such that you can set expectations on it.
|
615
|
+
However, you also want to use `FakeFoo` for the default behavior, as duplicating
|
616
|
+
it in the mock object is, well, a lot of work.
|
617
|
+
|
618
|
+
When you define the mock class using gMock, you can have it delegate its default
|
619
|
+
action to a fake class you already have, using this pattern:
|
620
|
+
|
621
|
+
```cpp
|
622
|
+
class MockFoo : public Foo {
|
623
|
+
public:
|
624
|
+
// Normal mock method definitions using gMock.
|
625
|
+
MOCK_METHOD(char, DoThis, (int n), (override));
|
626
|
+
MOCK_METHOD(void, DoThat, (const char* s, int* p), (override));
|
627
|
+
|
628
|
+
// Delegates the default actions of the methods to a FakeFoo object.
|
629
|
+
// This must be called *before* the custom ON_CALL() statements.
|
630
|
+
void DelegateToFake() {
|
631
|
+
ON_CALL(*this, DoThis).WillByDefault([this](int n) {
|
632
|
+
return fake_.DoThis(n);
|
633
|
+
});
|
634
|
+
ON_CALL(*this, DoThat).WillByDefault([this](const char* s, int* p) {
|
635
|
+
fake_.DoThat(s, p);
|
636
|
+
});
|
637
|
+
}
|
638
|
+
|
639
|
+
private:
|
640
|
+
FakeFoo fake_; // Keeps an instance of the fake in the mock.
|
641
|
+
};
|
642
|
+
```
|
643
|
+
|
644
|
+
With that, you can use `MockFoo` in your tests as usual. Just remember that if
|
645
|
+
you don't explicitly set an action in an `ON_CALL()` or `EXPECT_CALL()`, the
|
646
|
+
fake will be called upon to do it.:
|
647
|
+
|
648
|
+
```cpp
|
649
|
+
using ::testing::_;
|
650
|
+
|
651
|
+
TEST(AbcTest, Xyz) {
|
652
|
+
MockFoo foo;
|
653
|
+
|
654
|
+
foo.DelegateToFake(); // Enables the fake for delegation.
|
655
|
+
|
656
|
+
// Put your ON_CALL(foo, ...)s here, if any.
|
657
|
+
|
658
|
+
// No action specified, meaning to use the default action.
|
659
|
+
EXPECT_CALL(foo, DoThis(5));
|
660
|
+
EXPECT_CALL(foo, DoThat(_, _));
|
661
|
+
|
662
|
+
int n = 0;
|
663
|
+
EXPECT_EQ('+', foo.DoThis(5)); // FakeFoo::DoThis() is invoked.
|
664
|
+
foo.DoThat("Hi", &n); // FakeFoo::DoThat() is invoked.
|
665
|
+
EXPECT_EQ(2, n);
|
666
|
+
}
|
667
|
+
```
|
668
|
+
|
669
|
+
**Some tips:**
|
670
|
+
|
671
|
+
* If you want, you can still override the default action by providing your own
|
672
|
+
`ON_CALL()` or using `.WillOnce()` / `.WillRepeatedly()` in `EXPECT_CALL()`.
|
673
|
+
* In `DelegateToFake()`, you only need to delegate the methods whose fake
|
674
|
+
implementation you intend to use.
|
675
|
+
|
676
|
+
* The general technique discussed here works for overloaded methods, but
|
677
|
+
you'll need to tell the compiler which version you mean. To disambiguate a
|
678
|
+
mock function (the one you specify inside the parentheses of `ON_CALL()`),
|
679
|
+
use [this technique](#SelectOverload); to disambiguate a fake function (the
|
680
|
+
one you place inside `Invoke()`), use a `static_cast` to specify the
|
681
|
+
function's type. For instance, if class `Foo` has methods `char DoThis(int
|
682
|
+
n)` and `bool DoThis(double x) const`, and you want to invoke the latter,
|
683
|
+
you need to write `Invoke(&fake_, static_cast<bool (FakeFoo::*)(double)
|
684
|
+
const>(&FakeFoo::DoThis))` instead of `Invoke(&fake_, &FakeFoo::DoThis)`
|
685
|
+
(The strange-looking thing inside the angled brackets of `static_cast` is
|
686
|
+
the type of a function pointer to the second `DoThis()` method.).
|
687
|
+
|
688
|
+
* Having to mix a mock and a fake is often a sign of something gone wrong.
|
689
|
+
Perhaps you haven't got used to the interaction-based way of testing yet. Or
|
690
|
+
perhaps your interface is taking on too many roles and should be split up.
|
691
|
+
Therefore, **don't abuse this**. We would only recommend to do it as an
|
692
|
+
intermediate step when you are refactoring your code.
|
693
|
+
|
694
|
+
Regarding the tip on mixing a mock and a fake, here's an example on why it may
|
695
|
+
be a bad sign: Suppose you have a class `System` for low-level system
|
696
|
+
operations. In particular, it does file and I/O operations. And suppose you want
|
697
|
+
to test how your code uses `System` to do I/O, and you just want the file
|
698
|
+
operations to work normally. If you mock out the entire `System` class, you'll
|
699
|
+
have to provide a fake implementation for the file operation part, which
|
700
|
+
suggests that `System` is taking on too many roles.
|
701
|
+
|
702
|
+
Instead, you can define a `FileOps` interface and an `IOOps` interface and split
|
703
|
+
`System`'s functionalities into the two. Then you can mock `IOOps` without
|
704
|
+
mocking `FileOps`.
|
705
|
+
|
706
|
+
### Delegating Calls to a Real Object
|
707
|
+
|
708
|
+
When using testing doubles (mocks, fakes, stubs, and etc), sometimes their
|
709
|
+
behaviors will differ from those of the real objects. This difference could be
|
710
|
+
either intentional (as in simulating an error such that you can test the error
|
711
|
+
handling code) or unintentional. If your mocks have different behaviors than the
|
712
|
+
real objects by mistake, you could end up with code that passes the tests but
|
713
|
+
fails in production.
|
714
|
+
|
715
|
+
You can use the *delegating-to-real* technique to ensure that your mock has the
|
716
|
+
same behavior as the real object while retaining the ability to validate calls.
|
717
|
+
This technique is very similar to the [delegating-to-fake](#DelegatingToFake)
|
718
|
+
technique, the difference being that we use a real object instead of a fake.
|
719
|
+
Here's an example:
|
720
|
+
|
721
|
+
```cpp
|
722
|
+
using ::testing::AtLeast;
|
723
|
+
|
724
|
+
class MockFoo : public Foo {
|
725
|
+
public:
|
726
|
+
MockFoo() {
|
727
|
+
// By default, all calls are delegated to the real object.
|
728
|
+
ON_CALL(*this, DoThis).WillByDefault([this](int n) {
|
729
|
+
return real_.DoThis(n);
|
730
|
+
});
|
731
|
+
ON_CALL(*this, DoThat).WillByDefault([this](const char* s, int* p) {
|
732
|
+
real_.DoThat(s, p);
|
733
|
+
});
|
734
|
+
...
|
735
|
+
}
|
736
|
+
MOCK_METHOD(char, DoThis, ...);
|
737
|
+
MOCK_METHOD(void, DoThat, ...);
|
738
|
+
...
|
739
|
+
private:
|
740
|
+
Foo real_;
|
741
|
+
};
|
742
|
+
|
743
|
+
...
|
744
|
+
MockFoo mock;
|
745
|
+
EXPECT_CALL(mock, DoThis())
|
746
|
+
.Times(3);
|
747
|
+
EXPECT_CALL(mock, DoThat("Hi"))
|
748
|
+
.Times(AtLeast(1));
|
749
|
+
... use mock in test ...
|
750
|
+
```
|
751
|
+
|
752
|
+
With this, gMock will verify that your code made the right calls (with the right
|
753
|
+
arguments, in the right order, called the right number of times, etc), and a
|
754
|
+
real object will answer the calls (so the behavior will be the same as in
|
755
|
+
production). This gives you the best of both worlds.
|
756
|
+
|
757
|
+
### Delegating Calls to a Parent Class
|
758
|
+
|
759
|
+
Ideally, you should code to interfaces, whose methods are all pure virtual. In
|
760
|
+
reality, sometimes you do need to mock a virtual method that is not pure (i.e,
|
761
|
+
it already has an implementation). For example:
|
762
|
+
|
763
|
+
```cpp
|
764
|
+
class Foo {
|
765
|
+
public:
|
766
|
+
virtual ~Foo();
|
767
|
+
|
768
|
+
virtual void Pure(int n) = 0;
|
769
|
+
virtual int Concrete(const char* str) { ... }
|
770
|
+
};
|
771
|
+
|
772
|
+
class MockFoo : public Foo {
|
773
|
+
public:
|
774
|
+
// Mocking a pure method.
|
775
|
+
MOCK_METHOD(void, Pure, (int n), (override));
|
776
|
+
// Mocking a concrete method. Foo::Concrete() is shadowed.
|
777
|
+
MOCK_METHOD(int, Concrete, (const char* str), (override));
|
778
|
+
};
|
779
|
+
```
|
780
|
+
|
781
|
+
Sometimes you may want to call `Foo::Concrete()` instead of
|
782
|
+
`MockFoo::Concrete()`. Perhaps you want to do it as part of a stub action, or
|
783
|
+
perhaps your test doesn't need to mock `Concrete()` at all (but it would be
|
784
|
+
oh-so painful to have to define a new mock class whenever you don't need to mock
|
785
|
+
one of its methods).
|
786
|
+
|
787
|
+
You can call `Foo::Concrete()` inside an action by:
|
788
|
+
|
789
|
+
```cpp
|
790
|
+
...
|
791
|
+
EXPECT_CALL(foo, Concrete).WillOnce([&foo](const char* str) {
|
792
|
+
return foo.Foo::Concrete(str);
|
793
|
+
});
|
794
|
+
```
|
795
|
+
|
796
|
+
or tell the mock object that you don't want to mock `Concrete()`:
|
797
|
+
|
798
|
+
```cpp
|
799
|
+
...
|
800
|
+
ON_CALL(foo, Concrete).WillByDefault([&foo](const char* str) {
|
801
|
+
return foo.Foo::Concrete(str);
|
802
|
+
});
|
803
|
+
```
|
804
|
+
|
805
|
+
(Why don't we just write `{ return foo.Concrete(str); }`? If you do that,
|
806
|
+
`MockFoo::Concrete()` will be called (and cause an infinite recursion) since
|
807
|
+
`Foo::Concrete()` is virtual. That's just how C++ works.)
|
808
|
+
|
809
|
+
## Using Matchers
|
810
|
+
|
811
|
+
### Matching Argument Values Exactly
|
812
|
+
|
813
|
+
You can specify exactly which arguments a mock method is expecting:
|
814
|
+
|
815
|
+
```cpp
|
816
|
+
using ::testing::Return;
|
817
|
+
...
|
818
|
+
EXPECT_CALL(foo, DoThis(5))
|
819
|
+
.WillOnce(Return('a'));
|
820
|
+
EXPECT_CALL(foo, DoThat("Hello", bar));
|
821
|
+
```
|
822
|
+
|
823
|
+
### Using Simple Matchers
|
824
|
+
|
825
|
+
You can use matchers to match arguments that have a certain property:
|
826
|
+
|
827
|
+
```cpp
|
828
|
+
using ::testing::NotNull;
|
829
|
+
using ::testing::Return;
|
830
|
+
...
|
831
|
+
EXPECT_CALL(foo, DoThis(Ge(5))) // The argument must be >= 5.
|
832
|
+
.WillOnce(Return('a'));
|
833
|
+
EXPECT_CALL(foo, DoThat("Hello", NotNull()));
|
834
|
+
// The second argument must not be NULL.
|
835
|
+
```
|
836
|
+
|
837
|
+
A frequently used matcher is `_`, which matches anything:
|
838
|
+
|
839
|
+
```cpp
|
840
|
+
EXPECT_CALL(foo, DoThat(_, NotNull()));
|
841
|
+
```
|
842
|
+
<!-- GOOGLETEST_CM0022 DO NOT DELETE -->
|
843
|
+
|
844
|
+
### Combining Matchers {#CombiningMatchers}
|
845
|
+
|
846
|
+
You can build complex matchers from existing ones using `AllOf()`,
|
847
|
+
`AllOfArray()`, `AnyOf()`, `AnyOfArray()` and `Not()`:
|
848
|
+
|
849
|
+
```cpp
|
850
|
+
using ::testing::AllOf;
|
851
|
+
using ::testing::Gt;
|
852
|
+
using ::testing::HasSubstr;
|
853
|
+
using ::testing::Ne;
|
854
|
+
using ::testing::Not;
|
855
|
+
...
|
856
|
+
// The argument must be > 5 and != 10.
|
857
|
+
EXPECT_CALL(foo, DoThis(AllOf(Gt(5),
|
858
|
+
Ne(10))));
|
859
|
+
|
860
|
+
// The first argument must not contain sub-string "blah".
|
861
|
+
EXPECT_CALL(foo, DoThat(Not(HasSubstr("blah")),
|
862
|
+
NULL));
|
863
|
+
```
|
864
|
+
|
865
|
+
Matchers are function objects, and parametrized matchers can be composed just
|
866
|
+
like any other function. However because their types can be long and rarely
|
867
|
+
provide meaningful information, it can be easier to express them with C++14
|
868
|
+
generic lambdas to avoid specifying types. For example,
|
869
|
+
|
870
|
+
```cpp
|
871
|
+
using ::testing::Contains;
|
872
|
+
using ::testing::Property;
|
873
|
+
|
874
|
+
inline constexpr auto HasFoo = [](const auto& f) {
|
875
|
+
return Property(&MyClass::foo, Contains(f));
|
876
|
+
};
|
877
|
+
...
|
878
|
+
EXPECT_THAT(x, HasFoo("blah"));
|
879
|
+
```
|
880
|
+
|
881
|
+
### Casting Matchers {#SafeMatcherCast}
|
882
|
+
|
883
|
+
gMock matchers are statically typed, meaning that the compiler can catch your
|
884
|
+
mistake if you use a matcher of the wrong type (for example, if you use `Eq(5)`
|
885
|
+
to match a `string` argument). Good for you!
|
886
|
+
|
887
|
+
Sometimes, however, you know what you're doing and want the compiler to give you
|
888
|
+
some slack. One example is that you have a matcher for `long` and the argument
|
889
|
+
you want to match is `int`. While the two types aren't exactly the same, there
|
890
|
+
is nothing really wrong with using a `Matcher<long>` to match an `int` - after
|
891
|
+
all, we can first convert the `int` argument to a `long` losslessly before
|
892
|
+
giving it to the matcher.
|
893
|
+
|
894
|
+
To support this need, gMock gives you the `SafeMatcherCast<T>(m)` function. It
|
895
|
+
casts a matcher `m` to type `Matcher<T>`. To ensure safety, gMock checks that
|
896
|
+
(let `U` be the type `m` accepts :
|
897
|
+
|
898
|
+
1. Type `T` can be *implicitly* cast to type `U`;
|
899
|
+
2. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and
|
900
|
+
floating-point numbers), the conversion from `T` to `U` is not lossy (in
|
901
|
+
other words, any value representable by `T` can also be represented by `U`);
|
902
|
+
and
|
903
|
+
3. When `U` is a reference, `T` must also be a reference (as the underlying
|
904
|
+
matcher may be interested in the address of the `U` value).
|
905
|
+
|
906
|
+
The code won't compile if any of these conditions isn't met.
|
907
|
+
|
908
|
+
Here's one example:
|
909
|
+
|
910
|
+
```cpp
|
911
|
+
using ::testing::SafeMatcherCast;
|
912
|
+
|
913
|
+
// A base class and a child class.
|
914
|
+
class Base { ... };
|
915
|
+
class Derived : public Base { ... };
|
916
|
+
|
917
|
+
class MockFoo : public Foo {
|
918
|
+
public:
|
919
|
+
MOCK_METHOD(void, DoThis, (Derived* derived), (override));
|
920
|
+
};
|
921
|
+
|
922
|
+
...
|
923
|
+
MockFoo foo;
|
924
|
+
// m is a Matcher<Base*> we got from somewhere.
|
925
|
+
EXPECT_CALL(foo, DoThis(SafeMatcherCast<Derived*>(m)));
|
926
|
+
```
|
927
|
+
|
928
|
+
If you find `SafeMatcherCast<T>(m)` too limiting, you can use a similar function
|
929
|
+
`MatcherCast<T>(m)`. The difference is that `MatcherCast` works as long as you
|
930
|
+
can `static_cast` type `T` to type `U`.
|
931
|
+
|
932
|
+
`MatcherCast` essentially lets you bypass C++'s type system (`static_cast` isn't
|
933
|
+
always safe as it could throw away information, for example), so be careful not
|
934
|
+
to misuse/abuse it.
|
935
|
+
|
936
|
+
### Selecting Between Overloaded Functions {#SelectOverload}
|
937
|
+
|
938
|
+
If you expect an overloaded function to be called, the compiler may need some
|
939
|
+
help on which overloaded version it is.
|
940
|
+
|
941
|
+
To disambiguate functions overloaded on the const-ness of this object, use the
|
942
|
+
`Const()` argument wrapper.
|
943
|
+
|
944
|
+
```cpp
|
945
|
+
using ::testing::ReturnRef;
|
946
|
+
|
947
|
+
class MockFoo : public Foo {
|
948
|
+
...
|
949
|
+
MOCK_METHOD(Bar&, GetBar, (), (override));
|
950
|
+
MOCK_METHOD(const Bar&, GetBar, (), (const, override));
|
951
|
+
};
|
952
|
+
|
953
|
+
...
|
954
|
+
MockFoo foo;
|
955
|
+
Bar bar1, bar2;
|
956
|
+
EXPECT_CALL(foo, GetBar()) // The non-const GetBar().
|
957
|
+
.WillOnce(ReturnRef(bar1));
|
958
|
+
EXPECT_CALL(Const(foo), GetBar()) // The const GetBar().
|
959
|
+
.WillOnce(ReturnRef(bar2));
|
960
|
+
```
|
961
|
+
|
962
|
+
(`Const()` is defined by gMock and returns a `const` reference to its argument.)
|
963
|
+
|
964
|
+
To disambiguate overloaded functions with the same number of arguments but
|
965
|
+
different argument types, you may need to specify the exact type of a matcher,
|
966
|
+
either by wrapping your matcher in `Matcher<type>()`, or using a matcher whose
|
967
|
+
type is fixed (`TypedEq<type>`, `An<type>()`, etc):
|
968
|
+
|
969
|
+
```cpp
|
970
|
+
using ::testing::An;
|
971
|
+
using ::testing::Matcher;
|
972
|
+
using ::testing::TypedEq;
|
973
|
+
|
974
|
+
class MockPrinter : public Printer {
|
975
|
+
public:
|
976
|
+
MOCK_METHOD(void, Print, (int n), (override));
|
977
|
+
MOCK_METHOD(void, Print, (char c), (override));
|
978
|
+
};
|
979
|
+
|
980
|
+
TEST(PrinterTest, Print) {
|
981
|
+
MockPrinter printer;
|
982
|
+
|
983
|
+
EXPECT_CALL(printer, Print(An<int>())); // void Print(int);
|
984
|
+
EXPECT_CALL(printer, Print(Matcher<int>(Lt(5)))); // void Print(int);
|
985
|
+
EXPECT_CALL(printer, Print(TypedEq<char>('a'))); // void Print(char);
|
986
|
+
|
987
|
+
printer.Print(3);
|
988
|
+
printer.Print(6);
|
989
|
+
printer.Print('a');
|
990
|
+
}
|
991
|
+
```
|
992
|
+
|
993
|
+
### Performing Different Actions Based on the Arguments
|
994
|
+
|
995
|
+
When a mock method is called, the *last* matching expectation that's still
|
996
|
+
active will be selected (think "newer overrides older"). So, you can make a
|
997
|
+
method do different things depending on its argument values like this:
|
998
|
+
|
999
|
+
```cpp
|
1000
|
+
using ::testing::_;
|
1001
|
+
using ::testing::Lt;
|
1002
|
+
using ::testing::Return;
|
1003
|
+
...
|
1004
|
+
// The default case.
|
1005
|
+
EXPECT_CALL(foo, DoThis(_))
|
1006
|
+
.WillRepeatedly(Return('b'));
|
1007
|
+
// The more specific case.
|
1008
|
+
EXPECT_CALL(foo, DoThis(Lt(5)))
|
1009
|
+
.WillRepeatedly(Return('a'));
|
1010
|
+
```
|
1011
|
+
|
1012
|
+
Now, if `foo.DoThis()` is called with a value less than 5, `'a'` will be
|
1013
|
+
returned; otherwise `'b'` will be returned.
|
1014
|
+
|
1015
|
+
### Matching Multiple Arguments as a Whole
|
1016
|
+
|
1017
|
+
Sometimes it's not enough to match the arguments individually. For example, we
|
1018
|
+
may want to say that the first argument must be less than the second argument.
|
1019
|
+
The `With()` clause allows us to match all arguments of a mock function as a
|
1020
|
+
whole. For example,
|
1021
|
+
|
1022
|
+
```cpp
|
1023
|
+
using ::testing::_;
|
1024
|
+
using ::testing::Ne;
|
1025
|
+
using ::testing::Lt;
|
1026
|
+
...
|
1027
|
+
EXPECT_CALL(foo, InRange(Ne(0), _))
|
1028
|
+
.With(Lt());
|
1029
|
+
```
|
1030
|
+
|
1031
|
+
says that the first argument of `InRange()` must not be 0, and must be less than
|
1032
|
+
the second argument.
|
1033
|
+
|
1034
|
+
The expression inside `With()` must be a matcher of type `Matcher<std::tuple<A1,
|
1035
|
+
..., An>>`, where `A1`, ..., `An` are the types of the function arguments.
|
1036
|
+
|
1037
|
+
You can also write `AllArgs(m)` instead of `m` inside `.With()`. The two forms
|
1038
|
+
are equivalent, but `.With(AllArgs(Lt()))` is more readable than `.With(Lt())`.
|
1039
|
+
|
1040
|
+
You can use `Args<k1, ..., kn>(m)` to match the `n` selected arguments (as a
|
1041
|
+
tuple) against `m`. For example,
|
1042
|
+
|
1043
|
+
```cpp
|
1044
|
+
using ::testing::_;
|
1045
|
+
using ::testing::AllOf;
|
1046
|
+
using ::testing::Args;
|
1047
|
+
using ::testing::Lt;
|
1048
|
+
...
|
1049
|
+
EXPECT_CALL(foo, Blah)
|
1050
|
+
.With(AllOf(Args<0, 1>(Lt()), Args<1, 2>(Lt())));
|
1051
|
+
```
|
1052
|
+
|
1053
|
+
says that `Blah` will be called with arguments `x`, `y`, and `z` where `x < y <
|
1054
|
+
z`. Note that in this example, it wasn't necessary specify the positional
|
1055
|
+
matchers.
|
1056
|
+
|
1057
|
+
As a convenience and example, gMock provides some matchers for 2-tuples,
|
1058
|
+
including the `Lt()` matcher above. See [here](#MultiArgMatchers) for the
|
1059
|
+
complete list.
|
1060
|
+
|
1061
|
+
Note that if you want to pass the arguments to a predicate of your own (e.g.
|
1062
|
+
`.With(Args<0, 1>(Truly(&MyPredicate)))`), that predicate MUST be written to
|
1063
|
+
take a `std::tuple` as its argument; gMock will pass the `n` selected arguments
|
1064
|
+
as *one* single tuple to the predicate.
|
1065
|
+
|
1066
|
+
### Using Matchers as Predicates
|
1067
|
+
|
1068
|
+
Have you noticed that a matcher is just a fancy predicate that also knows how to
|
1069
|
+
describe itself? Many existing algorithms take predicates as arguments (e.g.
|
1070
|
+
those defined in STL's `<algorithm>` header), and it would be a shame if gMock
|
1071
|
+
matchers were not allowed to participate.
|
1072
|
+
|
1073
|
+
Luckily, you can use a matcher where a unary predicate functor is expected by
|
1074
|
+
wrapping it inside the `Matches()` function. For example,
|
1075
|
+
|
1076
|
+
```cpp
|
1077
|
+
#include <algorithm>
|
1078
|
+
#include <vector>
|
1079
|
+
|
1080
|
+
using ::testing::Matches;
|
1081
|
+
using ::testing::Ge;
|
1082
|
+
|
1083
|
+
vector<int> v;
|
1084
|
+
...
|
1085
|
+
// How many elements in v are >= 10?
|
1086
|
+
const int count = count_if(v.begin(), v.end(), Matches(Ge(10)));
|
1087
|
+
```
|
1088
|
+
|
1089
|
+
Since you can build complex matchers from simpler ones easily using gMock, this
|
1090
|
+
gives you a way to conveniently construct composite predicates (doing the same
|
1091
|
+
using STL's `<functional>` header is just painful). For example, here's a
|
1092
|
+
predicate that's satisfied by any number that is >= 0, <= 100, and != 50:
|
1093
|
+
|
1094
|
+
```cpp
|
1095
|
+
using testing::AllOf;
|
1096
|
+
using testing::Ge;
|
1097
|
+
using testing::Le;
|
1098
|
+
using testing::Matches;
|
1099
|
+
using testing::Ne;
|
1100
|
+
...
|
1101
|
+
Matches(AllOf(Ge(0), Le(100), Ne(50)))
|
1102
|
+
```
|
1103
|
+
|
1104
|
+
### Using Matchers in googletest Assertions
|
1105
|
+
|
1106
|
+
Since matchers are basically predicates that also know how to describe
|
1107
|
+
themselves, there is a way to take advantage of them in googletest assertions.
|
1108
|
+
It's called `ASSERT_THAT` and `EXPECT_THAT`:
|
1109
|
+
|
1110
|
+
```cpp
|
1111
|
+
ASSERT_THAT(value, matcher); // Asserts that value matches matcher.
|
1112
|
+
EXPECT_THAT(value, matcher); // The non-fatal version.
|
1113
|
+
```
|
1114
|
+
|
1115
|
+
For example, in a googletest test you can write:
|
1116
|
+
|
1117
|
+
```cpp
|
1118
|
+
#include "gmock/gmock.h"
|
1119
|
+
|
1120
|
+
using ::testing::AllOf;
|
1121
|
+
using ::testing::Ge;
|
1122
|
+
using ::testing::Le;
|
1123
|
+
using ::testing::MatchesRegex;
|
1124
|
+
using ::testing::StartsWith;
|
1125
|
+
|
1126
|
+
...
|
1127
|
+
EXPECT_THAT(Foo(), StartsWith("Hello"));
|
1128
|
+
EXPECT_THAT(Bar(), MatchesRegex("Line \\d+"));
|
1129
|
+
ASSERT_THAT(Baz(), AllOf(Ge(5), Le(10)));
|
1130
|
+
```
|
1131
|
+
|
1132
|
+
which (as you can probably guess) executes `Foo()`, `Bar()`, and `Baz()`, and
|
1133
|
+
verifies that:
|
1134
|
+
|
1135
|
+
* `Foo()` returns a string that starts with `"Hello"`.
|
1136
|
+
* `Bar()` returns a string that matches regular expression `"Line \\d+"`.
|
1137
|
+
* `Baz()` returns a number in the range [5, 10].
|
1138
|
+
|
1139
|
+
The nice thing about these macros is that *they read like English*. They
|
1140
|
+
generate informative messages too. For example, if the first `EXPECT_THAT()`
|
1141
|
+
above fails, the message will be something like:
|
1142
|
+
|
1143
|
+
```cpp
|
1144
|
+
Value of: Foo()
|
1145
|
+
Actual: "Hi, world!"
|
1146
|
+
Expected: starts with "Hello"
|
1147
|
+
```
|
1148
|
+
|
1149
|
+
**Credit:** The idea of `(ASSERT|EXPECT)_THAT` was borrowed from Joe Walnes'
|
1150
|
+
Hamcrest project, which adds `assertThat()` to JUnit.
|
1151
|
+
|
1152
|
+
### Using Predicates as Matchers
|
1153
|
+
|
1154
|
+
gMock provides a [built-in set](cheat_sheet.md#MatcherList) of matchers. In case
|
1155
|
+
you find them lacking, you can use an arbitrary unary predicate function or
|
1156
|
+
functor as a matcher - as long as the predicate accepts a value of the type you
|
1157
|
+
want. You do this by wrapping the predicate inside the `Truly()` function, for
|
1158
|
+
example:
|
1159
|
+
|
1160
|
+
```cpp
|
1161
|
+
using ::testing::Truly;
|
1162
|
+
|
1163
|
+
int IsEven(int n) { return (n % 2) == 0 ? 1 : 0; }
|
1164
|
+
...
|
1165
|
+
// Bar() must be called with an even number.
|
1166
|
+
EXPECT_CALL(foo, Bar(Truly(IsEven)));
|
1167
|
+
```
|
1168
|
+
|
1169
|
+
Note that the predicate function / functor doesn't have to return `bool`. It
|
1170
|
+
works as long as the return value can be used as the condition in in statement
|
1171
|
+
`if (condition) ...`.
|
1172
|
+
|
1173
|
+
<!-- GOOGLETEST_CM0023 DO NOT DELETE -->
|
1174
|
+
|
1175
|
+
### Matching Arguments that Are Not Copyable
|
1176
|
+
|
1177
|
+
When you do an `EXPECT_CALL(mock_obj, Foo(bar))`, gMock saves away a copy of
|
1178
|
+
`bar`. When `Foo()` is called later, gMock compares the argument to `Foo()` with
|
1179
|
+
the saved copy of `bar`. This way, you don't need to worry about `bar` being
|
1180
|
+
modified or destroyed after the `EXPECT_CALL()` is executed. The same is true
|
1181
|
+
when you use matchers like `Eq(bar)`, `Le(bar)`, and so on.
|
1182
|
+
|
1183
|
+
But what if `bar` cannot be copied (i.e. has no copy constructor)? You could
|
1184
|
+
define your own matcher function or callback and use it with `Truly()`, as the
|
1185
|
+
previous couple of recipes have shown. Or, you may be able to get away from it
|
1186
|
+
if you can guarantee that `bar` won't be changed after the `EXPECT_CALL()` is
|
1187
|
+
executed. Just tell gMock that it should save a reference to `bar`, instead of a
|
1188
|
+
copy of it. Here's how:
|
1189
|
+
|
1190
|
+
```cpp
|
1191
|
+
using ::testing::Eq;
|
1192
|
+
using ::testing::Lt;
|
1193
|
+
...
|
1194
|
+
// Expects that Foo()'s argument == bar.
|
1195
|
+
EXPECT_CALL(mock_obj, Foo(Eq(std::ref(bar))));
|
1196
|
+
|
1197
|
+
// Expects that Foo()'s argument < bar.
|
1198
|
+
EXPECT_CALL(mock_obj, Foo(Lt(std::ref(bar))));
|
1199
|
+
```
|
1200
|
+
|
1201
|
+
Remember: if you do this, don't change `bar` after the `EXPECT_CALL()`, or the
|
1202
|
+
result is undefined.
|
1203
|
+
|
1204
|
+
### Validating a Member of an Object
|
1205
|
+
|
1206
|
+
Often a mock function takes a reference to object as an argument. When matching
|
1207
|
+
the argument, you may not want to compare the entire object against a fixed
|
1208
|
+
object, as that may be over-specification. Instead, you may need to validate a
|
1209
|
+
certain member variable or the result of a certain getter method of the object.
|
1210
|
+
You can do this with `Field()` and `Property()`. More specifically,
|
1211
|
+
|
1212
|
+
```cpp
|
1213
|
+
Field(&Foo::bar, m)
|
1214
|
+
```
|
1215
|
+
|
1216
|
+
is a matcher that matches a `Foo` object whose `bar` member variable satisfies
|
1217
|
+
matcher `m`.
|
1218
|
+
|
1219
|
+
```cpp
|
1220
|
+
Property(&Foo::baz, m)
|
1221
|
+
```
|
1222
|
+
|
1223
|
+
is a matcher that matches a `Foo` object whose `baz()` method returns a value
|
1224
|
+
that satisfies matcher `m`.
|
1225
|
+
|
1226
|
+
For example:
|
1227
|
+
|
1228
|
+
<!-- mdformat off(github rendering does not support multiline tables) -->
|
1229
|
+
| Expression | Description |
|
1230
|
+
| :--------------------------- | :--------------------------------------- |
|
1231
|
+
| `Field(&Foo::number, Ge(3))` | Matches `x` where `x.number >= 3`. |
|
1232
|
+
| `Property(&Foo::name, StartsWith("John "))` | Matches `x` where `x.name()` starts with `"John "`. |
|
1233
|
+
<!-- mdformat on -->
|
1234
|
+
|
1235
|
+
Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument
|
1236
|
+
and be declared as `const`.
|
1237
|
+
|
1238
|
+
BTW, `Field()` and `Property()` can also match plain pointers to objects. For
|
1239
|
+
instance,
|
1240
|
+
|
1241
|
+
```cpp
|
1242
|
+
using ::testing::Field;
|
1243
|
+
using ::testing::Ge;
|
1244
|
+
...
|
1245
|
+
Field(&Foo::number, Ge(3))
|
1246
|
+
```
|
1247
|
+
|
1248
|
+
matches a plain pointer `p` where `p->number >= 3`. If `p` is `NULL`, the match
|
1249
|
+
will always fail regardless of the inner matcher.
|
1250
|
+
|
1251
|
+
What if you want to validate more than one members at the same time? Remember
|
1252
|
+
that there are [`AllOf()` and `AllOfArray()`](#CombiningMatchers).
|
1253
|
+
|
1254
|
+
Finally `Field()` and `Property()` provide overloads that take the field or
|
1255
|
+
property names as the first argument to include it in the error message. This
|
1256
|
+
can be useful when creating combined matchers.
|
1257
|
+
|
1258
|
+
```cpp
|
1259
|
+
using ::testing::AllOf;
|
1260
|
+
using ::testing::Field;
|
1261
|
+
using ::testing::Matcher;
|
1262
|
+
using ::testing::SafeMatcherCast;
|
1263
|
+
|
1264
|
+
Matcher<Foo> IsFoo(const Foo& foo) {
|
1265
|
+
return AllOf(Field("some_field", &Foo::some_field, foo.some_field),
|
1266
|
+
Field("other_field", &Foo::other_field, foo.other_field),
|
1267
|
+
Field("last_field", &Foo::last_field, foo.last_field));
|
1268
|
+
}
|
1269
|
+
```
|
1270
|
+
|
1271
|
+
### Validating the Value Pointed to by a Pointer Argument
|
1272
|
+
|
1273
|
+
C++ functions often take pointers as arguments. You can use matchers like
|
1274
|
+
`IsNull()`, `NotNull()`, and other comparison matchers to match a pointer, but
|
1275
|
+
what if you want to make sure the value *pointed to* by the pointer, instead of
|
1276
|
+
the pointer itself, has a certain property? Well, you can use the `Pointee(m)`
|
1277
|
+
matcher.
|
1278
|
+
|
1279
|
+
`Pointee(m)` matches a pointer if and only if `m` matches the value the pointer
|
1280
|
+
points to. For example:
|
1281
|
+
|
1282
|
+
```cpp
|
1283
|
+
using ::testing::Ge;
|
1284
|
+
using ::testing::Pointee;
|
1285
|
+
...
|
1286
|
+
EXPECT_CALL(foo, Bar(Pointee(Ge(3))));
|
1287
|
+
```
|
1288
|
+
|
1289
|
+
expects `foo.Bar()` to be called with a pointer that points to a value greater
|
1290
|
+
than or equal to 3.
|
1291
|
+
|
1292
|
+
One nice thing about `Pointee()` is that it treats a `NULL` pointer as a match
|
1293
|
+
failure, so you can write `Pointee(m)` instead of
|
1294
|
+
|
1295
|
+
```cpp
|
1296
|
+
using ::testing::AllOf;
|
1297
|
+
using ::testing::NotNull;
|
1298
|
+
using ::testing::Pointee;
|
1299
|
+
...
|
1300
|
+
AllOf(NotNull(), Pointee(m))
|
1301
|
+
```
|
1302
|
+
|
1303
|
+
without worrying that a `NULL` pointer will crash your test.
|
1304
|
+
|
1305
|
+
Also, did we tell you that `Pointee()` works with both raw pointers **and**
|
1306
|
+
smart pointers (`std::unique_ptr`, `std::shared_ptr`, etc)?
|
1307
|
+
|
1308
|
+
What if you have a pointer to pointer? You guessed it - you can use nested
|
1309
|
+
`Pointee()` to probe deeper inside the value. For example,
|
1310
|
+
`Pointee(Pointee(Lt(3)))` matches a pointer that points to a pointer that points
|
1311
|
+
to a number less than 3 (what a mouthful...).
|
1312
|
+
|
1313
|
+
### Testing a Certain Property of an Object
|
1314
|
+
|
1315
|
+
Sometimes you want to specify that an object argument has a certain property,
|
1316
|
+
but there is no existing matcher that does this. If you want good error
|
1317
|
+
messages, you should [define a matcher](#NewMatchers). If you want to do it
|
1318
|
+
quick and dirty, you could get away with writing an ordinary function.
|
1319
|
+
|
1320
|
+
Let's say you have a mock function that takes an object of type `Foo`, which has
|
1321
|
+
an `int bar()` method and an `int baz()` method, and you want to constrain that
|
1322
|
+
the argument's `bar()` value plus its `baz()` value is a given number. Here's
|
1323
|
+
how you can define a matcher to do it:
|
1324
|
+
|
1325
|
+
```cpp
|
1326
|
+
using ::testing::Matcher;
|
1327
|
+
using ::testing::MatcherInterface;
|
1328
|
+
using ::testing::MatchResultListener;
|
1329
|
+
|
1330
|
+
class BarPlusBazEqMatcher : public MatcherInterface<const Foo&> {
|
1331
|
+
public:
|
1332
|
+
explicit BarPlusBazEqMatcher(int expected_sum)
|
1333
|
+
: expected_sum_(expected_sum) {}
|
1334
|
+
|
1335
|
+
bool MatchAndExplain(const Foo& foo,
|
1336
|
+
MatchResultListener* /* listener */) const override {
|
1337
|
+
return (foo.bar() + foo.baz()) == expected_sum_;
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
void DescribeTo(std::ostream* os) const override {
|
1341
|
+
*os << "bar() + baz() equals " << expected_sum_;
|
1342
|
+
}
|
1343
|
+
|
1344
|
+
void DescribeNegationTo(std::ostream* os) const override {
|
1345
|
+
*os << "bar() + baz() does not equal " << expected_sum_;
|
1346
|
+
}
|
1347
|
+
private:
|
1348
|
+
const int expected_sum_;
|
1349
|
+
};
|
1350
|
+
|
1351
|
+
Matcher<const Foo&> BarPlusBazEq(int expected_sum) {
|
1352
|
+
return MakeMatcher(new BarPlusBazEqMatcher(expected_sum));
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
...
|
1356
|
+
EXPECT_CALL(..., DoThis(BarPlusBazEq(5)))...;
|
1357
|
+
```
|
1358
|
+
|
1359
|
+
### Matching Containers
|
1360
|
+
|
1361
|
+
Sometimes an STL container (e.g. list, vector, map, ...) is passed to a mock
|
1362
|
+
function and you may want to validate it. Since most STL containers support the
|
1363
|
+
`==` operator, you can write `Eq(expected_container)` or simply
|
1364
|
+
`expected_container` to match a container exactly.
|
1365
|
+
|
1366
|
+
Sometimes, though, you may want to be more flexible (for example, the first
|
1367
|
+
element must be an exact match, but the second element can be any positive
|
1368
|
+
number, and so on). Also, containers used in tests often have a small number of
|
1369
|
+
elements, and having to define the expected container out-of-line is a bit of a
|
1370
|
+
hassle.
|
1371
|
+
|
1372
|
+
You can use the `ElementsAre()` or `UnorderedElementsAre()` matcher in such
|
1373
|
+
cases:
|
1374
|
+
|
1375
|
+
```cpp
|
1376
|
+
using ::testing::_;
|
1377
|
+
using ::testing::ElementsAre;
|
1378
|
+
using ::testing::Gt;
|
1379
|
+
...
|
1380
|
+
MOCK_METHOD(void, Foo, (const vector<int>& numbers), (override));
|
1381
|
+
...
|
1382
|
+
EXPECT_CALL(mock, Foo(ElementsAre(1, Gt(0), _, 5)));
|
1383
|
+
```
|
1384
|
+
|
1385
|
+
The above matcher says that the container must have 4 elements, which must be 1,
|
1386
|
+
greater than 0, anything, and 5 respectively.
|
1387
|
+
|
1388
|
+
If you instead write:
|
1389
|
+
|
1390
|
+
```cpp
|
1391
|
+
using ::testing::_;
|
1392
|
+
using ::testing::Gt;
|
1393
|
+
using ::testing::UnorderedElementsAre;
|
1394
|
+
...
|
1395
|
+
MOCK_METHOD(void, Foo, (const vector<int>& numbers), (override));
|
1396
|
+
...
|
1397
|
+
EXPECT_CALL(mock, Foo(UnorderedElementsAre(1, Gt(0), _, 5)));
|
1398
|
+
```
|
1399
|
+
|
1400
|
+
It means that the container must have 4 elements, which (under some permutation)
|
1401
|
+
must be 1, greater than 0, anything, and 5 respectively.
|
1402
|
+
|
1403
|
+
As an alternative you can place the arguments in a C-style array and use
|
1404
|
+
`ElementsAreArray()` or `UnorderedElementsAreArray()` instead:
|
1405
|
+
|
1406
|
+
```cpp
|
1407
|
+
using ::testing::ElementsAreArray;
|
1408
|
+
...
|
1409
|
+
// ElementsAreArray accepts an array of element values.
|
1410
|
+
const int expected_vector1[] = {1, 5, 2, 4, ...};
|
1411
|
+
EXPECT_CALL(mock, Foo(ElementsAreArray(expected_vector1)));
|
1412
|
+
|
1413
|
+
// Or, an array of element matchers.
|
1414
|
+
Matcher<int> expected_vector2[] = {1, Gt(2), _, 3, ...};
|
1415
|
+
EXPECT_CALL(mock, Foo(ElementsAreArray(expected_vector2)));
|
1416
|
+
```
|
1417
|
+
|
1418
|
+
In case the array needs to be dynamically created (and therefore the array size
|
1419
|
+
cannot be inferred by the compiler), you can give `ElementsAreArray()` an
|
1420
|
+
additional argument to specify the array size:
|
1421
|
+
|
1422
|
+
```cpp
|
1423
|
+
using ::testing::ElementsAreArray;
|
1424
|
+
...
|
1425
|
+
int* const expected_vector3 = new int[count];
|
1426
|
+
... fill expected_vector3 with values ...
|
1427
|
+
EXPECT_CALL(mock, Foo(ElementsAreArray(expected_vector3, count)));
|
1428
|
+
```
|
1429
|
+
|
1430
|
+
Use `Pair` when comparing maps or other associative containers.
|
1431
|
+
|
1432
|
+
```cpp
|
1433
|
+
using testing::ElementsAre;
|
1434
|
+
using testing::Pair;
|
1435
|
+
...
|
1436
|
+
std::map<string, int> m = {{"a", 1}, {"b", 2}, {"c", 3}};
|
1437
|
+
EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3)));
|
1438
|
+
```
|
1439
|
+
|
1440
|
+
**Tips:**
|
1441
|
+
|
1442
|
+
* `ElementsAre*()` can be used to match *any* container that implements the
|
1443
|
+
STL iterator pattern (i.e. it has a `const_iterator` type and supports
|
1444
|
+
`begin()/end()`), not just the ones defined in STL. It will even work with
|
1445
|
+
container types yet to be written - as long as they follows the above
|
1446
|
+
pattern.
|
1447
|
+
* You can use nested `ElementsAre*()` to match nested (multi-dimensional)
|
1448
|
+
containers.
|
1449
|
+
* If the container is passed by pointer instead of by reference, just write
|
1450
|
+
`Pointee(ElementsAre*(...))`.
|
1451
|
+
* The order of elements *matters* for `ElementsAre*()`. If you are using it
|
1452
|
+
with containers whose element order are undefined (e.g. `hash_map`) you
|
1453
|
+
should use `WhenSorted` around `ElementsAre`.
|
1454
|
+
|
1455
|
+
### Sharing Matchers
|
1456
|
+
|
1457
|
+
Under the hood, a gMock matcher object consists of a pointer to a ref-counted
|
1458
|
+
implementation object. Copying matchers is allowed and very efficient, as only
|
1459
|
+
the pointer is copied. When the last matcher that references the implementation
|
1460
|
+
object dies, the implementation object will be deleted.
|
1461
|
+
|
1462
|
+
Therefore, if you have some complex matcher that you want to use again and
|
1463
|
+
again, there is no need to build it everytime. Just assign it to a matcher
|
1464
|
+
variable and use that variable repeatedly! For example,
|
1465
|
+
|
1466
|
+
```cpp
|
1467
|
+
using ::testing::AllOf;
|
1468
|
+
using ::testing::Gt;
|
1469
|
+
using ::testing::Le;
|
1470
|
+
using ::testing::Matcher;
|
1471
|
+
...
|
1472
|
+
Matcher<int> in_range = AllOf(Gt(5), Le(10));
|
1473
|
+
... use in_range as a matcher in multiple EXPECT_CALLs ...
|
1474
|
+
```
|
1475
|
+
|
1476
|
+
### Matchers must have no side-effects {#PureMatchers}
|
1477
|
+
|
1478
|
+
WARNING: gMock does not guarantee when or how many times a matcher will be
|
1479
|
+
invoked. Therefore, all matchers must be *purely functional*: they cannot have
|
1480
|
+
any side effects, and the match result must not depend on anything other than
|
1481
|
+
the matcher's parameters and the value being matched.
|
1482
|
+
|
1483
|
+
This requirement must be satisfied no matter how a matcher is defined (e.g., if
|
1484
|
+
it is one of the standard matchers, or a custom matcher). In particular, a
|
1485
|
+
matcher can never call a mock function, as that will affect the state of the
|
1486
|
+
mock object and gMock.
|
1487
|
+
|
1488
|
+
## Setting Expectations
|
1489
|
+
|
1490
|
+
### Knowing When to Expect {#UseOnCall}
|
1491
|
+
|
1492
|
+
<!-- GOOGLETEST_CM0018 DO NOT DELETE -->
|
1493
|
+
|
1494
|
+
**`ON_CALL`** is likely the *single most under-utilized construct* in gMock.
|
1495
|
+
|
1496
|
+
There are basically two constructs for defining the behavior of a mock object:
|
1497
|
+
`ON_CALL` and `EXPECT_CALL`. The difference? `ON_CALL` defines what happens when
|
1498
|
+
a mock method is called, but <em>doesn't imply any expectation on the method
|
1499
|
+
being called</em>. `EXPECT_CALL` not only defines the behavior, but also sets an
|
1500
|
+
expectation that <em>the method will be called with the given arguments, for the
|
1501
|
+
given number of times</em> (and *in the given order* when you specify the order
|
1502
|
+
too).
|
1503
|
+
|
1504
|
+
Since `EXPECT_CALL` does more, isn't it better than `ON_CALL`? Not really. Every
|
1505
|
+
`EXPECT_CALL` adds a constraint on the behavior of the code under test. Having
|
1506
|
+
more constraints than necessary is *baaad* - even worse than not having enough
|
1507
|
+
constraints.
|
1508
|
+
|
1509
|
+
This may be counter-intuitive. How could tests that verify more be worse than
|
1510
|
+
tests that verify less? Isn't verification the whole point of tests?
|
1511
|
+
|
1512
|
+
The answer lies in *what* a test should verify. **A good test verifies the
|
1513
|
+
contract of the code.** If a test over-specifies, it doesn't leave enough
|
1514
|
+
freedom to the implementation. As a result, changing the implementation without
|
1515
|
+
breaking the contract (e.g. refactoring and optimization), which should be
|
1516
|
+
perfectly fine to do, can break such tests. Then you have to spend time fixing
|
1517
|
+
them, only to see them broken again the next time the implementation is changed.
|
1518
|
+
|
1519
|
+
Keep in mind that one doesn't have to verify more than one property in one test.
|
1520
|
+
In fact, **it's a good style to verify only one thing in one test.** If you do
|
1521
|
+
that, a bug will likely break only one or two tests instead of dozens (which
|
1522
|
+
case would you rather debug?). If you are also in the habit of giving tests
|
1523
|
+
descriptive names that tell what they verify, you can often easily guess what's
|
1524
|
+
wrong just from the test log itself.
|
1525
|
+
|
1526
|
+
So use `ON_CALL` by default, and only use `EXPECT_CALL` when you actually intend
|
1527
|
+
to verify that the call is made. For example, you may have a bunch of `ON_CALL`s
|
1528
|
+
in your test fixture to set the common mock behavior shared by all tests in the
|
1529
|
+
same group, and write (scarcely) different `EXPECT_CALL`s in different `TEST_F`s
|
1530
|
+
to verify different aspects of the code's behavior. Compared with the style
|
1531
|
+
where each `TEST` has many `EXPECT_CALL`s, this leads to tests that are more
|
1532
|
+
resilient to implementational changes (and thus less likely to require
|
1533
|
+
maintenance) and makes the intent of the tests more obvious (so they are easier
|
1534
|
+
to maintain when you do need to maintain them).
|
1535
|
+
|
1536
|
+
If you are bothered by the "Uninteresting mock function call" message printed
|
1537
|
+
when a mock method without an `EXPECT_CALL` is called, you may use a `NiceMock`
|
1538
|
+
instead to suppress all such messages for the mock object, or suppress the
|
1539
|
+
message for specific methods by adding `EXPECT_CALL(...).Times(AnyNumber())`. DO
|
1540
|
+
NOT suppress it by blindly adding an `EXPECT_CALL(...)`, or you'll have a test
|
1541
|
+
that's a pain to maintain.
|
1542
|
+
|
1543
|
+
### Ignoring Uninteresting Calls
|
1544
|
+
|
1545
|
+
If you are not interested in how a mock method is called, just don't say
|
1546
|
+
anything about it. In this case, if the method is ever called, gMock will
|
1547
|
+
perform its default action to allow the test program to continue. If you are not
|
1548
|
+
happy with the default action taken by gMock, you can override it using
|
1549
|
+
`DefaultValue<T>::Set()` (described [here](#DefaultValue)) or `ON_CALL()`.
|
1550
|
+
|
1551
|
+
Please note that once you expressed interest in a particular mock method (via
|
1552
|
+
`EXPECT_CALL()`), all invocations to it must match some expectation. If this
|
1553
|
+
function is called but the arguments don't match any `EXPECT_CALL()` statement,
|
1554
|
+
it will be an error.
|
1555
|
+
|
1556
|
+
### Disallowing Unexpected Calls
|
1557
|
+
|
1558
|
+
If a mock method shouldn't be called at all, explicitly say so:
|
1559
|
+
|
1560
|
+
```cpp
|
1561
|
+
using ::testing::_;
|
1562
|
+
...
|
1563
|
+
EXPECT_CALL(foo, Bar(_))
|
1564
|
+
.Times(0);
|
1565
|
+
```
|
1566
|
+
|
1567
|
+
If some calls to the method are allowed, but the rest are not, just list all the
|
1568
|
+
expected calls:
|
1569
|
+
|
1570
|
+
```cpp
|
1571
|
+
using ::testing::AnyNumber;
|
1572
|
+
using ::testing::Gt;
|
1573
|
+
...
|
1574
|
+
EXPECT_CALL(foo, Bar(5));
|
1575
|
+
EXPECT_CALL(foo, Bar(Gt(10)))
|
1576
|
+
.Times(AnyNumber());
|
1577
|
+
```
|
1578
|
+
|
1579
|
+
A call to `foo.Bar()` that doesn't match any of the `EXPECT_CALL()` statements
|
1580
|
+
will be an error.
|
1581
|
+
|
1582
|
+
### Understanding Uninteresting vs Unexpected Calls {#uninteresting-vs-unexpected}
|
1583
|
+
|
1584
|
+
*Uninteresting* calls and *unexpected* calls are different concepts in gMock.
|
1585
|
+
*Very* different.
|
1586
|
+
|
1587
|
+
A call `x.Y(...)` is **uninteresting** if there's *not even a single*
|
1588
|
+
`EXPECT_CALL(x, Y(...))` set. In other words, the test isn't interested in the
|
1589
|
+
`x.Y()` method at all, as evident in that the test doesn't care to say anything
|
1590
|
+
about it.
|
1591
|
+
|
1592
|
+
A call `x.Y(...)` is **unexpected** if there are *some* `EXPECT_CALL(x,
|
1593
|
+
Y(...))`s set, but none of them matches the call. Put another way, the test is
|
1594
|
+
interested in the `x.Y()` method (therefore it explicitly sets some
|
1595
|
+
`EXPECT_CALL` to verify how it's called); however, the verification fails as the
|
1596
|
+
test doesn't expect this particular call to happen.
|
1597
|
+
|
1598
|
+
**An unexpected call is always an error,** as the code under test doesn't behave
|
1599
|
+
the way the test expects it to behave.
|
1600
|
+
|
1601
|
+
**By default, an uninteresting call is not an error,** as it violates no
|
1602
|
+
constraint specified by the test. (gMock's philosophy is that saying nothing
|
1603
|
+
means there is no constraint.) However, it leads to a warning, as it *might*
|
1604
|
+
indicate a problem (e.g. the test author might have forgotten to specify a
|
1605
|
+
constraint).
|
1606
|
+
|
1607
|
+
In gMock, `NiceMock` and `StrictMock` can be used to make a mock class "nice" or
|
1608
|
+
"strict". How does this affect uninteresting calls and unexpected calls?
|
1609
|
+
|
1610
|
+
A **nice mock** suppresses uninteresting call *warnings*. It is less chatty than
|
1611
|
+
the default mock, but otherwise is the same. If a test fails with a default
|
1612
|
+
mock, it will also fail using a nice mock instead. And vice versa. Don't expect
|
1613
|
+
making a mock nice to change the test's result.
|
1614
|
+
|
1615
|
+
A **strict mock** turns uninteresting call warnings into errors. So making a
|
1616
|
+
mock strict may change the test's result.
|
1617
|
+
|
1618
|
+
Let's look at an example:
|
1619
|
+
|
1620
|
+
```cpp
|
1621
|
+
TEST(...) {
|
1622
|
+
NiceMock<MockDomainRegistry> mock_registry;
|
1623
|
+
EXPECT_CALL(mock_registry, GetDomainOwner("google.com"))
|
1624
|
+
.WillRepeatedly(Return("Larry Page"));
|
1625
|
+
|
1626
|
+
// Use mock_registry in code under test.
|
1627
|
+
... &mock_registry ...
|
1628
|
+
}
|
1629
|
+
```
|
1630
|
+
|
1631
|
+
The sole `EXPECT_CALL` here says that all calls to `GetDomainOwner()` must have
|
1632
|
+
`"google.com"` as the argument. If `GetDomainOwner("yahoo.com")` is called, it
|
1633
|
+
will be an unexpected call, and thus an error. *Having a nice mock doesn't
|
1634
|
+
change the severity of an unexpected call.*
|
1635
|
+
|
1636
|
+
So how do we tell gMock that `GetDomainOwner()` can be called with some other
|
1637
|
+
arguments as well? The standard technique is to add a "catch all" `EXPECT_CALL`:
|
1638
|
+
|
1639
|
+
```cpp
|
1640
|
+
EXPECT_CALL(mock_registry, GetDomainOwner(_))
|
1641
|
+
.Times(AnyNumber()); // catches all other calls to this method.
|
1642
|
+
EXPECT_CALL(mock_registry, GetDomainOwner("google.com"))
|
1643
|
+
.WillRepeatedly(Return("Larry Page"));
|
1644
|
+
```
|
1645
|
+
|
1646
|
+
Remember that `_` is the wildcard matcher that matches anything. With this, if
|
1647
|
+
`GetDomainOwner("google.com")` is called, it will do what the second
|
1648
|
+
`EXPECT_CALL` says; if it is called with a different argument, it will do what
|
1649
|
+
the first `EXPECT_CALL` says.
|
1650
|
+
|
1651
|
+
Note that the order of the two `EXPECT_CALL`s is important, as a newer
|
1652
|
+
`EXPECT_CALL` takes precedence over an older one.
|
1653
|
+
|
1654
|
+
For more on uninteresting calls, nice mocks, and strict mocks, read
|
1655
|
+
["The Nice, the Strict, and the Naggy"](#NiceStrictNaggy).
|
1656
|
+
|
1657
|
+
### Ignoring Uninteresting Arguments {#ParameterlessExpectations}
|
1658
|
+
|
1659
|
+
If your test doesn't care about the parameters (it only cares about the number
|
1660
|
+
or order of calls), you can often simply omit the parameter list:
|
1661
|
+
|
1662
|
+
```cpp
|
1663
|
+
// Expect foo.Bar( ... ) twice with any arguments.
|
1664
|
+
EXPECT_CALL(foo, Bar).Times(2);
|
1665
|
+
|
1666
|
+
// Delegate to the given method whenever the factory is invoked.
|
1667
|
+
ON_CALL(foo_factory, MakeFoo)
|
1668
|
+
.WillByDefault(&BuildFooForTest);
|
1669
|
+
```
|
1670
|
+
|
1671
|
+
This functionality is only available when a method is not overloaded; to prevent
|
1672
|
+
unexpected behavior it is a compilation error to try to set an expectation on a
|
1673
|
+
method where the specific overload is ambiguous. You can work around this by
|
1674
|
+
supplying a [simpler mock interface](#SimplerInterfaces) than the mocked class
|
1675
|
+
provides.
|
1676
|
+
|
1677
|
+
This pattern is also useful when the arguments are interesting, but match logic
|
1678
|
+
is substantially complex. You can leave the argument list unspecified and use
|
1679
|
+
SaveArg actions to [save the values for later verification](#SaveArgVerify). If
|
1680
|
+
you do that, you can easily differentiate calling the method the wrong number of
|
1681
|
+
times from calling it with the wrong arguments.
|
1682
|
+
|
1683
|
+
### Expecting Ordered Calls {#OrderedCalls}
|
1684
|
+
|
1685
|
+
Although an `EXPECT_CALL()` statement defined later takes precedence when gMock
|
1686
|
+
tries to match a function call with an expectation, by default calls don't have
|
1687
|
+
to happen in the order `EXPECT_CALL()` statements are written. For example, if
|
1688
|
+
the arguments match the matchers in the second `EXPECT_CALL()`, but not those in
|
1689
|
+
the first and third, then the second expectation will be used.
|
1690
|
+
|
1691
|
+
If you would rather have all calls occur in the order of the expectations, put
|
1692
|
+
the `EXPECT_CALL()` statements in a block where you define a variable of type
|
1693
|
+
`InSequence`:
|
1694
|
+
|
1695
|
+
```cpp
|
1696
|
+
using ::testing::_;
|
1697
|
+
using ::testing::InSequence;
|
1698
|
+
|
1699
|
+
{
|
1700
|
+
InSequence s;
|
1701
|
+
|
1702
|
+
EXPECT_CALL(foo, DoThis(5));
|
1703
|
+
EXPECT_CALL(bar, DoThat(_))
|
1704
|
+
.Times(2);
|
1705
|
+
EXPECT_CALL(foo, DoThis(6));
|
1706
|
+
}
|
1707
|
+
```
|
1708
|
+
|
1709
|
+
In this example, we expect a call to `foo.DoThis(5)`, followed by two calls to
|
1710
|
+
`bar.DoThat()` where the argument can be anything, which are in turn followed by
|
1711
|
+
a call to `foo.DoThis(6)`. If a call occurred out-of-order, gMock will report an
|
1712
|
+
error.
|
1713
|
+
|
1714
|
+
### Expecting Partially Ordered Calls {#PartialOrder}
|
1715
|
+
|
1716
|
+
Sometimes requiring everything to occur in a predetermined order can lead to
|
1717
|
+
brittle tests. For example, we may care about `A` occurring before both `B` and
|
1718
|
+
`C`, but aren't interested in the relative order of `B` and `C`. In this case,
|
1719
|
+
the test should reflect our real intent, instead of being overly constraining.
|
1720
|
+
|
1721
|
+
gMock allows you to impose an arbitrary DAG (directed acyclic graph) on the
|
1722
|
+
calls. One way to express the DAG is to use the
|
1723
|
+
[After](cheat_sheet.md#AfterClause) clause of `EXPECT_CALL`.
|
1724
|
+
|
1725
|
+
Another way is via the `InSequence()` clause (not the same as the `InSequence`
|
1726
|
+
class), which we borrowed from jMock 2. It's less flexible than `After()`, but
|
1727
|
+
more convenient when you have long chains of sequential calls, as it doesn't
|
1728
|
+
require you to come up with different names for the expectations in the chains.
|
1729
|
+
Here's how it works:
|
1730
|
+
|
1731
|
+
If we view `EXPECT_CALL()` statements as nodes in a graph, and add an edge from
|
1732
|
+
node A to node B wherever A must occur before B, we can get a DAG. We use the
|
1733
|
+
term "sequence" to mean a directed path in this DAG. Now, if we decompose the
|
1734
|
+
DAG into sequences, we just need to know which sequences each `EXPECT_CALL()`
|
1735
|
+
belongs to in order to be able to reconstruct the original DAG.
|
1736
|
+
|
1737
|
+
So, to specify the partial order on the expectations we need to do two things:
|
1738
|
+
first to define some `Sequence` objects, and then for each `EXPECT_CALL()` say
|
1739
|
+
which `Sequence` objects it is part of.
|
1740
|
+
|
1741
|
+
Expectations in the same sequence must occur in the order they are written. For
|
1742
|
+
example,
|
1743
|
+
|
1744
|
+
```cpp
|
1745
|
+
using ::testing::Sequence;
|
1746
|
+
...
|
1747
|
+
Sequence s1, s2;
|
1748
|
+
|
1749
|
+
EXPECT_CALL(foo, A())
|
1750
|
+
.InSequence(s1, s2);
|
1751
|
+
EXPECT_CALL(bar, B())
|
1752
|
+
.InSequence(s1);
|
1753
|
+
EXPECT_CALL(bar, C())
|
1754
|
+
.InSequence(s2);
|
1755
|
+
EXPECT_CALL(foo, D())
|
1756
|
+
.InSequence(s2);
|
1757
|
+
```
|
1758
|
+
|
1759
|
+
specifies the following DAG (where `s1` is `A -> B`, and `s2` is `A -> C -> D`):
|
1760
|
+
|
1761
|
+
```text
|
1762
|
+
+---> B
|
1763
|
+
|
|
1764
|
+
A ---|
|
1765
|
+
|
|
1766
|
+
+---> C ---> D
|
1767
|
+
```
|
1768
|
+
|
1769
|
+
This means that A must occur before B and C, and C must occur before D. There's
|
1770
|
+
no restriction about the order other than these.
|
1771
|
+
|
1772
|
+
### Controlling When an Expectation Retires
|
1773
|
+
|
1774
|
+
When a mock method is called, gMock only considers expectations that are still
|
1775
|
+
active. An expectation is active when created, and becomes inactive (aka
|
1776
|
+
*retires*) when a call that has to occur later has occurred. For example, in
|
1777
|
+
|
1778
|
+
```cpp
|
1779
|
+
using ::testing::_;
|
1780
|
+
using ::testing::Sequence;
|
1781
|
+
...
|
1782
|
+
Sequence s1, s2;
|
1783
|
+
|
1784
|
+
EXPECT_CALL(log, Log(WARNING, _, "File too large.")) // #1
|
1785
|
+
.Times(AnyNumber())
|
1786
|
+
.InSequence(s1, s2);
|
1787
|
+
EXPECT_CALL(log, Log(WARNING, _, "Data set is empty.")) // #2
|
1788
|
+
.InSequence(s1);
|
1789
|
+
EXPECT_CALL(log, Log(WARNING, _, "User not found.")) // #3
|
1790
|
+
.InSequence(s2);
|
1791
|
+
```
|
1792
|
+
|
1793
|
+
as soon as either #2 or #3 is matched, #1 will retire. If a warning `"File too
|
1794
|
+
large."` is logged after this, it will be an error.
|
1795
|
+
|
1796
|
+
Note that an expectation doesn't retire automatically when it's saturated. For
|
1797
|
+
example,
|
1798
|
+
|
1799
|
+
```cpp
|
1800
|
+
using ::testing::_;
|
1801
|
+
...
|
1802
|
+
EXPECT_CALL(log, Log(WARNING, _, _)); // #1
|
1803
|
+
EXPECT_CALL(log, Log(WARNING, _, "File too large.")); // #2
|
1804
|
+
```
|
1805
|
+
|
1806
|
+
says that there will be exactly one warning with the message `"File too
|
1807
|
+
large."`. If the second warning contains this message too, #2 will match again
|
1808
|
+
and result in an upper-bound-violated error.
|
1809
|
+
|
1810
|
+
If this is not what you want, you can ask an expectation to retire as soon as it
|
1811
|
+
becomes saturated:
|
1812
|
+
|
1813
|
+
```cpp
|
1814
|
+
using ::testing::_;
|
1815
|
+
...
|
1816
|
+
EXPECT_CALL(log, Log(WARNING, _, _)); // #1
|
1817
|
+
EXPECT_CALL(log, Log(WARNING, _, "File too large.")) // #2
|
1818
|
+
.RetiresOnSaturation();
|
1819
|
+
```
|
1820
|
+
|
1821
|
+
Here #2 can be used only once, so if you have two warnings with the message
|
1822
|
+
`"File too large."`, the first will match #2 and the second will match #1 -
|
1823
|
+
there will be no error.
|
1824
|
+
|
1825
|
+
## Using Actions
|
1826
|
+
|
1827
|
+
### Returning References from Mock Methods
|
1828
|
+
|
1829
|
+
If a mock function's return type is a reference, you need to use `ReturnRef()`
|
1830
|
+
instead of `Return()` to return a result:
|
1831
|
+
|
1832
|
+
```cpp
|
1833
|
+
using ::testing::ReturnRef;
|
1834
|
+
|
1835
|
+
class MockFoo : public Foo {
|
1836
|
+
public:
|
1837
|
+
MOCK_METHOD(Bar&, GetBar, (), (override));
|
1838
|
+
};
|
1839
|
+
...
|
1840
|
+
MockFoo foo;
|
1841
|
+
Bar bar;
|
1842
|
+
EXPECT_CALL(foo, GetBar())
|
1843
|
+
.WillOnce(ReturnRef(bar));
|
1844
|
+
...
|
1845
|
+
```
|
1846
|
+
|
1847
|
+
### Returning Live Values from Mock Methods
|
1848
|
+
|
1849
|
+
The `Return(x)` action saves a copy of `x` when the action is created, and
|
1850
|
+
always returns the same value whenever it's executed. Sometimes you may want to
|
1851
|
+
instead return the *live* value of `x` (i.e. its value at the time when the
|
1852
|
+
action is *executed*.). Use either `ReturnRef()` or `ReturnPointee()` for this
|
1853
|
+
purpose.
|
1854
|
+
|
1855
|
+
If the mock function's return type is a reference, you can do it using
|
1856
|
+
`ReturnRef(x)`, as shown in the previous recipe ("Returning References from Mock
|
1857
|
+
Methods"). However, gMock doesn't let you use `ReturnRef()` in a mock function
|
1858
|
+
whose return type is not a reference, as doing that usually indicates a user
|
1859
|
+
error. So, what shall you do?
|
1860
|
+
|
1861
|
+
Though you may be tempted, DO NOT use `std::ref()`:
|
1862
|
+
|
1863
|
+
```cpp
|
1864
|
+
using testing::Return;
|
1865
|
+
|
1866
|
+
class MockFoo : public Foo {
|
1867
|
+
public:
|
1868
|
+
MOCK_METHOD(int, GetValue, (), (override));
|
1869
|
+
};
|
1870
|
+
...
|
1871
|
+
int x = 0;
|
1872
|
+
MockFoo foo;
|
1873
|
+
EXPECT_CALL(foo, GetValue())
|
1874
|
+
.WillRepeatedly(Return(std::ref(x))); // Wrong!
|
1875
|
+
x = 42;
|
1876
|
+
EXPECT_EQ(42, foo.GetValue());
|
1877
|
+
```
|
1878
|
+
|
1879
|
+
Unfortunately, it doesn't work here. The above code will fail with error:
|
1880
|
+
|
1881
|
+
```text
|
1882
|
+
Value of: foo.GetValue()
|
1883
|
+
Actual: 0
|
1884
|
+
Expected: 42
|
1885
|
+
```
|
1886
|
+
|
1887
|
+
The reason is that `Return(*value*)` converts `value` to the actual return type
|
1888
|
+
of the mock function at the time when the action is *created*, not when it is
|
1889
|
+
*executed*. (This behavior was chosen for the action to be safe when `value` is
|
1890
|
+
a proxy object that references some temporary objects.) As a result,
|
1891
|
+
`std::ref(x)` is converted to an `int` value (instead of a `const int&`) when
|
1892
|
+
the expectation is set, and `Return(std::ref(x))` will always return 0.
|
1893
|
+
|
1894
|
+
`ReturnPointee(pointer)` was provided to solve this problem specifically. It
|
1895
|
+
returns the value pointed to by `pointer` at the time the action is *executed*:
|
1896
|
+
|
1897
|
+
```cpp
|
1898
|
+
using testing::ReturnPointee;
|
1899
|
+
...
|
1900
|
+
int x = 0;
|
1901
|
+
MockFoo foo;
|
1902
|
+
EXPECT_CALL(foo, GetValue())
|
1903
|
+
.WillRepeatedly(ReturnPointee(&x)); // Note the & here.
|
1904
|
+
x = 42;
|
1905
|
+
EXPECT_EQ(42, foo.GetValue()); // This will succeed now.
|
1906
|
+
```
|
1907
|
+
|
1908
|
+
### Combining Actions
|
1909
|
+
|
1910
|
+
Want to do more than one thing when a function is called? That's fine. `DoAll()`
|
1911
|
+
allow you to do sequence of actions every time. Only the return value of the
|
1912
|
+
last action in the sequence will be used.
|
1913
|
+
|
1914
|
+
```cpp
|
1915
|
+
using ::testing::_;
|
1916
|
+
using ::testing::DoAll;
|
1917
|
+
|
1918
|
+
class MockFoo : public Foo {
|
1919
|
+
public:
|
1920
|
+
MOCK_METHOD(bool, Bar, (int n), (override));
|
1921
|
+
};
|
1922
|
+
...
|
1923
|
+
EXPECT_CALL(foo, Bar(_))
|
1924
|
+
.WillOnce(DoAll(action_1,
|
1925
|
+
action_2,
|
1926
|
+
...
|
1927
|
+
action_n));
|
1928
|
+
```
|
1929
|
+
|
1930
|
+
### Verifying Complex Arguments {#SaveArgVerify}
|
1931
|
+
|
1932
|
+
If you want to verify that a method is called with a particular argument but the
|
1933
|
+
match criteria is complex, it can be difficult to distinguish between
|
1934
|
+
cardinality failures (calling the method the wrong number of times) and argument
|
1935
|
+
match failures. Similarly, if you are matching multiple parameters, it may not
|
1936
|
+
be easy to distinguishing which argument failed to match. For example:
|
1937
|
+
|
1938
|
+
```cpp
|
1939
|
+
// Not ideal: this could fail because of a problem with arg1 or arg2, or maybe
|
1940
|
+
// just the method wasn't called.
|
1941
|
+
EXPECT_CALL(foo, SendValues(_, ElementsAre(1, 4, 4, 7), EqualsProto( ... )));
|
1942
|
+
```
|
1943
|
+
|
1944
|
+
You can instead save the arguments and test them individually:
|
1945
|
+
|
1946
|
+
```cpp
|
1947
|
+
EXPECT_CALL(foo, SendValues)
|
1948
|
+
.WillOnce(DoAll(SaveArg<1>(&actual_array), SaveArg<2>(&actual_proto)));
|
1949
|
+
... run the test
|
1950
|
+
EXPECT_THAT(actual_array, ElementsAre(1, 4, 4, 7));
|
1951
|
+
EXPECT_THAT(actual_proto, EqualsProto( ... ));
|
1952
|
+
```
|
1953
|
+
|
1954
|
+
### Mocking Side Effects {#MockingSideEffects}
|
1955
|
+
|
1956
|
+
Sometimes a method exhibits its effect not via returning a value but via side
|
1957
|
+
effects. For example, it may change some global state or modify an output
|
1958
|
+
argument. To mock side effects, in general you can define your own action by
|
1959
|
+
implementing `::testing::ActionInterface`.
|
1960
|
+
|
1961
|
+
If all you need to do is to change an output argument, the built-in
|
1962
|
+
`SetArgPointee()` action is convenient:
|
1963
|
+
|
1964
|
+
```cpp
|
1965
|
+
using ::testing::_;
|
1966
|
+
using ::testing::SetArgPointee;
|
1967
|
+
|
1968
|
+
class MockMutator : public Mutator {
|
1969
|
+
public:
|
1970
|
+
MOCK_METHOD(void, Mutate, (bool mutate, int* value), (override));
|
1971
|
+
...
|
1972
|
+
}
|
1973
|
+
...
|
1974
|
+
MockMutator mutator;
|
1975
|
+
EXPECT_CALL(mutator, Mutate(true, _))
|
1976
|
+
.WillOnce(SetArgPointee<1>(5));
|
1977
|
+
```
|
1978
|
+
|
1979
|
+
In this example, when `mutator.Mutate()` is called, we will assign 5 to the
|
1980
|
+
`int` variable pointed to by argument #1 (0-based).
|
1981
|
+
|
1982
|
+
`SetArgPointee()` conveniently makes an internal copy of the value you pass to
|
1983
|
+
it, removing the need to keep the value in scope and alive. The implication
|
1984
|
+
however is that the value must have a copy constructor and assignment operator.
|
1985
|
+
|
1986
|
+
If the mock method also needs to return a value as well, you can chain
|
1987
|
+
`SetArgPointee()` with `Return()` using `DoAll()`, remembering to put the
|
1988
|
+
`Return()` statement last:
|
1989
|
+
|
1990
|
+
```cpp
|
1991
|
+
using ::testing::_;
|
1992
|
+
using ::testing::Return;
|
1993
|
+
using ::testing::SetArgPointee;
|
1994
|
+
|
1995
|
+
class MockMutator : public Mutator {
|
1996
|
+
public:
|
1997
|
+
...
|
1998
|
+
MOCK_METHOD(bool, MutateInt, (int* value), (override));
|
1999
|
+
}
|
2000
|
+
...
|
2001
|
+
MockMutator mutator;
|
2002
|
+
EXPECT_CALL(mutator, MutateInt(_))
|
2003
|
+
.WillOnce(DoAll(SetArgPointee<0>(5),
|
2004
|
+
Return(true)));
|
2005
|
+
```
|
2006
|
+
|
2007
|
+
Note, however, that if you use the `ReturnOKWith()` method, it will override the
|
2008
|
+
values provided by `SetArgPointee()` in the response parameters of your function
|
2009
|
+
call.
|
2010
|
+
|
2011
|
+
If the output argument is an array, use the `SetArrayArgument<N>(first, last)`
|
2012
|
+
action instead. It copies the elements in source range `[first, last)` to the
|
2013
|
+
array pointed to by the `N`-th (0-based) argument:
|
2014
|
+
|
2015
|
+
```cpp
|
2016
|
+
using ::testing::NotNull;
|
2017
|
+
using ::testing::SetArrayArgument;
|
2018
|
+
|
2019
|
+
class MockArrayMutator : public ArrayMutator {
|
2020
|
+
public:
|
2021
|
+
MOCK_METHOD(void, Mutate, (int* values, int num_values), (override));
|
2022
|
+
...
|
2023
|
+
}
|
2024
|
+
...
|
2025
|
+
MockArrayMutator mutator;
|
2026
|
+
int values[5] = {1, 2, 3, 4, 5};
|
2027
|
+
EXPECT_CALL(mutator, Mutate(NotNull(), 5))
|
2028
|
+
.WillOnce(SetArrayArgument<0>(values, values + 5));
|
2029
|
+
```
|
2030
|
+
|
2031
|
+
This also works when the argument is an output iterator:
|
2032
|
+
|
2033
|
+
```cpp
|
2034
|
+
using ::testing::_;
|
2035
|
+
using ::testing::SetArrayArgument;
|
2036
|
+
|
2037
|
+
class MockRolodex : public Rolodex {
|
2038
|
+
public:
|
2039
|
+
MOCK_METHOD(void, GetNames, (std::back_insert_iterator<vector<string>>),
|
2040
|
+
(override));
|
2041
|
+
...
|
2042
|
+
}
|
2043
|
+
...
|
2044
|
+
MockRolodex rolodex;
|
2045
|
+
vector<string> names;
|
2046
|
+
names.push_back("George");
|
2047
|
+
names.push_back("John");
|
2048
|
+
names.push_back("Thomas");
|
2049
|
+
EXPECT_CALL(rolodex, GetNames(_))
|
2050
|
+
.WillOnce(SetArrayArgument<0>(names.begin(), names.end()));
|
2051
|
+
```
|
2052
|
+
|
2053
|
+
### Changing a Mock Object's Behavior Based on the State
|
2054
|
+
|
2055
|
+
If you expect a call to change the behavior of a mock object, you can use
|
2056
|
+
`::testing::InSequence` to specify different behaviors before and after the
|
2057
|
+
call:
|
2058
|
+
|
2059
|
+
```cpp
|
2060
|
+
using ::testing::InSequence;
|
2061
|
+
using ::testing::Return;
|
2062
|
+
|
2063
|
+
...
|
2064
|
+
{
|
2065
|
+
InSequence seq;
|
2066
|
+
EXPECT_CALL(my_mock, IsDirty())
|
2067
|
+
.WillRepeatedly(Return(true));
|
2068
|
+
EXPECT_CALL(my_mock, Flush());
|
2069
|
+
EXPECT_CALL(my_mock, IsDirty())
|
2070
|
+
.WillRepeatedly(Return(false));
|
2071
|
+
}
|
2072
|
+
my_mock.FlushIfDirty();
|
2073
|
+
```
|
2074
|
+
|
2075
|
+
This makes `my_mock.IsDirty()` return `true` before `my_mock.Flush()` is called
|
2076
|
+
and return `false` afterwards.
|
2077
|
+
|
2078
|
+
If the behavior change is more complex, you can store the effects in a variable
|
2079
|
+
and make a mock method get its return value from that variable:
|
2080
|
+
|
2081
|
+
```cpp
|
2082
|
+
using ::testing::_;
|
2083
|
+
using ::testing::SaveArg;
|
2084
|
+
using ::testing::Return;
|
2085
|
+
|
2086
|
+
ACTION_P(ReturnPointee, p) { return *p; }
|
2087
|
+
...
|
2088
|
+
int previous_value = 0;
|
2089
|
+
EXPECT_CALL(my_mock, GetPrevValue)
|
2090
|
+
.WillRepeatedly(ReturnPointee(&previous_value));
|
2091
|
+
EXPECT_CALL(my_mock, UpdateValue)
|
2092
|
+
.WillRepeatedly(SaveArg<0>(&previous_value));
|
2093
|
+
my_mock.DoSomethingToUpdateValue();
|
2094
|
+
```
|
2095
|
+
|
2096
|
+
Here `my_mock.GetPrevValue()` will always return the argument of the last
|
2097
|
+
`UpdateValue()` call.
|
2098
|
+
|
2099
|
+
### Setting the Default Value for a Return Type {#DefaultValue}
|
2100
|
+
|
2101
|
+
If a mock method's return type is a built-in C++ type or pointer, by default it
|
2102
|
+
will return 0 when invoked. Also, in C++ 11 and above, a mock method whose
|
2103
|
+
return type has a default constructor will return a default-constructed value by
|
2104
|
+
default. You only need to specify an action if this default value doesn't work
|
2105
|
+
for you.
|
2106
|
+
|
2107
|
+
Sometimes, you may want to change this default value, or you may want to specify
|
2108
|
+
a default value for types gMock doesn't know about. You can do this using the
|
2109
|
+
`::testing::DefaultValue` class template:
|
2110
|
+
|
2111
|
+
```cpp
|
2112
|
+
using ::testing::DefaultValue;
|
2113
|
+
|
2114
|
+
class MockFoo : public Foo {
|
2115
|
+
public:
|
2116
|
+
MOCK_METHOD(Bar, CalculateBar, (), (override));
|
2117
|
+
};
|
2118
|
+
|
2119
|
+
|
2120
|
+
...
|
2121
|
+
Bar default_bar;
|
2122
|
+
// Sets the default return value for type Bar.
|
2123
|
+
DefaultValue<Bar>::Set(default_bar);
|
2124
|
+
|
2125
|
+
MockFoo foo;
|
2126
|
+
|
2127
|
+
// We don't need to specify an action here, as the default
|
2128
|
+
// return value works for us.
|
2129
|
+
EXPECT_CALL(foo, CalculateBar());
|
2130
|
+
|
2131
|
+
foo.CalculateBar(); // This should return default_bar.
|
2132
|
+
|
2133
|
+
// Unsets the default return value.
|
2134
|
+
DefaultValue<Bar>::Clear();
|
2135
|
+
```
|
2136
|
+
|
2137
|
+
Please note that changing the default value for a type can make your tests hard
|
2138
|
+
to understand. We recommend you to use this feature judiciously. For example,
|
2139
|
+
you may want to make sure the `Set()` and `Clear()` calls are right next to the
|
2140
|
+
code that uses your mock.
|
2141
|
+
|
2142
|
+
### Setting the Default Actions for a Mock Method
|
2143
|
+
|
2144
|
+
You've learned how to change the default value of a given type. However, this
|
2145
|
+
may be too coarse for your purpose: perhaps you have two mock methods with the
|
2146
|
+
same return type and you want them to have different behaviors. The `ON_CALL()`
|
2147
|
+
macro allows you to customize your mock's behavior at the method level:
|
2148
|
+
|
2149
|
+
```cpp
|
2150
|
+
using ::testing::_;
|
2151
|
+
using ::testing::AnyNumber;
|
2152
|
+
using ::testing::Gt;
|
2153
|
+
using ::testing::Return;
|
2154
|
+
...
|
2155
|
+
ON_CALL(foo, Sign(_))
|
2156
|
+
.WillByDefault(Return(-1));
|
2157
|
+
ON_CALL(foo, Sign(0))
|
2158
|
+
.WillByDefault(Return(0));
|
2159
|
+
ON_CALL(foo, Sign(Gt(0)))
|
2160
|
+
.WillByDefault(Return(1));
|
2161
|
+
|
2162
|
+
EXPECT_CALL(foo, Sign(_))
|
2163
|
+
.Times(AnyNumber());
|
2164
|
+
|
2165
|
+
foo.Sign(5); // This should return 1.
|
2166
|
+
foo.Sign(-9); // This should return -1.
|
2167
|
+
foo.Sign(0); // This should return 0.
|
2168
|
+
```
|
2169
|
+
|
2170
|
+
As you may have guessed, when there are more than one `ON_CALL()` statements,
|
2171
|
+
the newer ones in the order take precedence over the older ones. In other words,
|
2172
|
+
the **last** one that matches the function arguments will be used. This matching
|
2173
|
+
order allows you to set up the common behavior in a mock object's constructor or
|
2174
|
+
the test fixture's set-up phase and specialize the mock's behavior later.
|
2175
|
+
|
2176
|
+
Note that both `ON_CALL` and `EXPECT_CALL` have the same "later statements take
|
2177
|
+
precedence" rule, but they don't interact. That is, `EXPECT_CALL`s have their
|
2178
|
+
own precedence order distinct from the `ON_CALL` precedence order.
|
2179
|
+
|
2180
|
+
### Using Functions/Methods/Functors/Lambdas as Actions {#FunctionsAsActions}
|
2181
|
+
|
2182
|
+
If the built-in actions don't suit you, you can use an existing callable
|
2183
|
+
(function, `std::function`, method, functor, lambda) as an action.
|
2184
|
+
|
2185
|
+
<!-- GOOGLETEST_CM0024 DO NOT DELETE -->
|
2186
|
+
|
2187
|
+
```cpp
|
2188
|
+
using ::testing::_; using ::testing::Invoke;
|
2189
|
+
|
2190
|
+
class MockFoo : public Foo {
|
2191
|
+
public:
|
2192
|
+
MOCK_METHOD(int, Sum, (int x, int y), (override));
|
2193
|
+
MOCK_METHOD(bool, ComplexJob, (int x), (override));
|
2194
|
+
};
|
2195
|
+
|
2196
|
+
int CalculateSum(int x, int y) { return x + y; }
|
2197
|
+
int Sum3(int x, int y, int z) { return x + y + z; }
|
2198
|
+
|
2199
|
+
class Helper {
|
2200
|
+
public:
|
2201
|
+
bool ComplexJob(int x);
|
2202
|
+
};
|
2203
|
+
|
2204
|
+
...
|
2205
|
+
MockFoo foo;
|
2206
|
+
Helper helper;
|
2207
|
+
EXPECT_CALL(foo, Sum(_, _))
|
2208
|
+
.WillOnce(&CalculateSum)
|
2209
|
+
.WillRepeatedly(Invoke(NewPermanentCallback(Sum3, 1)));
|
2210
|
+
EXPECT_CALL(foo, ComplexJob(_))
|
2211
|
+
.WillOnce(Invoke(&helper, &Helper::ComplexJob))
|
2212
|
+
.WillOnce([] { return true; })
|
2213
|
+
.WillRepeatedly([](int x) { return x > 0; });
|
2214
|
+
|
2215
|
+
foo.Sum(5, 6); // Invokes CalculateSum(5, 6).
|
2216
|
+
foo.Sum(2, 3); // Invokes Sum3(1, 2, 3).
|
2217
|
+
foo.ComplexJob(10); // Invokes helper.ComplexJob(10).
|
2218
|
+
foo.ComplexJob(-1); // Invokes the inline lambda.
|
2219
|
+
```
|
2220
|
+
|
2221
|
+
The only requirement is that the type of the function, etc must be *compatible*
|
2222
|
+
with the signature of the mock function, meaning that the latter's arguments (if
|
2223
|
+
it takes any) can be implicitly converted to the corresponding arguments of the
|
2224
|
+
former, and the former's return type can be implicitly converted to that of the
|
2225
|
+
latter. So, you can invoke something whose type is *not* exactly the same as the
|
2226
|
+
mock function, as long as it's safe to do so - nice, huh?
|
2227
|
+
|
2228
|
+
**`Note:`{.escaped}**
|
2229
|
+
|
2230
|
+
* The action takes ownership of the callback and will delete it when the
|
2231
|
+
action itself is destructed.
|
2232
|
+
* If the type of a callback is derived from a base callback type `C`, you need
|
2233
|
+
to implicitly cast it to `C` to resolve the overloading, e.g.
|
2234
|
+
|
2235
|
+
```cpp
|
2236
|
+
using ::testing::Invoke;
|
2237
|
+
...
|
2238
|
+
ResultCallback<bool>* is_ok = ...;
|
2239
|
+
... Invoke(is_ok) ...; // This works.
|
2240
|
+
|
2241
|
+
BlockingClosure* done = new BlockingClosure;
|
2242
|
+
... Invoke(implicit_cast<Closure*>(done)) ...; // The cast is necessary.
|
2243
|
+
```
|
2244
|
+
|
2245
|
+
### Using Functions with Extra Info as Actions
|
2246
|
+
|
2247
|
+
The function or functor you call using `Invoke()` must have the same number of
|
2248
|
+
arguments as the mock function you use it for. Sometimes you may have a function
|
2249
|
+
that takes more arguments, and you are willing to pass in the extra arguments
|
2250
|
+
yourself to fill the gap. You can do this in gMock using callbacks with
|
2251
|
+
pre-bound arguments. Here's an example:
|
2252
|
+
|
2253
|
+
```cpp
|
2254
|
+
using ::testing::Invoke;
|
2255
|
+
|
2256
|
+
class MockFoo : public Foo {
|
2257
|
+
public:
|
2258
|
+
MOCK_METHOD(char, DoThis, (int n), (override));
|
2259
|
+
};
|
2260
|
+
|
2261
|
+
char SignOfSum(int x, int y) {
|
2262
|
+
const int sum = x + y;
|
2263
|
+
return (sum > 0) ? '+' : (sum < 0) ? '-' : '0';
|
2264
|
+
}
|
2265
|
+
|
2266
|
+
TEST_F(FooTest, Test) {
|
2267
|
+
MockFoo foo;
|
2268
|
+
|
2269
|
+
EXPECT_CALL(foo, DoThis(2))
|
2270
|
+
.WillOnce(Invoke(NewPermanentCallback(SignOfSum, 5)));
|
2271
|
+
EXPECT_EQ('+', foo.DoThis(2)); // Invokes SignOfSum(5, 2).
|
2272
|
+
}
|
2273
|
+
```
|
2274
|
+
|
2275
|
+
### Invoking a Function/Method/Functor/Lambda/Callback Without Arguments
|
2276
|
+
|
2277
|
+
`Invoke()` passes the mock function's arguments to the function, etc being
|
2278
|
+
invoked such that the callee has the full context of the call to work with. If
|
2279
|
+
the invoked function is not interested in some or all of the arguments, it can
|
2280
|
+
simply ignore them.
|
2281
|
+
|
2282
|
+
Yet, a common pattern is that a test author wants to invoke a function without
|
2283
|
+
the arguments of the mock function. She could do that using a wrapper function
|
2284
|
+
that throws away the arguments before invoking an underlining nullary function.
|
2285
|
+
Needless to say, this can be tedious and obscures the intent of the test.
|
2286
|
+
|
2287
|
+
There are two solutions to this problem. First, you can pass any callable of
|
2288
|
+
zero args as an action. Alternatively, use `InvokeWithoutArgs()`, which is like
|
2289
|
+
`Invoke()` except that it doesn't pass the mock function's arguments to the
|
2290
|
+
callee. Here's an example of each:
|
2291
|
+
|
2292
|
+
```cpp
|
2293
|
+
using ::testing::_;
|
2294
|
+
using ::testing::InvokeWithoutArgs;
|
2295
|
+
|
2296
|
+
class MockFoo : public Foo {
|
2297
|
+
public:
|
2298
|
+
MOCK_METHOD(bool, ComplexJob, (int n), (override));
|
2299
|
+
};
|
2300
|
+
|
2301
|
+
bool Job1() { ... }
|
2302
|
+
bool Job2(int n, char c) { ... }
|
2303
|
+
|
2304
|
+
...
|
2305
|
+
MockFoo foo;
|
2306
|
+
EXPECT_CALL(foo, ComplexJob(_))
|
2307
|
+
.WillOnce([] { Job1(); });
|
2308
|
+
.WillOnce(InvokeWithoutArgs(NewPermanentCallback(Job2, 5, 'a')));
|
2309
|
+
|
2310
|
+
foo.ComplexJob(10); // Invokes Job1().
|
2311
|
+
foo.ComplexJob(20); // Invokes Job2(5, 'a').
|
2312
|
+
```
|
2313
|
+
|
2314
|
+
**`Note:`{.escaped}**
|
2315
|
+
|
2316
|
+
* The action takes ownership of the callback and will delete it when the
|
2317
|
+
action itself is destructed.
|
2318
|
+
* If the type of a callback is derived from a base callback type `C`, you need
|
2319
|
+
to implicitly cast it to `C` to resolve the overloading, e.g.
|
2320
|
+
|
2321
|
+
```cpp
|
2322
|
+
using ::testing::InvokeWithoutArgs;
|
2323
|
+
...
|
2324
|
+
ResultCallback<bool>* is_ok = ...;
|
2325
|
+
... InvokeWithoutArgs(is_ok) ...; // This works.
|
2326
|
+
|
2327
|
+
BlockingClosure* done = ...;
|
2328
|
+
... InvokeWithoutArgs(implicit_cast<Closure*>(done)) ...;
|
2329
|
+
// The cast is necessary.
|
2330
|
+
```
|
2331
|
+
|
2332
|
+
### Invoking an Argument of the Mock Function
|
2333
|
+
|
2334
|
+
Sometimes a mock function will receive a function pointer, a functor (in other
|
2335
|
+
words, a "callable") as an argument, e.g.
|
2336
|
+
|
2337
|
+
```cpp
|
2338
|
+
class MockFoo : public Foo {
|
2339
|
+
public:
|
2340
|
+
MOCK_METHOD(bool, DoThis, (int n, (ResultCallback1<bool, int>* callback)),
|
2341
|
+
(override));
|
2342
|
+
};
|
2343
|
+
```
|
2344
|
+
|
2345
|
+
and you may want to invoke this callable argument:
|
2346
|
+
|
2347
|
+
```cpp
|
2348
|
+
using ::testing::_;
|
2349
|
+
...
|
2350
|
+
MockFoo foo;
|
2351
|
+
EXPECT_CALL(foo, DoThis(_, _))
|
2352
|
+
.WillOnce(...);
|
2353
|
+
// Will execute callback->Run(5), where callback is the
|
2354
|
+
// second argument DoThis() receives.
|
2355
|
+
```
|
2356
|
+
|
2357
|
+
NOTE: The section below is legacy documentation from before C++ had lambdas:
|
2358
|
+
|
2359
|
+
Arghh, you need to refer to a mock function argument but C++ has no lambda
|
2360
|
+
(yet), so you have to define your own action. :-( Or do you really?
|
2361
|
+
|
2362
|
+
Well, gMock has an action to solve *exactly* this problem:
|
2363
|
+
|
2364
|
+
```cpp
|
2365
|
+
InvokeArgument<N>(arg_1, arg_2, ..., arg_m)
|
2366
|
+
```
|
2367
|
+
|
2368
|
+
will invoke the `N`-th (0-based) argument the mock function receives, with
|
2369
|
+
`arg_1`, `arg_2`, ..., and `arg_m`. No matter if the argument is a function
|
2370
|
+
pointer, a functor, or a callback. gMock handles them all.
|
2371
|
+
|
2372
|
+
With that, you could write:
|
2373
|
+
|
2374
|
+
```cpp
|
2375
|
+
using ::testing::_;
|
2376
|
+
using ::testing::InvokeArgument;
|
2377
|
+
...
|
2378
|
+
EXPECT_CALL(foo, DoThis(_, _))
|
2379
|
+
.WillOnce(InvokeArgument<1>(5));
|
2380
|
+
// Will execute callback->Run(5), where callback is the
|
2381
|
+
// second argument DoThis() receives.
|
2382
|
+
```
|
2383
|
+
|
2384
|
+
What if the callable takes an argument by reference? No problem - just wrap it
|
2385
|
+
inside `std::ref()`:
|
2386
|
+
|
2387
|
+
```cpp
|
2388
|
+
...
|
2389
|
+
MOCK_METHOD(bool, Bar,
|
2390
|
+
((ResultCallback2<bool, int, const Helper&>* callback)),
|
2391
|
+
(override));
|
2392
|
+
...
|
2393
|
+
using ::testing::_;
|
2394
|
+
using ::testing::InvokeArgument;
|
2395
|
+
...
|
2396
|
+
MockFoo foo;
|
2397
|
+
Helper helper;
|
2398
|
+
...
|
2399
|
+
EXPECT_CALL(foo, Bar(_))
|
2400
|
+
.WillOnce(InvokeArgument<0>(5, std::ref(helper)));
|
2401
|
+
// std::ref(helper) guarantees that a reference to helper, not a copy of
|
2402
|
+
// it, will be passed to the callback.
|
2403
|
+
```
|
2404
|
+
|
2405
|
+
What if the callable takes an argument by reference and we do **not** wrap the
|
2406
|
+
argument in `std::ref()`? Then `InvokeArgument()` will *make a copy* of the
|
2407
|
+
argument, and pass a *reference to the copy*, instead of a reference to the
|
2408
|
+
original value, to the callable. This is especially handy when the argument is a
|
2409
|
+
temporary value:
|
2410
|
+
|
2411
|
+
```cpp
|
2412
|
+
...
|
2413
|
+
MOCK_METHOD(bool, DoThat, (bool (*f)(const double& x, const string& s)),
|
2414
|
+
(override));
|
2415
|
+
...
|
2416
|
+
using ::testing::_;
|
2417
|
+
using ::testing::InvokeArgument;
|
2418
|
+
...
|
2419
|
+
MockFoo foo;
|
2420
|
+
...
|
2421
|
+
EXPECT_CALL(foo, DoThat(_))
|
2422
|
+
.WillOnce(InvokeArgument<0>(5.0, string("Hi")));
|
2423
|
+
// Will execute (*f)(5.0, string("Hi")), where f is the function pointer
|
2424
|
+
// DoThat() receives. Note that the values 5.0 and string("Hi") are
|
2425
|
+
// temporary and dead once the EXPECT_CALL() statement finishes. Yet
|
2426
|
+
// it's fine to perform this action later, since a copy of the values
|
2427
|
+
// are kept inside the InvokeArgument action.
|
2428
|
+
```
|
2429
|
+
|
2430
|
+
### Ignoring an Action's Result
|
2431
|
+
|
2432
|
+
Sometimes you have an action that returns *something*, but you need an action
|
2433
|
+
that returns `void` (perhaps you want to use it in a mock function that returns
|
2434
|
+
`void`, or perhaps it needs to be used in `DoAll()` and it's not the last in the
|
2435
|
+
list). `IgnoreResult()` lets you do that. For example:
|
2436
|
+
|
2437
|
+
```cpp
|
2438
|
+
using ::testing::_;
|
2439
|
+
using ::testing::DoAll;
|
2440
|
+
using ::testing::IgnoreResult;
|
2441
|
+
using ::testing::Return;
|
2442
|
+
|
2443
|
+
int Process(const MyData& data);
|
2444
|
+
string DoSomething();
|
2445
|
+
|
2446
|
+
class MockFoo : public Foo {
|
2447
|
+
public:
|
2448
|
+
MOCK_METHOD(void, Abc, (const MyData& data), (override));
|
2449
|
+
MOCK_METHOD(bool, Xyz, (), (override));
|
2450
|
+
};
|
2451
|
+
|
2452
|
+
...
|
2453
|
+
MockFoo foo;
|
2454
|
+
EXPECT_CALL(foo, Abc(_))
|
2455
|
+
// .WillOnce(Invoke(Process));
|
2456
|
+
// The above line won't compile as Process() returns int but Abc() needs
|
2457
|
+
// to return void.
|
2458
|
+
.WillOnce(IgnoreResult(Process));
|
2459
|
+
EXPECT_CALL(foo, Xyz())
|
2460
|
+
.WillOnce(DoAll(IgnoreResult(DoSomething),
|
2461
|
+
// Ignores the string DoSomething() returns.
|
2462
|
+
Return(true)));
|
2463
|
+
```
|
2464
|
+
|
2465
|
+
Note that you **cannot** use `IgnoreResult()` on an action that already returns
|
2466
|
+
`void`. Doing so will lead to ugly compiler errors.
|
2467
|
+
|
2468
|
+
### Selecting an Action's Arguments {#SelectingArgs}
|
2469
|
+
|
2470
|
+
Say you have a mock function `Foo()` that takes seven arguments, and you have a
|
2471
|
+
custom action that you want to invoke when `Foo()` is called. Trouble is, the
|
2472
|
+
custom action only wants three arguments:
|
2473
|
+
|
2474
|
+
```cpp
|
2475
|
+
using ::testing::_;
|
2476
|
+
using ::testing::Invoke;
|
2477
|
+
...
|
2478
|
+
MOCK_METHOD(bool, Foo,
|
2479
|
+
(bool visible, const string& name, int x, int y,
|
2480
|
+
(const map<pair<int, int>>), double& weight, double min_weight,
|
2481
|
+
double max_wight));
|
2482
|
+
...
|
2483
|
+
bool IsVisibleInQuadrant1(bool visible, int x, int y) {
|
2484
|
+
return visible && x >= 0 && y >= 0;
|
2485
|
+
}
|
2486
|
+
...
|
2487
|
+
EXPECT_CALL(mock, Foo)
|
2488
|
+
.WillOnce(Invoke(IsVisibleInQuadrant1)); // Uh, won't compile. :-(
|
2489
|
+
```
|
2490
|
+
|
2491
|
+
To please the compiler God, you need to define an "adaptor" that has the same
|
2492
|
+
signature as `Foo()` and calls the custom action with the right arguments:
|
2493
|
+
|
2494
|
+
```cpp
|
2495
|
+
using ::testing::_;
|
2496
|
+
using ::testing::Invoke;
|
2497
|
+
...
|
2498
|
+
bool MyIsVisibleInQuadrant1(bool visible, const string& name, int x, int y,
|
2499
|
+
const map<pair<int, int>, double>& weight,
|
2500
|
+
double min_weight, double max_wight) {
|
2501
|
+
return IsVisibleInQuadrant1(visible, x, y);
|
2502
|
+
}
|
2503
|
+
...
|
2504
|
+
EXPECT_CALL(mock, Foo)
|
2505
|
+
.WillOnce(Invoke(MyIsVisibleInQuadrant1)); // Now it works.
|
2506
|
+
```
|
2507
|
+
|
2508
|
+
But isn't this awkward?
|
2509
|
+
|
2510
|
+
gMock provides a generic *action adaptor*, so you can spend your time minding
|
2511
|
+
more important business than writing your own adaptors. Here's the syntax:
|
2512
|
+
|
2513
|
+
```cpp
|
2514
|
+
WithArgs<N1, N2, ..., Nk>(action)
|
2515
|
+
```
|
2516
|
+
|
2517
|
+
creates an action that passes the arguments of the mock function at the given
|
2518
|
+
indices (0-based) to the inner `action` and performs it. Using `WithArgs`, our
|
2519
|
+
original example can be written as:
|
2520
|
+
|
2521
|
+
```cpp
|
2522
|
+
using ::testing::_;
|
2523
|
+
using ::testing::Invoke;
|
2524
|
+
using ::testing::WithArgs;
|
2525
|
+
...
|
2526
|
+
EXPECT_CALL(mock, Foo)
|
2527
|
+
.WillOnce(WithArgs<0, 2, 3>(Invoke(IsVisibleInQuadrant1))); // No need to define your own adaptor.
|
2528
|
+
```
|
2529
|
+
|
2530
|
+
For better readability, gMock also gives you:
|
2531
|
+
|
2532
|
+
* `WithoutArgs(action)` when the inner `action` takes *no* argument, and
|
2533
|
+
* `WithArg<N>(action)` (no `s` after `Arg`) when the inner `action` takes
|
2534
|
+
*one* argument.
|
2535
|
+
|
2536
|
+
As you may have realized, `InvokeWithoutArgs(...)` is just syntactic sugar for
|
2537
|
+
`WithoutArgs(Invoke(...))`.
|
2538
|
+
|
2539
|
+
Here are more tips:
|
2540
|
+
|
2541
|
+
* The inner action used in `WithArgs` and friends does not have to be
|
2542
|
+
`Invoke()` -- it can be anything.
|
2543
|
+
* You can repeat an argument in the argument list if necessary, e.g.
|
2544
|
+
`WithArgs<2, 3, 3, 5>(...)`.
|
2545
|
+
* You can change the order of the arguments, e.g. `WithArgs<3, 2, 1>(...)`.
|
2546
|
+
* The types of the selected arguments do *not* have to match the signature of
|
2547
|
+
the inner action exactly. It works as long as they can be implicitly
|
2548
|
+
converted to the corresponding arguments of the inner action. For example,
|
2549
|
+
if the 4-th argument of the mock function is an `int` and `my_action` takes
|
2550
|
+
a `double`, `WithArg<4>(my_action)` will work.
|
2551
|
+
|
2552
|
+
### Ignoring Arguments in Action Functions
|
2553
|
+
|
2554
|
+
The [selecting-an-action's-arguments](#SelectingArgs) recipe showed us one way
|
2555
|
+
to make a mock function and an action with incompatible argument lists fit
|
2556
|
+
together. The downside is that wrapping the action in `WithArgs<...>()` can get
|
2557
|
+
tedious for people writing the tests.
|
2558
|
+
|
2559
|
+
If you are defining a function (or method, functor, lambda, callback) to be used
|
2560
|
+
with `Invoke*()`, and you are not interested in some of its arguments, an
|
2561
|
+
alternative to `WithArgs` is to declare the uninteresting arguments as `Unused`.
|
2562
|
+
This makes the definition less cluttered and less fragile in case the types of
|
2563
|
+
the uninteresting arguments change. It could also increase the chance the action
|
2564
|
+
function can be reused. For example, given
|
2565
|
+
|
2566
|
+
```cpp
|
2567
|
+
public:
|
2568
|
+
MOCK_METHOD(double, Foo, double(const string& label, double x, double y),
|
2569
|
+
(override));
|
2570
|
+
MOCK_METHOD(double, Bar, (int index, double x, double y), (override));
|
2571
|
+
```
|
2572
|
+
|
2573
|
+
instead of
|
2574
|
+
|
2575
|
+
```cpp
|
2576
|
+
using ::testing::_;
|
2577
|
+
using ::testing::Invoke;
|
2578
|
+
|
2579
|
+
double DistanceToOriginWithLabel(const string& label, double x, double y) {
|
2580
|
+
return sqrt(x*x + y*y);
|
2581
|
+
}
|
2582
|
+
double DistanceToOriginWithIndex(int index, double x, double y) {
|
2583
|
+
return sqrt(x*x + y*y);
|
2584
|
+
}
|
2585
|
+
...
|
2586
|
+
EXPECT_CALL(mock, Foo("abc", _, _))
|
2587
|
+
.WillOnce(Invoke(DistanceToOriginWithLabel));
|
2588
|
+
EXPECT_CALL(mock, Bar(5, _, _))
|
2589
|
+
.WillOnce(Invoke(DistanceToOriginWithIndex));
|
2590
|
+
```
|
2591
|
+
|
2592
|
+
you could write
|
2593
|
+
|
2594
|
+
```cpp
|
2595
|
+
using ::testing::_;
|
2596
|
+
using ::testing::Invoke;
|
2597
|
+
using ::testing::Unused;
|
2598
|
+
|
2599
|
+
double DistanceToOrigin(Unused, double x, double y) {
|
2600
|
+
return sqrt(x*x + y*y);
|
2601
|
+
}
|
2602
|
+
...
|
2603
|
+
EXPECT_CALL(mock, Foo("abc", _, _))
|
2604
|
+
.WillOnce(Invoke(DistanceToOrigin));
|
2605
|
+
EXPECT_CALL(mock, Bar(5, _, _))
|
2606
|
+
.WillOnce(Invoke(DistanceToOrigin));
|
2607
|
+
```
|
2608
|
+
|
2609
|
+
### Sharing Actions
|
2610
|
+
|
2611
|
+
Just like matchers, a gMock action object consists of a pointer to a ref-counted
|
2612
|
+
implementation object. Therefore copying actions is also allowed and very
|
2613
|
+
efficient. When the last action that references the implementation object dies,
|
2614
|
+
the implementation object will be deleted.
|
2615
|
+
|
2616
|
+
If you have some complex action that you want to use again and again, you may
|
2617
|
+
not have to build it from scratch everytime. If the action doesn't have an
|
2618
|
+
internal state (i.e. if it always does the same thing no matter how many times
|
2619
|
+
it has been called), you can assign it to an action variable and use that
|
2620
|
+
variable repeatedly. For example:
|
2621
|
+
|
2622
|
+
```cpp
|
2623
|
+
using ::testing::Action;
|
2624
|
+
using ::testing::DoAll;
|
2625
|
+
using ::testing::Return;
|
2626
|
+
using ::testing::SetArgPointee;
|
2627
|
+
...
|
2628
|
+
Action<bool(int*)> set_flag = DoAll(SetArgPointee<0>(5),
|
2629
|
+
Return(true));
|
2630
|
+
... use set_flag in .WillOnce() and .WillRepeatedly() ...
|
2631
|
+
```
|
2632
|
+
|
2633
|
+
However, if the action has its own state, you may be surprised if you share the
|
2634
|
+
action object. Suppose you have an action factory `IncrementCounter(init)` which
|
2635
|
+
creates an action that increments and returns a counter whose initial value is
|
2636
|
+
`init`, using two actions created from the same expression and using a shared
|
2637
|
+
action will exhibit different behaviors. Example:
|
2638
|
+
|
2639
|
+
```cpp
|
2640
|
+
EXPECT_CALL(foo, DoThis())
|
2641
|
+
.WillRepeatedly(IncrementCounter(0));
|
2642
|
+
EXPECT_CALL(foo, DoThat())
|
2643
|
+
.WillRepeatedly(IncrementCounter(0));
|
2644
|
+
foo.DoThis(); // Returns 1.
|
2645
|
+
foo.DoThis(); // Returns 2.
|
2646
|
+
foo.DoThat(); // Returns 1 - Blah() uses a different
|
2647
|
+
// counter than Bar()'s.
|
2648
|
+
```
|
2649
|
+
|
2650
|
+
versus
|
2651
|
+
|
2652
|
+
```cpp
|
2653
|
+
using ::testing::Action;
|
2654
|
+
...
|
2655
|
+
Action<int()> increment = IncrementCounter(0);
|
2656
|
+
EXPECT_CALL(foo, DoThis())
|
2657
|
+
.WillRepeatedly(increment);
|
2658
|
+
EXPECT_CALL(foo, DoThat())
|
2659
|
+
.WillRepeatedly(increment);
|
2660
|
+
foo.DoThis(); // Returns 1.
|
2661
|
+
foo.DoThis(); // Returns 2.
|
2662
|
+
foo.DoThat(); // Returns 3 - the counter is shared.
|
2663
|
+
```
|
2664
|
+
|
2665
|
+
### Testing Asynchronous Behavior
|
2666
|
+
|
2667
|
+
One oft-encountered problem with gMock is that it can be hard to test
|
2668
|
+
asynchronous behavior. Suppose you had a `EventQueue` class that you wanted to
|
2669
|
+
test, and you created a separate `EventDispatcher` interface so that you could
|
2670
|
+
easily mock it out. However, the implementation of the class fired all the
|
2671
|
+
events on a background thread, which made test timings difficult. You could just
|
2672
|
+
insert `sleep()` statements and hope for the best, but that makes your test
|
2673
|
+
behavior nondeterministic. A better way is to use gMock actions and
|
2674
|
+
`Notification` objects to force your asynchronous test to behave synchronously.
|
2675
|
+
|
2676
|
+
```cpp
|
2677
|
+
using ::testing::DoAll;
|
2678
|
+
using ::testing::InvokeWithoutArgs;
|
2679
|
+
using ::testing::Return;
|
2680
|
+
|
2681
|
+
class MockEventDispatcher : public EventDispatcher {
|
2682
|
+
MOCK_METHOD(bool, DispatchEvent, (int32), (override));
|
2683
|
+
};
|
2684
|
+
|
2685
|
+
ACTION_P(Notify, notification) {
|
2686
|
+
notification->Notify();
|
2687
|
+
}
|
2688
|
+
|
2689
|
+
TEST(EventQueueTest, EnqueueEventTest) {
|
2690
|
+
MockEventDispatcher mock_event_dispatcher;
|
2691
|
+
EventQueue event_queue(&mock_event_dispatcher);
|
2692
|
+
|
2693
|
+
const int32 kEventId = 321;
|
2694
|
+
absl::Notification done;
|
2695
|
+
EXPECT_CALL(mock_event_dispatcher, DispatchEvent(kEventId))
|
2696
|
+
.WillOnce(Notify(&done));
|
2697
|
+
|
2698
|
+
event_queue.EnqueueEvent(kEventId);
|
2699
|
+
done.WaitForNotification();
|
2700
|
+
}
|
2701
|
+
```
|
2702
|
+
|
2703
|
+
In the example above, we set our normal gMock expectations, but then add an
|
2704
|
+
additional action to notify the `Notification` object. Now we can just call
|
2705
|
+
`Notification::WaitForNotification()` in the main thread to wait for the
|
2706
|
+
asynchronous call to finish. After that, our test suite is complete and we can
|
2707
|
+
safely exit.
|
2708
|
+
|
2709
|
+
Note: this example has a downside: namely, if the expectation is not satisfied,
|
2710
|
+
our test will run forever. It will eventually time-out and fail, but it will
|
2711
|
+
take longer and be slightly harder to debug. To alleviate this problem, you can
|
2712
|
+
use `WaitForNotificationWithTimeout(ms)` instead of `WaitForNotification()`.
|
2713
|
+
|
2714
|
+
## Misc Recipes on Using gMock
|
2715
|
+
|
2716
|
+
### Mocking Methods That Use Move-Only Types
|
2717
|
+
|
2718
|
+
C++11 introduced *move-only types*. A move-only-typed value can be moved from
|
2719
|
+
one object to another, but cannot be copied. `std::unique_ptr<T>` is probably
|
2720
|
+
the most commonly used move-only type.
|
2721
|
+
|
2722
|
+
Mocking a method that takes and/or returns move-only types presents some
|
2723
|
+
challenges, but nothing insurmountable. This recipe shows you how you can do it.
|
2724
|
+
Note that the support for move-only method arguments was only introduced to
|
2725
|
+
gMock in April 2017; in older code, you may find more complex
|
2726
|
+
[workarounds](#LegacyMoveOnly) for lack of this feature.
|
2727
|
+
|
2728
|
+
Let’s say we are working on a fictional project that lets one post and share
|
2729
|
+
snippets called “buzzes”. Your code uses these types:
|
2730
|
+
|
2731
|
+
```cpp
|
2732
|
+
enum class AccessLevel { kInternal, kPublic };
|
2733
|
+
|
2734
|
+
class Buzz {
|
2735
|
+
public:
|
2736
|
+
explicit Buzz(AccessLevel access) { ... }
|
2737
|
+
...
|
2738
|
+
};
|
2739
|
+
|
2740
|
+
class Buzzer {
|
2741
|
+
public:
|
2742
|
+
virtual ~Buzzer() {}
|
2743
|
+
virtual std::unique_ptr<Buzz> MakeBuzz(StringPiece text) = 0;
|
2744
|
+
virtual bool ShareBuzz(std::unique_ptr<Buzz> buzz, int64_t timestamp) = 0;
|
2745
|
+
...
|
2746
|
+
};
|
2747
|
+
```
|
2748
|
+
|
2749
|
+
A `Buzz` object represents a snippet being posted. A class that implements the
|
2750
|
+
`Buzzer` interface is capable of creating and sharing `Buzz`es. Methods in
|
2751
|
+
`Buzzer` may return a `unique_ptr<Buzz>` or take a `unique_ptr<Buzz>`. Now we
|
2752
|
+
need to mock `Buzzer` in our tests.
|
2753
|
+
|
2754
|
+
To mock a method that accepts or returns move-only types, you just use the
|
2755
|
+
familiar `MOCK_METHOD` syntax as usual:
|
2756
|
+
|
2757
|
+
```cpp
|
2758
|
+
class MockBuzzer : public Buzzer {
|
2759
|
+
public:
|
2760
|
+
MOCK_METHOD(std::unique_ptr<Buzz>, MakeBuzz, (StringPiece text), (override));
|
2761
|
+
MOCK_METHOD(bool, ShareBuzz, (std::unique_ptr<Buzz> buzz, int64_t timestamp),
|
2762
|
+
(override));
|
2763
|
+
};
|
2764
|
+
```
|
2765
|
+
|
2766
|
+
Now that we have the mock class defined, we can use it in tests. In the
|
2767
|
+
following code examples, we assume that we have defined a `MockBuzzer` object
|
2768
|
+
named `mock_buzzer_`:
|
2769
|
+
|
2770
|
+
```cpp
|
2771
|
+
MockBuzzer mock_buzzer_;
|
2772
|
+
```
|
2773
|
+
|
2774
|
+
First let’s see how we can set expectations on the `MakeBuzz()` method, which
|
2775
|
+
returns a `unique_ptr<Buzz>`.
|
2776
|
+
|
2777
|
+
As usual, if you set an expectation without an action (i.e. the `.WillOnce()` or
|
2778
|
+
`.WillRepeatedly()` clause), when that expectation fires, the default action for
|
2779
|
+
that method will be taken. Since `unique_ptr<>` has a default constructor that
|
2780
|
+
returns a null `unique_ptr`, that’s what you’ll get if you don’t specify an
|
2781
|
+
action:
|
2782
|
+
|
2783
|
+
```cpp
|
2784
|
+
// Use the default action.
|
2785
|
+
EXPECT_CALL(mock_buzzer_, MakeBuzz("hello"));
|
2786
|
+
|
2787
|
+
// Triggers the previous EXPECT_CALL.
|
2788
|
+
EXPECT_EQ(nullptr, mock_buzzer_.MakeBuzz("hello"));
|
2789
|
+
```
|
2790
|
+
|
2791
|
+
If you are not happy with the default action, you can tweak it as usual; see
|
2792
|
+
[Setting Default Actions](#OnCall).
|
2793
|
+
|
2794
|
+
If you just need to return a pre-defined move-only value, you can use the
|
2795
|
+
`Return(ByMove(...))` action:
|
2796
|
+
|
2797
|
+
```cpp
|
2798
|
+
// When this fires, the unique_ptr<> specified by ByMove(...) will
|
2799
|
+
// be returned.
|
2800
|
+
EXPECT_CALL(mock_buzzer_, MakeBuzz("world"))
|
2801
|
+
.WillOnce(Return(ByMove(MakeUnique<Buzz>(AccessLevel::kInternal))));
|
2802
|
+
|
2803
|
+
EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("world"));
|
2804
|
+
```
|
2805
|
+
|
2806
|
+
Note that `ByMove()` is essential here - if you drop it, the code won’t compile.
|
2807
|
+
|
2808
|
+
Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
|
2809
|
+
performed more than once (e.g. you write `...
|
2810
|
+
.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first time
|
2811
|
+
the action runs, the source value will be consumed (since it’s a move-only
|
2812
|
+
value), so the next time around, there’s no value to move from -- you’ll get a
|
2813
|
+
run-time error that `Return(ByMove(...))` can only be run once.
|
2814
|
+
|
2815
|
+
If you need your mock method to do more than just moving a pre-defined value,
|
2816
|
+
remember that you can always use a lambda or a callable object, which can do
|
2817
|
+
pretty much anything you want:
|
2818
|
+
|
2819
|
+
```cpp
|
2820
|
+
EXPECT_CALL(mock_buzzer_, MakeBuzz("x"))
|
2821
|
+
.WillRepeatedly([](StringPiece text) {
|
2822
|
+
return MakeUnique<Buzz>(AccessLevel::kInternal);
|
2823
|
+
});
|
2824
|
+
|
2825
|
+
EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("x"));
|
2826
|
+
EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("x"));
|
2827
|
+
```
|
2828
|
+
|
2829
|
+
Every time this `EXPECT_CALL` fires, a new `unique_ptr<Buzz>` will be created
|
2830
|
+
and returned. You cannot do this with `Return(ByMove(...))`.
|
2831
|
+
|
2832
|
+
That covers returning move-only values; but how do we work with methods
|
2833
|
+
accepting move-only arguments? The answer is that they work normally, although
|
2834
|
+
some actions will not compile when any of method's arguments are move-only. You
|
2835
|
+
can always use `Return`, or a [lambda or functor](#FunctionsAsActions):
|
2836
|
+
|
2837
|
+
```cpp
|
2838
|
+
using ::testing::Unused;
|
2839
|
+
|
2840
|
+
EXPECT_CALL(mock_buzzer_, ShareBuzz(NotNull(), _)).WillOnce(Return(true));
|
2841
|
+
EXPECT_TRUE(mock_buzzer_.ShareBuzz(MakeUnique<Buzz>(AccessLevel::kInternal)),
|
2842
|
+
0);
|
2843
|
+
|
2844
|
+
EXPECT_CALL(mock_buzzer_, ShareBuzz(_, _)).WillOnce(
|
2845
|
+
[](std::unique_ptr<Buzz> buzz, Unused) { return buzz != nullptr; });
|
2846
|
+
EXPECT_FALSE(mock_buzzer_.ShareBuzz(nullptr, 0));
|
2847
|
+
```
|
2848
|
+
|
2849
|
+
Many built-in actions (`WithArgs`, `WithoutArgs`,`DeleteArg`, `SaveArg`, ...)
|
2850
|
+
could in principle support move-only arguments, but the support for this is not
|
2851
|
+
implemented yet. If this is blocking you, please file a bug.
|
2852
|
+
|
2853
|
+
A few actions (e.g. `DoAll`) copy their arguments internally, so they can never
|
2854
|
+
work with non-copyable objects; you'll have to use functors instead.
|
2855
|
+
|
2856
|
+
#### Legacy workarounds for move-only types {#LegacyMoveOnly}
|
2857
|
+
|
2858
|
+
Support for move-only function arguments was only introduced to gMock in April
|
2859
|
+
2017. In older code, you may encounter the following workaround for the lack of
|
2860
|
+
this feature (it is no longer necessary - we're including it just for
|
2861
|
+
reference):
|
2862
|
+
|
2863
|
+
```cpp
|
2864
|
+
class MockBuzzer : public Buzzer {
|
2865
|
+
public:
|
2866
|
+
MOCK_METHOD(bool, DoShareBuzz, (Buzz* buzz, Time timestamp));
|
2867
|
+
bool ShareBuzz(std::unique_ptr<Buzz> buzz, Time timestamp) override {
|
2868
|
+
return DoShareBuzz(buzz.get(), timestamp);
|
2869
|
+
}
|
2870
|
+
};
|
2871
|
+
```
|
2872
|
+
|
2873
|
+
The trick is to delegate the `ShareBuzz()` method to a mock method (let’s call
|
2874
|
+
it `DoShareBuzz()`) that does not take move-only parameters. Then, instead of
|
2875
|
+
setting expectations on `ShareBuzz()`, you set them on the `DoShareBuzz()` mock
|
2876
|
+
method:
|
2877
|
+
|
2878
|
+
```cpp
|
2879
|
+
MockBuzzer mock_buzzer_;
|
2880
|
+
EXPECT_CALL(mock_buzzer_, DoShareBuzz(NotNull(), _));
|
2881
|
+
|
2882
|
+
// When one calls ShareBuzz() on the MockBuzzer like this, the call is
|
2883
|
+
// forwarded to DoShareBuzz(), which is mocked. Therefore this statement
|
2884
|
+
// will trigger the above EXPECT_CALL.
|
2885
|
+
mock_buzzer_.ShareBuzz(MakeUnique<Buzz>(AccessLevel::kInternal), 0);
|
2886
|
+
```
|
2887
|
+
|
2888
|
+
### Making the Compilation Faster
|
2889
|
+
|
2890
|
+
Believe it or not, the *vast majority* of the time spent on compiling a mock
|
2891
|
+
class is in generating its constructor and destructor, as they perform
|
2892
|
+
non-trivial tasks (e.g. verification of the expectations). What's more, mock
|
2893
|
+
methods with different signatures have different types and thus their
|
2894
|
+
constructors/destructors need to be generated by the compiler separately. As a
|
2895
|
+
result, if you mock many different types of methods, compiling your mock class
|
2896
|
+
can get really slow.
|
2897
|
+
|
2898
|
+
If you are experiencing slow compilation, you can move the definition of your
|
2899
|
+
mock class' constructor and destructor out of the class body and into a `.cc`
|
2900
|
+
file. This way, even if you `#include` your mock class in N files, the compiler
|
2901
|
+
only needs to generate its constructor and destructor once, resulting in a much
|
2902
|
+
faster compilation.
|
2903
|
+
|
2904
|
+
Let's illustrate the idea using an example. Here's the definition of a mock
|
2905
|
+
class before applying this recipe:
|
2906
|
+
|
2907
|
+
```cpp
|
2908
|
+
// File mock_foo.h.
|
2909
|
+
...
|
2910
|
+
class MockFoo : public Foo {
|
2911
|
+
public:
|
2912
|
+
// Since we don't declare the constructor or the destructor,
|
2913
|
+
// the compiler will generate them in every translation unit
|
2914
|
+
// where this mock class is used.
|
2915
|
+
|
2916
|
+
MOCK_METHOD(int, DoThis, (), (override));
|
2917
|
+
MOCK_METHOD(bool, DoThat, (const char* str), (override));
|
2918
|
+
... more mock methods ...
|
2919
|
+
};
|
2920
|
+
```
|
2921
|
+
|
2922
|
+
After the change, it would look like:
|
2923
|
+
|
2924
|
+
```cpp
|
2925
|
+
// File mock_foo.h.
|
2926
|
+
...
|
2927
|
+
class MockFoo : public Foo {
|
2928
|
+
public:
|
2929
|
+
// The constructor and destructor are declared, but not defined, here.
|
2930
|
+
MockFoo();
|
2931
|
+
virtual ~MockFoo();
|
2932
|
+
|
2933
|
+
MOCK_METHOD(int, DoThis, (), (override));
|
2934
|
+
MOCK_METHOD(bool, DoThat, (const char* str), (override));
|
2935
|
+
... more mock methods ...
|
2936
|
+
};
|
2937
|
+
```
|
2938
|
+
|
2939
|
+
and
|
2940
|
+
|
2941
|
+
```cpp
|
2942
|
+
// File mock_foo.cc.
|
2943
|
+
#include "path/to/mock_foo.h"
|
2944
|
+
|
2945
|
+
// The definitions may appear trivial, but the functions actually do a
|
2946
|
+
// lot of things through the constructors/destructors of the member
|
2947
|
+
// variables used to implement the mock methods.
|
2948
|
+
MockFoo::MockFoo() {}
|
2949
|
+
MockFoo::~MockFoo() {}
|
2950
|
+
```
|
2951
|
+
|
2952
|
+
### Forcing a Verification
|
2953
|
+
|
2954
|
+
When it's being destroyed, your friendly mock object will automatically verify
|
2955
|
+
that all expectations on it have been satisfied, and will generate googletest
|
2956
|
+
failures if not. This is convenient as it leaves you with one less thing to
|
2957
|
+
worry about. That is, unless you are not sure if your mock object will be
|
2958
|
+
destroyed.
|
2959
|
+
|
2960
|
+
How could it be that your mock object won't eventually be destroyed? Well, it
|
2961
|
+
might be created on the heap and owned by the code you are testing. Suppose
|
2962
|
+
there's a bug in that code and it doesn't delete the mock object properly - you
|
2963
|
+
could end up with a passing test when there's actually a bug.
|
2964
|
+
|
2965
|
+
Using a heap checker is a good idea and can alleviate the concern, but its
|
2966
|
+
implementation is not 100% reliable. So, sometimes you do want to *force* gMock
|
2967
|
+
to verify a mock object before it is (hopefully) destructed. You can do this
|
2968
|
+
with `Mock::VerifyAndClearExpectations(&mock_object)`:
|
2969
|
+
|
2970
|
+
```cpp
|
2971
|
+
TEST(MyServerTest, ProcessesRequest) {
|
2972
|
+
using ::testing::Mock;
|
2973
|
+
|
2974
|
+
MockFoo* const foo = new MockFoo;
|
2975
|
+
EXPECT_CALL(*foo, ...)...;
|
2976
|
+
// ... other expectations ...
|
2977
|
+
|
2978
|
+
// server now owns foo.
|
2979
|
+
MyServer server(foo);
|
2980
|
+
server.ProcessRequest(...);
|
2981
|
+
|
2982
|
+
// In case that server's destructor will forget to delete foo,
|
2983
|
+
// this will verify the expectations anyway.
|
2984
|
+
Mock::VerifyAndClearExpectations(foo);
|
2985
|
+
} // server is destroyed when it goes out of scope here.
|
2986
|
+
```
|
2987
|
+
|
2988
|
+
**Tip:** The `Mock::VerifyAndClearExpectations()` function returns a `bool` to
|
2989
|
+
indicate whether the verification was successful (`true` for yes), so you can
|
2990
|
+
wrap that function call inside a `ASSERT_TRUE()` if there is no point going
|
2991
|
+
further when the verification has failed.
|
2992
|
+
|
2993
|
+
### Using Check Points {#UsingCheckPoints}
|
2994
|
+
|
2995
|
+
Sometimes you may want to "reset" a mock object at various check points in your
|
2996
|
+
test: at each check point, you verify that all existing expectations on the mock
|
2997
|
+
object have been satisfied, and then you set some new expectations on it as if
|
2998
|
+
it's newly created. This allows you to work with a mock object in "phases" whose
|
2999
|
+
sizes are each manageable.
|
3000
|
+
|
3001
|
+
One such scenario is that in your test's `SetUp()` function, you may want to put
|
3002
|
+
the object you are testing into a certain state, with the help from a mock
|
3003
|
+
object. Once in the desired state, you want to clear all expectations on the
|
3004
|
+
mock, such that in the `TEST_F` body you can set fresh expectations on it.
|
3005
|
+
|
3006
|
+
As you may have figured out, the `Mock::VerifyAndClearExpectations()` function
|
3007
|
+
we saw in the previous recipe can help you here. Or, if you are using
|
3008
|
+
`ON_CALL()` to set default actions on the mock object and want to clear the
|
3009
|
+
default actions as well, use `Mock::VerifyAndClear(&mock_object)` instead. This
|
3010
|
+
function does what `Mock::VerifyAndClearExpectations(&mock_object)` does and
|
3011
|
+
returns the same `bool`, **plus** it clears the `ON_CALL()` statements on
|
3012
|
+
`mock_object` too.
|
3013
|
+
|
3014
|
+
Another trick you can use to achieve the same effect is to put the expectations
|
3015
|
+
in sequences and insert calls to a dummy "check-point" function at specific
|
3016
|
+
places. Then you can verify that the mock function calls do happen at the right
|
3017
|
+
time. For example, if you are exercising code:
|
3018
|
+
|
3019
|
+
```cpp
|
3020
|
+
Foo(1);
|
3021
|
+
Foo(2);
|
3022
|
+
Foo(3);
|
3023
|
+
```
|
3024
|
+
|
3025
|
+
and want to verify that `Foo(1)` and `Foo(3)` both invoke `mock.Bar("a")`, but
|
3026
|
+
`Foo(2)` doesn't invoke anything. You can write:
|
3027
|
+
|
3028
|
+
```cpp
|
3029
|
+
using ::testing::MockFunction;
|
3030
|
+
|
3031
|
+
TEST(FooTest, InvokesBarCorrectly) {
|
3032
|
+
MyMock mock;
|
3033
|
+
// Class MockFunction<F> has exactly one mock method. It is named
|
3034
|
+
// Call() and has type F.
|
3035
|
+
MockFunction<void(string check_point_name)> check;
|
3036
|
+
{
|
3037
|
+
InSequence s;
|
3038
|
+
|
3039
|
+
EXPECT_CALL(mock, Bar("a"));
|
3040
|
+
EXPECT_CALL(check, Call("1"));
|
3041
|
+
EXPECT_CALL(check, Call("2"));
|
3042
|
+
EXPECT_CALL(mock, Bar("a"));
|
3043
|
+
}
|
3044
|
+
Foo(1);
|
3045
|
+
check.Call("1");
|
3046
|
+
Foo(2);
|
3047
|
+
check.Call("2");
|
3048
|
+
Foo(3);
|
3049
|
+
}
|
3050
|
+
```
|
3051
|
+
|
3052
|
+
The expectation spec says that the first `Bar("a")` must happen before check
|
3053
|
+
point "1", the second `Bar("a")` must happen after check point "2", and nothing
|
3054
|
+
should happen between the two check points. The explicit check points make it
|
3055
|
+
easy to tell which `Bar("a")` is called by which call to `Foo()`.
|
3056
|
+
|
3057
|
+
### Mocking Destructors
|
3058
|
+
|
3059
|
+
Sometimes you want to make sure a mock object is destructed at the right time,
|
3060
|
+
e.g. after `bar->A()` is called but before `bar->B()` is called. We already know
|
3061
|
+
that you can specify constraints on the [order](#OrderedCalls) of mock function
|
3062
|
+
calls, so all we need to do is to mock the destructor of the mock function.
|
3063
|
+
|
3064
|
+
This sounds simple, except for one problem: a destructor is a special function
|
3065
|
+
with special syntax and special semantics, and the `MOCK_METHOD` macro doesn't
|
3066
|
+
work for it:
|
3067
|
+
|
3068
|
+
```cpp
|
3069
|
+
MOCK_METHOD(void, ~MockFoo, ()); // Won't compile!
|
3070
|
+
```
|
3071
|
+
|
3072
|
+
The good news is that you can use a simple pattern to achieve the same effect.
|
3073
|
+
First, add a mock function `Die()` to your mock class and call it in the
|
3074
|
+
destructor, like this:
|
3075
|
+
|
3076
|
+
```cpp
|
3077
|
+
class MockFoo : public Foo {
|
3078
|
+
...
|
3079
|
+
// Add the following two lines to the mock class.
|
3080
|
+
MOCK_METHOD(void, Die, ());
|
3081
|
+
~MockFoo() override { Die(); }
|
3082
|
+
};
|
3083
|
+
```
|
3084
|
+
|
3085
|
+
(If the name `Die()` clashes with an existing symbol, choose another name.) Now,
|
3086
|
+
we have translated the problem of testing when a `MockFoo` object dies to
|
3087
|
+
testing when its `Die()` method is called:
|
3088
|
+
|
3089
|
+
```cpp
|
3090
|
+
MockFoo* foo = new MockFoo;
|
3091
|
+
MockBar* bar = new MockBar;
|
3092
|
+
...
|
3093
|
+
{
|
3094
|
+
InSequence s;
|
3095
|
+
|
3096
|
+
// Expects *foo to die after bar->A() and before bar->B().
|
3097
|
+
EXPECT_CALL(*bar, A());
|
3098
|
+
EXPECT_CALL(*foo, Die());
|
3099
|
+
EXPECT_CALL(*bar, B());
|
3100
|
+
}
|
3101
|
+
```
|
3102
|
+
|
3103
|
+
And that's that.
|
3104
|
+
|
3105
|
+
### Using gMock and Threads {#UsingThreads}
|
3106
|
+
|
3107
|
+
In a **unit** test, it's best if you could isolate and test a piece of code in a
|
3108
|
+
single-threaded context. That avoids race conditions and dead locks, and makes
|
3109
|
+
debugging your test much easier.
|
3110
|
+
|
3111
|
+
Yet most programs are multi-threaded, and sometimes to test something we need to
|
3112
|
+
pound on it from more than one thread. gMock works for this purpose too.
|
3113
|
+
|
3114
|
+
Remember the steps for using a mock:
|
3115
|
+
|
3116
|
+
1. Create a mock object `foo`.
|
3117
|
+
2. Set its default actions and expectations using `ON_CALL()` and
|
3118
|
+
`EXPECT_CALL()`.
|
3119
|
+
3. The code under test calls methods of `foo`.
|
3120
|
+
4. Optionally, verify and reset the mock.
|
3121
|
+
5. Destroy the mock yourself, or let the code under test destroy it. The
|
3122
|
+
destructor will automatically verify it.
|
3123
|
+
|
3124
|
+
If you follow the following simple rules, your mocks and threads can live
|
3125
|
+
happily together:
|
3126
|
+
|
3127
|
+
* Execute your *test code* (as opposed to the code being tested) in *one*
|
3128
|
+
thread. This makes your test easy to follow.
|
3129
|
+
* Obviously, you can do step #1 without locking.
|
3130
|
+
* When doing step #2 and #5, make sure no other thread is accessing `foo`.
|
3131
|
+
Obvious too, huh?
|
3132
|
+
* #3 and #4 can be done either in one thread or in multiple threads - anyway
|
3133
|
+
you want. gMock takes care of the locking, so you don't have to do any -
|
3134
|
+
unless required by your test logic.
|
3135
|
+
|
3136
|
+
If you violate the rules (for example, if you set expectations on a mock while
|
3137
|
+
another thread is calling its methods), you get undefined behavior. That's not
|
3138
|
+
fun, so don't do it.
|
3139
|
+
|
3140
|
+
gMock guarantees that the action for a mock function is done in the same thread
|
3141
|
+
that called the mock function. For example, in
|
3142
|
+
|
3143
|
+
```cpp
|
3144
|
+
EXPECT_CALL(mock, Foo(1))
|
3145
|
+
.WillOnce(action1);
|
3146
|
+
EXPECT_CALL(mock, Foo(2))
|
3147
|
+
.WillOnce(action2);
|
3148
|
+
```
|
3149
|
+
|
3150
|
+
if `Foo(1)` is called in thread 1 and `Foo(2)` is called in thread 2, gMock will
|
3151
|
+
execute `action1` in thread 1 and `action2` in thread 2.
|
3152
|
+
|
3153
|
+
gMock does *not* impose a sequence on actions performed in different threads
|
3154
|
+
(doing so may create deadlocks as the actions may need to cooperate). This means
|
3155
|
+
that the execution of `action1` and `action2` in the above example *may*
|
3156
|
+
interleave. If this is a problem, you should add proper synchronization logic to
|
3157
|
+
`action1` and `action2` to make the test thread-safe.
|
3158
|
+
|
3159
|
+
Also, remember that `DefaultValue<T>` is a global resource that potentially
|
3160
|
+
affects *all* living mock objects in your program. Naturally, you won't want to
|
3161
|
+
mess with it from multiple threads or when there still are mocks in action.
|
3162
|
+
|
3163
|
+
### Controlling How Much Information gMock Prints
|
3164
|
+
|
3165
|
+
When gMock sees something that has the potential of being an error (e.g. a mock
|
3166
|
+
function with no expectation is called, a.k.a. an uninteresting call, which is
|
3167
|
+
allowed but perhaps you forgot to explicitly ban the call), it prints some
|
3168
|
+
warning messages, including the arguments of the function, the return value, and
|
3169
|
+
the stack trace. Hopefully this will remind you to take a look and see if there
|
3170
|
+
is indeed a problem.
|
3171
|
+
|
3172
|
+
Sometimes you are confident that your tests are correct and may not appreciate
|
3173
|
+
such friendly messages. Some other times, you are debugging your tests or
|
3174
|
+
learning about the behavior of the code you are testing, and wish you could
|
3175
|
+
observe every mock call that happens (including argument values, the return
|
3176
|
+
value, and the stack trace). Clearly, one size doesn't fit all.
|
3177
|
+
|
3178
|
+
You can control how much gMock tells you using the `--gmock_verbose=LEVEL`
|
3179
|
+
command-line flag, where `LEVEL` is a string with three possible values:
|
3180
|
+
|
3181
|
+
* `info`: gMock will print all informational messages, warnings, and errors
|
3182
|
+
(most verbose). At this setting, gMock will also log any calls to the
|
3183
|
+
`ON_CALL/EXPECT_CALL` macros. It will include a stack trace in
|
3184
|
+
"uninteresting call" warnings.
|
3185
|
+
* `warning`: gMock will print both warnings and errors (less verbose); it will
|
3186
|
+
omit the stack traces in "uninteresting call" warnings. This is the default.
|
3187
|
+
* `error`: gMock will print errors only (least verbose).
|
3188
|
+
|
3189
|
+
Alternatively, you can adjust the value of that flag from within your tests like
|
3190
|
+
so:
|
3191
|
+
|
3192
|
+
```cpp
|
3193
|
+
::testing::FLAGS_gmock_verbose = "error";
|
3194
|
+
```
|
3195
|
+
|
3196
|
+
If you find gMock printing too many stack frames with its informational or
|
3197
|
+
warning messages, remember that you can control their amount with the
|
3198
|
+
`--gtest_stack_trace_depth=max_depth` flag.
|
3199
|
+
|
3200
|
+
Now, judiciously use the right flag to enable gMock serve you better!
|
3201
|
+
|
3202
|
+
### Gaining Super Vision into Mock Calls
|
3203
|
+
|
3204
|
+
You have a test using gMock. It fails: gMock tells you some expectations aren't
|
3205
|
+
satisfied. However, you aren't sure why: Is there a typo somewhere in the
|
3206
|
+
matchers? Did you mess up the order of the `EXPECT_CALL`s? Or is the code under
|
3207
|
+
test doing something wrong? How can you find out the cause?
|
3208
|
+
|
3209
|
+
Won't it be nice if you have X-ray vision and can actually see the trace of all
|
3210
|
+
`EXPECT_CALL`s and mock method calls as they are made? For each call, would you
|
3211
|
+
like to see its actual argument values and which `EXPECT_CALL` gMock thinks it
|
3212
|
+
matches? If you still need some help to figure out who made these calls, how
|
3213
|
+
about being able to see the complete stack trace at each mock call?
|
3214
|
+
|
3215
|
+
You can unlock this power by running your test with the `--gmock_verbose=info`
|
3216
|
+
flag. For example, given the test program:
|
3217
|
+
|
3218
|
+
```cpp
|
3219
|
+
#include "gmock/gmock.h"
|
3220
|
+
|
3221
|
+
using testing::_;
|
3222
|
+
using testing::HasSubstr;
|
3223
|
+
using testing::Return;
|
3224
|
+
|
3225
|
+
class MockFoo {
|
3226
|
+
public:
|
3227
|
+
MOCK_METHOD(void, F, (const string& x, const string& y));
|
3228
|
+
};
|
3229
|
+
|
3230
|
+
TEST(Foo, Bar) {
|
3231
|
+
MockFoo mock;
|
3232
|
+
EXPECT_CALL(mock, F(_, _)).WillRepeatedly(Return());
|
3233
|
+
EXPECT_CALL(mock, F("a", "b"));
|
3234
|
+
EXPECT_CALL(mock, F("c", HasSubstr("d")));
|
3235
|
+
|
3236
|
+
mock.F("a", "good");
|
3237
|
+
mock.F("a", "b");
|
3238
|
+
}
|
3239
|
+
```
|
3240
|
+
|
3241
|
+
if you run it with `--gmock_verbose=info`, you will see this output:
|
3242
|
+
|
3243
|
+
```shell
|
3244
|
+
[ RUN ] Foo.Bar
|
3245
|
+
|
3246
|
+
foo_test.cc:14: EXPECT_CALL(mock, F(_, _)) invoked
|
3247
|
+
Stack trace: ...
|
3248
|
+
|
3249
|
+
foo_test.cc:15: EXPECT_CALL(mock, F("a", "b")) invoked
|
3250
|
+
Stack trace: ...
|
3251
|
+
|
3252
|
+
foo_test.cc:16: EXPECT_CALL(mock, F("c", HasSubstr("d"))) invoked
|
3253
|
+
Stack trace: ...
|
3254
|
+
|
3255
|
+
foo_test.cc:14: Mock function call matches EXPECT_CALL(mock, F(_, _))...
|
3256
|
+
Function call: F(@0x7fff7c8dad40"a",@0x7fff7c8dad10"good")
|
3257
|
+
Stack trace: ...
|
3258
|
+
|
3259
|
+
foo_test.cc:15: Mock function call matches EXPECT_CALL(mock, F("a", "b"))...
|
3260
|
+
Function call: F(@0x7fff7c8dada0"a",@0x7fff7c8dad70"b")
|
3261
|
+
Stack trace: ...
|
3262
|
+
|
3263
|
+
foo_test.cc:16: Failure
|
3264
|
+
Actual function call count doesn't match EXPECT_CALL(mock, F("c", HasSubstr("d")))...
|
3265
|
+
Expected: to be called once
|
3266
|
+
Actual: never called - unsatisfied and active
|
3267
|
+
[ FAILED ] Foo.Bar
|
3268
|
+
```
|
3269
|
+
|
3270
|
+
Suppose the bug is that the `"c"` in the third `EXPECT_CALL` is a typo and
|
3271
|
+
should actually be `"a"`. With the above message, you should see that the actual
|
3272
|
+
`F("a", "good")` call is matched by the first `EXPECT_CALL`, not the third as
|
3273
|
+
you thought. From that it should be obvious that the third `EXPECT_CALL` is
|
3274
|
+
written wrong. Case solved.
|
3275
|
+
|
3276
|
+
If you are interested in the mock call trace but not the stack traces, you can
|
3277
|
+
combine `--gmock_verbose=info` with `--gtest_stack_trace_depth=0` on the test
|
3278
|
+
command line.
|
3279
|
+
|
3280
|
+
<!-- GOOGLETEST_CM0025 DO NOT DELETE -->
|
3281
|
+
|
3282
|
+
### Running Tests in Emacs
|
3283
|
+
|
3284
|
+
If you build and run your tests in Emacs using the `M-x google-compile` command
|
3285
|
+
(as many googletest users do), the source file locations of gMock and googletest
|
3286
|
+
errors will be highlighted. Just press `<Enter>` on one of them and you'll be
|
3287
|
+
taken to the offending line. Or, you can just type `C-x`` to jump to the next
|
3288
|
+
error.
|
3289
|
+
|
3290
|
+
To make it even easier, you can add the following lines to your `~/.emacs` file:
|
3291
|
+
|
3292
|
+
```text
|
3293
|
+
(global-set-key "\M-m" 'google-compile) ; m is for make
|
3294
|
+
(global-set-key [M-down] 'next-error)
|
3295
|
+
(global-set-key [M-up] '(lambda () (interactive) (next-error -1)))
|
3296
|
+
```
|
3297
|
+
|
3298
|
+
Then you can type `M-m` to start a build (if you want to run the test as well,
|
3299
|
+
just make sure `foo_test.run` or `runtests` is in the build command you supply
|
3300
|
+
after typing `M-m`), or `M-up`/`M-down` to move back and forth between errors.
|
3301
|
+
|
3302
|
+
## Extending gMock
|
3303
|
+
|
3304
|
+
### Writing New Matchers Quickly {#NewMatchers}
|
3305
|
+
|
3306
|
+
WARNING: gMock does not guarantee when or how many times a matcher will be
|
3307
|
+
invoked. Therefore, all matchers must be functionally pure. See
|
3308
|
+
[this section](#PureMatchers) for more details.
|
3309
|
+
|
3310
|
+
The `MATCHER*` family of macros can be used to define custom matchers easily.
|
3311
|
+
The syntax:
|
3312
|
+
|
3313
|
+
```cpp
|
3314
|
+
MATCHER(name, description_string_expression) { statements; }
|
3315
|
+
```
|
3316
|
+
|
3317
|
+
will define a matcher with the given name that executes the statements, which
|
3318
|
+
must return a `bool` to indicate if the match succeeds. Inside the statements,
|
3319
|
+
you can refer to the value being matched by `arg`, and refer to its type by
|
3320
|
+
`arg_type`.
|
3321
|
+
|
3322
|
+
The *description string* is a `string`-typed expression that documents what the
|
3323
|
+
matcher does, and is used to generate the failure message when the match fails.
|
3324
|
+
It can (and should) reference the special `bool` variable `negation`, and should
|
3325
|
+
evaluate to the description of the matcher when `negation` is `false`, or that
|
3326
|
+
of the matcher's negation when `negation` is `true`.
|
3327
|
+
|
3328
|
+
For convenience, we allow the description string to be empty (`""`), in which
|
3329
|
+
case gMock will use the sequence of words in the matcher name as the
|
3330
|
+
description.
|
3331
|
+
|
3332
|
+
For example:
|
3333
|
+
|
3334
|
+
```cpp
|
3335
|
+
MATCHER(IsDivisibleBy7, "") { return (arg % 7) == 0; }
|
3336
|
+
```
|
3337
|
+
|
3338
|
+
allows you to write
|
3339
|
+
|
3340
|
+
```cpp
|
3341
|
+
// Expects mock_foo.Bar(n) to be called where n is divisible by 7.
|
3342
|
+
EXPECT_CALL(mock_foo, Bar(IsDivisibleBy7()));
|
3343
|
+
```
|
3344
|
+
|
3345
|
+
or,
|
3346
|
+
|
3347
|
+
```cpp
|
3348
|
+
using ::testing::Not;
|
3349
|
+
...
|
3350
|
+
// Verifies that two values are divisible by 7.
|
3351
|
+
EXPECT_THAT(some_expression, IsDivisibleBy7());
|
3352
|
+
EXPECT_THAT(some_other_expression, Not(IsDivisibleBy7()));
|
3353
|
+
```
|
3354
|
+
|
3355
|
+
If the above assertions fail, they will print something like:
|
3356
|
+
|
3357
|
+
```shell
|
3358
|
+
Value of: some_expression
|
3359
|
+
Expected: is divisible by 7
|
3360
|
+
Actual: 27
|
3361
|
+
...
|
3362
|
+
Value of: some_other_expression
|
3363
|
+
Expected: not (is divisible by 7)
|
3364
|
+
Actual: 21
|
3365
|
+
```
|
3366
|
+
|
3367
|
+
where the descriptions `"is divisible by 7"` and `"not (is divisible by 7)"` are
|
3368
|
+
automatically calculated from the matcher name `IsDivisibleBy7`.
|
3369
|
+
|
3370
|
+
As you may have noticed, the auto-generated descriptions (especially those for
|
3371
|
+
the negation) may not be so great. You can always override them with a `string`
|
3372
|
+
expression of your own:
|
3373
|
+
|
3374
|
+
```cpp
|
3375
|
+
MATCHER(IsDivisibleBy7,
|
3376
|
+
absl::StrCat(negation ? "isn't" : "is", " divisible by 7")) {
|
3377
|
+
return (arg % 7) == 0;
|
3378
|
+
}
|
3379
|
+
```
|
3380
|
+
|
3381
|
+
Optionally, you can stream additional information to a hidden argument named
|
3382
|
+
`result_listener` to explain the match result. For example, a better definition
|
3383
|
+
of `IsDivisibleBy7` is:
|
3384
|
+
|
3385
|
+
```cpp
|
3386
|
+
MATCHER(IsDivisibleBy7, "") {
|
3387
|
+
if ((arg % 7) == 0)
|
3388
|
+
return true;
|
3389
|
+
|
3390
|
+
*result_listener << "the remainder is " << (arg % 7);
|
3391
|
+
return false;
|
3392
|
+
}
|
3393
|
+
```
|
3394
|
+
|
3395
|
+
With this definition, the above assertion will give a better message:
|
3396
|
+
|
3397
|
+
```shell
|
3398
|
+
Value of: some_expression
|
3399
|
+
Expected: is divisible by 7
|
3400
|
+
Actual: 27 (the remainder is 6)
|
3401
|
+
```
|
3402
|
+
|
3403
|
+
You should let `MatchAndExplain()` print *any additional information* that can
|
3404
|
+
help a user understand the match result. Note that it should explain why the
|
3405
|
+
match succeeds in case of a success (unless it's obvious) - this is useful when
|
3406
|
+
the matcher is used inside `Not()`. There is no need to print the argument value
|
3407
|
+
itself, as gMock already prints it for you.
|
3408
|
+
|
3409
|
+
NOTE: The type of the value being matched (`arg_type`) is determined by the
|
3410
|
+
context in which you use the matcher and is supplied to you by the compiler, so
|
3411
|
+
you don't need to worry about declaring it (nor can you). This allows the
|
3412
|
+
matcher to be polymorphic. For example, `IsDivisibleBy7()` can be used to match
|
3413
|
+
any type where the value of `(arg % 7) == 0` can be implicitly converted to a
|
3414
|
+
`bool`. In the `Bar(IsDivisibleBy7())` example above, if method `Bar()` takes an
|
3415
|
+
`int`, `arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will
|
3416
|
+
be `unsigned long`; and so on.
|
3417
|
+
|
3418
|
+
### Writing New Parameterized Matchers Quickly
|
3419
|
+
|
3420
|
+
Sometimes you'll want to define a matcher that has parameters. For that you can
|
3421
|
+
use the macro:
|
3422
|
+
|
3423
|
+
```cpp
|
3424
|
+
MATCHER_P(name, param_name, description_string) { statements; }
|
3425
|
+
```
|
3426
|
+
|
3427
|
+
where the description string can be either `""` or a `string` expression that
|
3428
|
+
references `negation` and `param_name`.
|
3429
|
+
|
3430
|
+
For example:
|
3431
|
+
|
3432
|
+
```cpp
|
3433
|
+
MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; }
|
3434
|
+
```
|
3435
|
+
|
3436
|
+
will allow you to write:
|
3437
|
+
|
3438
|
+
```cpp
|
3439
|
+
EXPECT_THAT(Blah("a"), HasAbsoluteValue(n));
|
3440
|
+
```
|
3441
|
+
|
3442
|
+
which may lead to this message (assuming `n` is 10):
|
3443
|
+
|
3444
|
+
```shell
|
3445
|
+
Value of: Blah("a")
|
3446
|
+
Expected: has absolute value 10
|
3447
|
+
Actual: -9
|
3448
|
+
```
|
3449
|
+
|
3450
|
+
Note that both the matcher description and its parameter are printed, making the
|
3451
|
+
message human-friendly.
|
3452
|
+
|
3453
|
+
In the matcher definition body, you can write `foo_type` to reference the type
|
3454
|
+
of a parameter named `foo`. For example, in the body of
|
3455
|
+
`MATCHER_P(HasAbsoluteValue, value)` above, you can write `value_type` to refer
|
3456
|
+
to the type of `value`.
|
3457
|
+
|
3458
|
+
gMock also provides `MATCHER_P2`, `MATCHER_P3`, ..., up to `MATCHER_P10` to
|
3459
|
+
support multi-parameter matchers:
|
3460
|
+
|
3461
|
+
```cpp
|
3462
|
+
MATCHER_Pk(name, param_1, ..., param_k, description_string) { statements; }
|
3463
|
+
```
|
3464
|
+
|
3465
|
+
Please note that the custom description string is for a particular *instance* of
|
3466
|
+
the matcher, where the parameters have been bound to actual values. Therefore
|
3467
|
+
usually you'll want the parameter values to be part of the description. gMock
|
3468
|
+
lets you do that by referencing the matcher parameters in the description string
|
3469
|
+
expression.
|
3470
|
+
|
3471
|
+
For example,
|
3472
|
+
|
3473
|
+
```cpp
|
3474
|
+
using ::testing::PrintToString;
|
3475
|
+
MATCHER_P2(InClosedRange, low, hi,
|
3476
|
+
absl::StrFormat("%s in range [%s, %s]", negation ? "isn't" : "is",
|
3477
|
+
PrintToString(low), PrintToString(hi))) {
|
3478
|
+
return low <= arg && arg <= hi;
|
3479
|
+
}
|
3480
|
+
...
|
3481
|
+
EXPECT_THAT(3, InClosedRange(4, 6));
|
3482
|
+
```
|
3483
|
+
|
3484
|
+
would generate a failure that contains the message:
|
3485
|
+
|
3486
|
+
```shell
|
3487
|
+
Expected: is in range [4, 6]
|
3488
|
+
```
|
3489
|
+
|
3490
|
+
If you specify `""` as the description, the failure message will contain the
|
3491
|
+
sequence of words in the matcher name followed by the parameter values printed
|
3492
|
+
as a tuple. For example,
|
3493
|
+
|
3494
|
+
```cpp
|
3495
|
+
MATCHER_P2(InClosedRange, low, hi, "") { ... }
|
3496
|
+
...
|
3497
|
+
EXPECT_THAT(3, InClosedRange(4, 6));
|
3498
|
+
```
|
3499
|
+
|
3500
|
+
would generate a failure that contains the text:
|
3501
|
+
|
3502
|
+
```shell
|
3503
|
+
Expected: in closed range (4, 6)
|
3504
|
+
```
|
3505
|
+
|
3506
|
+
For the purpose of typing, you can view
|
3507
|
+
|
3508
|
+
```cpp
|
3509
|
+
MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }
|
3510
|
+
```
|
3511
|
+
|
3512
|
+
as shorthand for
|
3513
|
+
|
3514
|
+
```cpp
|
3515
|
+
template <typename p1_type, ..., typename pk_type>
|
3516
|
+
FooMatcherPk<p1_type, ..., pk_type>
|
3517
|
+
Foo(p1_type p1, ..., pk_type pk) { ... }
|
3518
|
+
```
|
3519
|
+
|
3520
|
+
When you write `Foo(v1, ..., vk)`, the compiler infers the types of the
|
3521
|
+
parameters `v1`, ..., and `vk` for you. If you are not happy with the result of
|
3522
|
+
the type inference, you can specify the types by explicitly instantiating the
|
3523
|
+
template, as in `Foo<long, bool>(5, false)`. As said earlier, you don't get to
|
3524
|
+
(or need to) specify `arg_type` as that's determined by the context in which the
|
3525
|
+
matcher is used.
|
3526
|
+
|
3527
|
+
You can assign the result of expression `Foo(p1, ..., pk)` to a variable of type
|
3528
|
+
`FooMatcherPk<p1_type, ..., pk_type>`. This can be useful when composing
|
3529
|
+
matchers. Matchers that don't have a parameter or have only one parameter have
|
3530
|
+
special types: you can assign `Foo()` to a `FooMatcher`-typed variable, and
|
3531
|
+
assign `Foo(p)` to a `FooMatcherP<p_type>`-typed variable.
|
3532
|
+
|
3533
|
+
While you can instantiate a matcher template with reference types, passing the
|
3534
|
+
parameters by pointer usually makes your code more readable. If, however, you
|
3535
|
+
still want to pass a parameter by reference, be aware that in the failure
|
3536
|
+
message generated by the matcher you will see the value of the referenced object
|
3537
|
+
but not its address.
|
3538
|
+
|
3539
|
+
You can overload matchers with different numbers of parameters:
|
3540
|
+
|
3541
|
+
```cpp
|
3542
|
+
MATCHER_P(Blah, a, description_string_1) { ... }
|
3543
|
+
MATCHER_P2(Blah, a, b, description_string_2) { ... }
|
3544
|
+
```
|
3545
|
+
|
3546
|
+
While it's tempting to always use the `MATCHER*` macros when defining a new
|
3547
|
+
matcher, you should also consider implementing `MatcherInterface` or using
|
3548
|
+
`MakePolymorphicMatcher()` instead (see the recipes that follow), especially if
|
3549
|
+
you need to use the matcher a lot. While these approaches require more work,
|
3550
|
+
they give you more control on the types of the value being matched and the
|
3551
|
+
matcher parameters, which in general leads to better compiler error messages
|
3552
|
+
that pay off in the long run. They also allow overloading matchers based on
|
3553
|
+
parameter types (as opposed to just based on the number of parameters).
|
3554
|
+
|
3555
|
+
### Writing New Monomorphic Matchers
|
3556
|
+
|
3557
|
+
A matcher of argument type `T` implements `::testing::MatcherInterface<T>` and
|
3558
|
+
does two things: it tests whether a value of type `T` matches the matcher, and
|
3559
|
+
can describe what kind of values it matches. The latter ability is used for
|
3560
|
+
generating readable error messages when expectations are violated.
|
3561
|
+
|
3562
|
+
The interface looks like this:
|
3563
|
+
|
3564
|
+
```cpp
|
3565
|
+
class MatchResultListener {
|
3566
|
+
public:
|
3567
|
+
...
|
3568
|
+
// Streams x to the underlying ostream; does nothing if the ostream
|
3569
|
+
// is NULL.
|
3570
|
+
template <typename T>
|
3571
|
+
MatchResultListener& operator<<(const T& x);
|
3572
|
+
|
3573
|
+
// Returns the underlying ostream.
|
3574
|
+
std::ostream* stream();
|
3575
|
+
};
|
3576
|
+
|
3577
|
+
template <typename T>
|
3578
|
+
class MatcherInterface {
|
3579
|
+
public:
|
3580
|
+
virtual ~MatcherInterface();
|
3581
|
+
|
3582
|
+
// Returns true if and only if the matcher matches x; also explains the match
|
3583
|
+
// result to 'listener'.
|
3584
|
+
virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
|
3585
|
+
|
3586
|
+
// Describes this matcher to an ostream.
|
3587
|
+
virtual void DescribeTo(std::ostream* os) const = 0;
|
3588
|
+
|
3589
|
+
// Describes the negation of this matcher to an ostream.
|
3590
|
+
virtual void DescribeNegationTo(std::ostream* os) const;
|
3591
|
+
};
|
3592
|
+
```
|
3593
|
+
|
3594
|
+
If you need a custom matcher but `Truly()` is not a good option (for example,
|
3595
|
+
you may not be happy with the way `Truly(predicate)` describes itself, or you
|
3596
|
+
may want your matcher to be polymorphic as `Eq(value)` is), you can define a
|
3597
|
+
matcher to do whatever you want in two steps: first implement the matcher
|
3598
|
+
interface, and then define a factory function to create a matcher instance. The
|
3599
|
+
second step is not strictly needed but it makes the syntax of using the matcher
|
3600
|
+
nicer.
|
3601
|
+
|
3602
|
+
For example, you can define a matcher to test whether an `int` is divisible by 7
|
3603
|
+
and then use it like this:
|
3604
|
+
|
3605
|
+
```cpp
|
3606
|
+
using ::testing::MakeMatcher;
|
3607
|
+
using ::testing::Matcher;
|
3608
|
+
using ::testing::MatcherInterface;
|
3609
|
+
using ::testing::MatchResultListener;
|
3610
|
+
|
3611
|
+
class DivisibleBy7Matcher : public MatcherInterface<int> {
|
3612
|
+
public:
|
3613
|
+
bool MatchAndExplain(int n,
|
3614
|
+
MatchResultListener* /* listener */) const override {
|
3615
|
+
return (n % 7) == 0;
|
3616
|
+
}
|
3617
|
+
|
3618
|
+
void DescribeTo(std::ostream* os) const override {
|
3619
|
+
*os << "is divisible by 7";
|
3620
|
+
}
|
3621
|
+
|
3622
|
+
void DescribeNegationTo(std::ostream* os) const override {
|
3623
|
+
*os << "is not divisible by 7";
|
3624
|
+
}
|
3625
|
+
};
|
3626
|
+
|
3627
|
+
Matcher<int> DivisibleBy7() {
|
3628
|
+
return MakeMatcher(new DivisibleBy7Matcher);
|
3629
|
+
}
|
3630
|
+
|
3631
|
+
...
|
3632
|
+
EXPECT_CALL(foo, Bar(DivisibleBy7()));
|
3633
|
+
```
|
3634
|
+
|
3635
|
+
You may improve the matcher message by streaming additional information to the
|
3636
|
+
`listener` argument in `MatchAndExplain()`:
|
3637
|
+
|
3638
|
+
```cpp
|
3639
|
+
class DivisibleBy7Matcher : public MatcherInterface<int> {
|
3640
|
+
public:
|
3641
|
+
bool MatchAndExplain(int n,
|
3642
|
+
MatchResultListener* listener) const override {
|
3643
|
+
const int remainder = n % 7;
|
3644
|
+
if (remainder != 0) {
|
3645
|
+
*listener << "the remainder is " << remainder;
|
3646
|
+
}
|
3647
|
+
return remainder == 0;
|
3648
|
+
}
|
3649
|
+
...
|
3650
|
+
};
|
3651
|
+
```
|
3652
|
+
|
3653
|
+
Then, `EXPECT_THAT(x, DivisibleBy7());` may generate a message like this:
|
3654
|
+
|
3655
|
+
```shell
|
3656
|
+
Value of: x
|
3657
|
+
Expected: is divisible by 7
|
3658
|
+
Actual: 23 (the remainder is 2)
|
3659
|
+
```
|
3660
|
+
|
3661
|
+
### Writing New Polymorphic Matchers
|
3662
|
+
|
3663
|
+
You've learned how to write your own matchers in the previous recipe. Just one
|
3664
|
+
problem: a matcher created using `MakeMatcher()` only works for one particular
|
3665
|
+
type of arguments. If you want a *polymorphic* matcher that works with arguments
|
3666
|
+
of several types (for instance, `Eq(x)` can be used to match a *`value`* as long
|
3667
|
+
as `value == x` compiles -- *`value`* and `x` don't have to share the same
|
3668
|
+
type), you can learn the trick from `testing/base/public/gmock-matchers.h` but
|
3669
|
+
it's a bit involved.
|
3670
|
+
|
3671
|
+
Fortunately, most of the time you can define a polymorphic matcher easily with
|
3672
|
+
the help of `MakePolymorphicMatcher()`. Here's how you can define `NotNull()` as
|
3673
|
+
an example:
|
3674
|
+
|
3675
|
+
```cpp
|
3676
|
+
using ::testing::MakePolymorphicMatcher;
|
3677
|
+
using ::testing::MatchResultListener;
|
3678
|
+
using ::testing::PolymorphicMatcher;
|
3679
|
+
|
3680
|
+
class NotNullMatcher {
|
3681
|
+
public:
|
3682
|
+
// To implement a polymorphic matcher, first define a COPYABLE class
|
3683
|
+
// that has three members MatchAndExplain(), DescribeTo(), and
|
3684
|
+
// DescribeNegationTo(), like the following.
|
3685
|
+
|
3686
|
+
// In this example, we want to use NotNull() with any pointer, so
|
3687
|
+
// MatchAndExplain() accepts a pointer of any type as its first argument.
|
3688
|
+
// In general, you can define MatchAndExplain() as an ordinary method or
|
3689
|
+
// a method template, or even overload it.
|
3690
|
+
template <typename T>
|
3691
|
+
bool MatchAndExplain(T* p,
|
3692
|
+
MatchResultListener* /* listener */) const {
|
3693
|
+
return p != NULL;
|
3694
|
+
}
|
3695
|
+
|
3696
|
+
// Describes the property of a value matching this matcher.
|
3697
|
+
void DescribeTo(std::ostream* os) const { *os << "is not NULL"; }
|
3698
|
+
|
3699
|
+
// Describes the property of a value NOT matching this matcher.
|
3700
|
+
void DescribeNegationTo(std::ostream* os) const { *os << "is NULL"; }
|
3701
|
+
};
|
3702
|
+
|
3703
|
+
// To construct a polymorphic matcher, pass an instance of the class
|
3704
|
+
// to MakePolymorphicMatcher(). Note the return type.
|
3705
|
+
PolymorphicMatcher<NotNullMatcher> NotNull() {
|
3706
|
+
return MakePolymorphicMatcher(NotNullMatcher());
|
3707
|
+
}
|
3708
|
+
|
3709
|
+
...
|
3710
|
+
|
3711
|
+
EXPECT_CALL(foo, Bar(NotNull())); // The argument must be a non-NULL pointer.
|
3712
|
+
```
|
3713
|
+
|
3714
|
+
**Note:** Your polymorphic matcher class does **not** need to inherit from
|
3715
|
+
`MatcherInterface` or any other class, and its methods do **not** need to be
|
3716
|
+
virtual.
|
3717
|
+
|
3718
|
+
Like in a monomorphic matcher, you may explain the match result by streaming
|
3719
|
+
additional information to the `listener` argument in `MatchAndExplain()`.
|
3720
|
+
|
3721
|
+
### Writing New Cardinalities
|
3722
|
+
|
3723
|
+
A cardinality is used in `Times()` to tell gMock how many times you expect a
|
3724
|
+
call to occur. It doesn't have to be exact. For example, you can say
|
3725
|
+
`AtLeast(5)` or `Between(2, 4)`.
|
3726
|
+
|
3727
|
+
If the [built-in set](cheat_sheet.md#CardinalityList) of cardinalities doesn't
|
3728
|
+
suit you, you are free to define your own by implementing the following
|
3729
|
+
interface (in namespace `testing`):
|
3730
|
+
|
3731
|
+
```cpp
|
3732
|
+
class CardinalityInterface {
|
3733
|
+
public:
|
3734
|
+
virtual ~CardinalityInterface();
|
3735
|
+
|
3736
|
+
// Returns true if and only if call_count calls will satisfy this cardinality.
|
3737
|
+
virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
|
3738
|
+
|
3739
|
+
// Returns true if and only if call_count calls will saturate this
|
3740
|
+
// cardinality.
|
3741
|
+
virtual bool IsSaturatedByCallCount(int call_count) const = 0;
|
3742
|
+
|
3743
|
+
// Describes self to an ostream.
|
3744
|
+
virtual void DescribeTo(std::ostream* os) const = 0;
|
3745
|
+
};
|
3746
|
+
```
|
3747
|
+
|
3748
|
+
For example, to specify that a call must occur even number of times, you can
|
3749
|
+
write
|
3750
|
+
|
3751
|
+
```cpp
|
3752
|
+
using ::testing::Cardinality;
|
3753
|
+
using ::testing::CardinalityInterface;
|
3754
|
+
using ::testing::MakeCardinality;
|
3755
|
+
|
3756
|
+
class EvenNumberCardinality : public CardinalityInterface {
|
3757
|
+
public:
|
3758
|
+
bool IsSatisfiedByCallCount(int call_count) const override {
|
3759
|
+
return (call_count % 2) == 0;
|
3760
|
+
}
|
3761
|
+
|
3762
|
+
bool IsSaturatedByCallCount(int call_count) const override {
|
3763
|
+
return false;
|
3764
|
+
}
|
3765
|
+
|
3766
|
+
void DescribeTo(std::ostream* os) const {
|
3767
|
+
*os << "called even number of times";
|
3768
|
+
}
|
3769
|
+
};
|
3770
|
+
|
3771
|
+
Cardinality EvenNumber() {
|
3772
|
+
return MakeCardinality(new EvenNumberCardinality);
|
3773
|
+
}
|
3774
|
+
|
3775
|
+
...
|
3776
|
+
EXPECT_CALL(foo, Bar(3))
|
3777
|
+
.Times(EvenNumber());
|
3778
|
+
```
|
3779
|
+
|
3780
|
+
### Writing New Actions Quickly {#QuickNewActions}
|
3781
|
+
|
3782
|
+
If the built-in actions don't work for you, you can easily define your own one.
|
3783
|
+
Just define a functor class with a (possibly templated) call operator, matching
|
3784
|
+
the signature of your action.
|
3785
|
+
|
3786
|
+
```cpp
|
3787
|
+
struct Increment {
|
3788
|
+
template <typename T>
|
3789
|
+
T operator()(T* arg) {
|
3790
|
+
return ++(*arg);
|
3791
|
+
}
|
3792
|
+
}
|
3793
|
+
```
|
3794
|
+
|
3795
|
+
The same approach works with stateful functors (or any callable, really):
|
3796
|
+
|
3797
|
+
```
|
3798
|
+
struct MultiplyBy {
|
3799
|
+
template <typename T>
|
3800
|
+
T operator()(T arg) { return arg * multiplier; }
|
3801
|
+
|
3802
|
+
int multiplier;
|
3803
|
+
}
|
3804
|
+
|
3805
|
+
// Then use:
|
3806
|
+
// EXPECT_CALL(...).WillOnce(MultiplyBy{7});
|
3807
|
+
```
|
3808
|
+
|
3809
|
+
#### Legacy macro-based Actions
|
3810
|
+
|
3811
|
+
Before C++11, the functor-based actions were not supported; the old way of
|
3812
|
+
writing actions was through a set of `ACTION*` macros. We suggest to avoid them
|
3813
|
+
in new code; they hide a lot of logic behind the macro, potentially leading to
|
3814
|
+
harder-to-understand compiler errors. Nevertheless, we cover them here for
|
3815
|
+
completeness.
|
3816
|
+
|
3817
|
+
By writing
|
3818
|
+
|
3819
|
+
```cpp
|
3820
|
+
ACTION(name) { statements; }
|
3821
|
+
```
|
3822
|
+
|
3823
|
+
in a namespace scope (i.e. not inside a class or function), you will define an
|
3824
|
+
action with the given name that executes the statements. The value returned by
|
3825
|
+
`statements` will be used as the return value of the action. Inside the
|
3826
|
+
statements, you can refer to the K-th (0-based) argument of the mock function as
|
3827
|
+
`argK`. For example:
|
3828
|
+
|
3829
|
+
```cpp
|
3830
|
+
ACTION(IncrementArg1) { return ++(*arg1); }
|
3831
|
+
```
|
3832
|
+
|
3833
|
+
allows you to write
|
3834
|
+
|
3835
|
+
```cpp
|
3836
|
+
... WillOnce(IncrementArg1());
|
3837
|
+
```
|
3838
|
+
|
3839
|
+
Note that you don't need to specify the types of the mock function arguments.
|
3840
|
+
Rest assured that your code is type-safe though: you'll get a compiler error if
|
3841
|
+
`*arg1` doesn't support the `++` operator, or if the type of `++(*arg1)` isn't
|
3842
|
+
compatible with the mock function's return type.
|
3843
|
+
|
3844
|
+
Another example:
|
3845
|
+
|
3846
|
+
```cpp
|
3847
|
+
ACTION(Foo) {
|
3848
|
+
(*arg2)(5);
|
3849
|
+
Blah();
|
3850
|
+
*arg1 = 0;
|
3851
|
+
return arg0;
|
3852
|
+
}
|
3853
|
+
```
|
3854
|
+
|
3855
|
+
defines an action `Foo()` that invokes argument #2 (a function pointer) with 5,
|
3856
|
+
calls function `Blah()`, sets the value pointed to by argument #1 to 0, and
|
3857
|
+
returns argument #0.
|
3858
|
+
|
3859
|
+
For more convenience and flexibility, you can also use the following pre-defined
|
3860
|
+
symbols in the body of `ACTION`:
|
3861
|
+
|
3862
|
+
`argK_type` | The type of the K-th (0-based) argument of the mock function
|
3863
|
+
:-------------- | :-----------------------------------------------------------
|
3864
|
+
`args` | All arguments of the mock function as a tuple
|
3865
|
+
`args_type` | The type of all arguments of the mock function as a tuple
|
3866
|
+
`return_type` | The return type of the mock function
|
3867
|
+
`function_type` | The type of the mock function
|
3868
|
+
|
3869
|
+
For example, when using an `ACTION` as a stub action for mock function:
|
3870
|
+
|
3871
|
+
```cpp
|
3872
|
+
int DoSomething(bool flag, int* ptr);
|
3873
|
+
```
|
3874
|
+
|
3875
|
+
we have:
|
3876
|
+
|
3877
|
+
Pre-defined Symbol | Is Bound To
|
3878
|
+
------------------ | ---------------------------------
|
3879
|
+
`arg0` | the value of `flag`
|
3880
|
+
`arg0_type` | the type `bool`
|
3881
|
+
`arg1` | the value of `ptr`
|
3882
|
+
`arg1_type` | the type `int*`
|
3883
|
+
`args` | the tuple `(flag, ptr)`
|
3884
|
+
`args_type` | the type `std::tuple<bool, int*>`
|
3885
|
+
`return_type` | the type `int`
|
3886
|
+
`function_type` | the type `int(bool, int*)`
|
3887
|
+
|
3888
|
+
#### Legacy macro-based parameterized Actions
|
3889
|
+
|
3890
|
+
Sometimes you'll want to parameterize an action you define. For that we have
|
3891
|
+
another macro
|
3892
|
+
|
3893
|
+
```cpp
|
3894
|
+
ACTION_P(name, param) { statements; }
|
3895
|
+
```
|
3896
|
+
|
3897
|
+
For example,
|
3898
|
+
|
3899
|
+
```cpp
|
3900
|
+
ACTION_P(Add, n) { return arg0 + n; }
|
3901
|
+
```
|
3902
|
+
|
3903
|
+
will allow you to write
|
3904
|
+
|
3905
|
+
```cpp
|
3906
|
+
// Returns argument #0 + 5.
|
3907
|
+
... WillOnce(Add(5));
|
3908
|
+
```
|
3909
|
+
|
3910
|
+
For convenience, we use the term *arguments* for the values used to invoke the
|
3911
|
+
mock function, and the term *parameters* for the values used to instantiate an
|
3912
|
+
action.
|
3913
|
+
|
3914
|
+
Note that you don't need to provide the type of the parameter either. Suppose
|
3915
|
+
the parameter is named `param`, you can also use the gMock-defined symbol
|
3916
|
+
`param_type` to refer to the type of the parameter as inferred by the compiler.
|
3917
|
+
For example, in the body of `ACTION_P(Add, n)` above, you can write `n_type` for
|
3918
|
+
the type of `n`.
|
3919
|
+
|
3920
|
+
gMock also provides `ACTION_P2`, `ACTION_P3`, and etc to support multi-parameter
|
3921
|
+
actions. For example,
|
3922
|
+
|
3923
|
+
```cpp
|
3924
|
+
ACTION_P2(ReturnDistanceTo, x, y) {
|
3925
|
+
double dx = arg0 - x;
|
3926
|
+
double dy = arg1 - y;
|
3927
|
+
return sqrt(dx*dx + dy*dy);
|
3928
|
+
}
|
3929
|
+
```
|
3930
|
+
|
3931
|
+
lets you write
|
3932
|
+
|
3933
|
+
```cpp
|
3934
|
+
... WillOnce(ReturnDistanceTo(5.0, 26.5));
|
3935
|
+
```
|
3936
|
+
|
3937
|
+
You can view `ACTION` as a degenerated parameterized action where the number of
|
3938
|
+
parameters is 0.
|
3939
|
+
|
3940
|
+
You can also easily define actions overloaded on the number of parameters:
|
3941
|
+
|
3942
|
+
```cpp
|
3943
|
+
ACTION_P(Plus, a) { ... }
|
3944
|
+
ACTION_P2(Plus, a, b) { ... }
|
3945
|
+
```
|
3946
|
+
|
3947
|
+
### Restricting the Type of an Argument or Parameter in an ACTION
|
3948
|
+
|
3949
|
+
For maximum brevity and reusability, the `ACTION*` macros don't ask you to
|
3950
|
+
provide the types of the mock function arguments and the action parameters.
|
3951
|
+
Instead, we let the compiler infer the types for us.
|
3952
|
+
|
3953
|
+
Sometimes, however, we may want to be more explicit about the types. There are
|
3954
|
+
several tricks to do that. For example:
|
3955
|
+
|
3956
|
+
```cpp
|
3957
|
+
ACTION(Foo) {
|
3958
|
+
// Makes sure arg0 can be converted to int.
|
3959
|
+
int n = arg0;
|
3960
|
+
... use n instead of arg0 here ...
|
3961
|
+
}
|
3962
|
+
|
3963
|
+
ACTION_P(Bar, param) {
|
3964
|
+
// Makes sure the type of arg1 is const char*.
|
3965
|
+
::testing::StaticAssertTypeEq<const char*, arg1_type>();
|
3966
|
+
|
3967
|
+
// Makes sure param can be converted to bool.
|
3968
|
+
bool flag = param;
|
3969
|
+
}
|
3970
|
+
```
|
3971
|
+
|
3972
|
+
where `StaticAssertTypeEq` is a compile-time assertion in googletest that
|
3973
|
+
verifies two types are the same.
|
3974
|
+
|
3975
|
+
### Writing New Action Templates Quickly
|
3976
|
+
|
3977
|
+
Sometimes you want to give an action explicit template parameters that cannot be
|
3978
|
+
inferred from its value parameters. `ACTION_TEMPLATE()` supports that and can be
|
3979
|
+
viewed as an extension to `ACTION()` and `ACTION_P*()`.
|
3980
|
+
|
3981
|
+
The syntax:
|
3982
|
+
|
3983
|
+
```cpp
|
3984
|
+
ACTION_TEMPLATE(ActionName,
|
3985
|
+
HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),
|
3986
|
+
AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }
|
3987
|
+
```
|
3988
|
+
|
3989
|
+
defines an action template that takes *m* explicit template parameters and *n*
|
3990
|
+
value parameters, where *m* is in [1, 10] and *n* is in [0, 10]. `name_i` is the
|
3991
|
+
name of the *i*-th template parameter, and `kind_i` specifies whether it's a
|
3992
|
+
`typename`, an integral constant, or a template. `p_i` is the name of the *i*-th
|
3993
|
+
value parameter.
|
3994
|
+
|
3995
|
+
Example:
|
3996
|
+
|
3997
|
+
```cpp
|
3998
|
+
// DuplicateArg<k, T>(output) converts the k-th argument of the mock
|
3999
|
+
// function to type T and copies it to *output.
|
4000
|
+
ACTION_TEMPLATE(DuplicateArg,
|
4001
|
+
// Note the comma between int and k:
|
4002
|
+
HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
|
4003
|
+
AND_1_VALUE_PARAMS(output)) {
|
4004
|
+
*output = T(std::get<k>(args));
|
4005
|
+
}
|
4006
|
+
```
|
4007
|
+
|
4008
|
+
To create an instance of an action template, write:
|
4009
|
+
|
4010
|
+
```cpp
|
4011
|
+
ActionName<t1, ..., t_m>(v1, ..., v_n)
|
4012
|
+
```
|
4013
|
+
|
4014
|
+
where the `t`s are the template arguments and the `v`s are the value arguments.
|
4015
|
+
The value argument types are inferred by the compiler. For example:
|
4016
|
+
|
4017
|
+
```cpp
|
4018
|
+
using ::testing::_;
|
4019
|
+
...
|
4020
|
+
int n;
|
4021
|
+
EXPECT_CALL(mock, Foo).WillOnce(DuplicateArg<1, unsigned char>(&n));
|
4022
|
+
```
|
4023
|
+
|
4024
|
+
If you want to explicitly specify the value argument types, you can provide
|
4025
|
+
additional template arguments:
|
4026
|
+
|
4027
|
+
```cpp
|
4028
|
+
ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)
|
4029
|
+
```
|
4030
|
+
|
4031
|
+
where `u_i` is the desired type of `v_i`.
|
4032
|
+
|
4033
|
+
`ACTION_TEMPLATE` and `ACTION`/`ACTION_P*` can be overloaded on the number of
|
4034
|
+
value parameters, but not on the number of template parameters. Without the
|
4035
|
+
restriction, the meaning of the following is unclear:
|
4036
|
+
|
4037
|
+
```cpp
|
4038
|
+
OverloadedAction<int, bool>(x);
|
4039
|
+
```
|
4040
|
+
|
4041
|
+
Are we using a single-template-parameter action where `bool` refers to the type
|
4042
|
+
of `x`, or a two-template-parameter action where the compiler is asked to infer
|
4043
|
+
the type of `x`?
|
4044
|
+
|
4045
|
+
### Using the ACTION Object's Type
|
4046
|
+
|
4047
|
+
If you are writing a function that returns an `ACTION` object, you'll need to
|
4048
|
+
know its type. The type depends on the macro used to define the action and the
|
4049
|
+
parameter types. The rule is relatively simple:
|
4050
|
+
|
4051
|
+
| Given Definition | Expression | Has Type |
|
4052
|
+
| ----------------------------- | ------------------- | --------------------- |
|
4053
|
+
| `ACTION(Foo)` | `Foo()` | `FooAction` |
|
4054
|
+
| `ACTION_TEMPLATE(Foo,` | `Foo<t1, ..., | `FooAction<t1, ..., |
|
4055
|
+
: `HAS_m_TEMPLATE_PARAMS(...),` : t_m>()` : t_m>` :
|
4056
|
+
: `AND_0_VALUE_PARAMS())` : : :
|
4057
|
+
| `ACTION_P(Bar, param)` | `Bar(int_value)` | `BarActionP<int>` |
|
4058
|
+
| `ACTION_TEMPLATE(Bar,` | `Bar<t1, ..., t_m>` | `FooActionP<t1, ..., |
|
4059
|
+
: `HAS_m_TEMPLATE_PARAMS(...),` : `(int_value)` : t_m, int>` :
|
4060
|
+
: `AND_1_VALUE_PARAMS(p1))` : : :
|
4061
|
+
| `ACTION_P2(Baz, p1, p2)` | `Baz(bool_value,` | `BazActionP2<bool, |
|
4062
|
+
: : `int_value)` : int>` :
|
4063
|
+
| `ACTION_TEMPLATE(Baz,` | `Baz<t1, ..., t_m>` | `FooActionP2<t1, ..., |
|
4064
|
+
: `HAS_m_TEMPLATE_PARAMS(...),` : `(bool_value,` : t_m,` `bool, int>` :
|
4065
|
+
: `AND_2_VALUE_PARAMS(p1, p2))` : `int_value)` : :
|
4066
|
+
| ... | ... | ... |
|
4067
|
+
|
4068
|
+
Note that we have to pick different suffixes (`Action`, `ActionP`, `ActionP2`,
|
4069
|
+
and etc) for actions with different numbers of value parameters, or the action
|
4070
|
+
definitions cannot be overloaded on the number of them.
|
4071
|
+
|
4072
|
+
### Writing New Monomorphic Actions {#NewMonoActions}
|
4073
|
+
|
4074
|
+
While the `ACTION*` macros are very convenient, sometimes they are
|
4075
|
+
inappropriate. For example, despite the tricks shown in the previous recipes,
|
4076
|
+
they don't let you directly specify the types of the mock function arguments and
|
4077
|
+
the action parameters, which in general leads to unoptimized compiler error
|
4078
|
+
messages that can baffle unfamiliar users. They also don't allow overloading
|
4079
|
+
actions based on parameter types without jumping through some hoops.
|
4080
|
+
|
4081
|
+
An alternative to the `ACTION*` macros is to implement
|
4082
|
+
`::testing::ActionInterface<F>`, where `F` is the type of the mock function in
|
4083
|
+
which the action will be used. For example:
|
4084
|
+
|
4085
|
+
```cpp
|
4086
|
+
template <typename F>
|
4087
|
+
class ActionInterface {
|
4088
|
+
public:
|
4089
|
+
virtual ~ActionInterface();
|
4090
|
+
|
4091
|
+
// Performs the action. Result is the return type of function type
|
4092
|
+
// F, and ArgumentTuple is the tuple of arguments of F.
|
4093
|
+
//
|
4094
|
+
|
4095
|
+
// For example, if F is int(bool, const string&), then Result would
|
4096
|
+
// be int, and ArgumentTuple would be std::tuple<bool, const string&>.
|
4097
|
+
virtual Result Perform(const ArgumentTuple& args) = 0;
|
4098
|
+
};
|
4099
|
+
```
|
4100
|
+
|
4101
|
+
```cpp
|
4102
|
+
using ::testing::_;
|
4103
|
+
using ::testing::Action;
|
4104
|
+
using ::testing::ActionInterface;
|
4105
|
+
using ::testing::MakeAction;
|
4106
|
+
|
4107
|
+
typedef int IncrementMethod(int*);
|
4108
|
+
|
4109
|
+
class IncrementArgumentAction : public ActionInterface<IncrementMethod> {
|
4110
|
+
public:
|
4111
|
+
int Perform(const std::tuple<int*>& args) override {
|
4112
|
+
int* p = std::get<0>(args); // Grabs the first argument.
|
4113
|
+
return *p++;
|
4114
|
+
}
|
4115
|
+
};
|
4116
|
+
|
4117
|
+
Action<IncrementMethod> IncrementArgument() {
|
4118
|
+
return MakeAction(new IncrementArgumentAction);
|
4119
|
+
}
|
4120
|
+
|
4121
|
+
...
|
4122
|
+
EXPECT_CALL(foo, Baz(_))
|
4123
|
+
.WillOnce(IncrementArgument());
|
4124
|
+
|
4125
|
+
int n = 5;
|
4126
|
+
foo.Baz(&n); // Should return 5 and change n to 6.
|
4127
|
+
```
|
4128
|
+
|
4129
|
+
### Writing New Polymorphic Actions {#NewPolyActions}
|
4130
|
+
|
4131
|
+
The previous recipe showed you how to define your own action. This is all good,
|
4132
|
+
except that you need to know the type of the function in which the action will
|
4133
|
+
be used. Sometimes that can be a problem. For example, if you want to use the
|
4134
|
+
action in functions with *different* types (e.g. like `Return()` and
|
4135
|
+
`SetArgPointee()`).
|
4136
|
+
|
4137
|
+
If an action can be used in several types of mock functions, we say it's
|
4138
|
+
*polymorphic*. The `MakePolymorphicAction()` function template makes it easy to
|
4139
|
+
define such an action:
|
4140
|
+
|
4141
|
+
```cpp
|
4142
|
+
namespace testing {
|
4143
|
+
template <typename Impl>
|
4144
|
+
PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl);
|
4145
|
+
} // namespace testing
|
4146
|
+
```
|
4147
|
+
|
4148
|
+
As an example, let's define an action that returns the second argument in the
|
4149
|
+
mock function's argument list. The first step is to define an implementation
|
4150
|
+
class:
|
4151
|
+
|
4152
|
+
```cpp
|
4153
|
+
class ReturnSecondArgumentAction {
|
4154
|
+
public:
|
4155
|
+
template <typename Result, typename ArgumentTuple>
|
4156
|
+
Result Perform(const ArgumentTuple& args) const {
|
4157
|
+
// To get the i-th (0-based) argument, use std::get(args).
|
4158
|
+
return std::get<1>(args);
|
4159
|
+
}
|
4160
|
+
};
|
4161
|
+
```
|
4162
|
+
|
4163
|
+
This implementation class does *not* need to inherit from any particular class.
|
4164
|
+
What matters is that it must have a `Perform()` method template. This method
|
4165
|
+
template takes the mock function's arguments as a tuple in a **single**
|
4166
|
+
argument, and returns the result of the action. It can be either `const` or not,
|
4167
|
+
but must be invokable with exactly one template argument, which is the result
|
4168
|
+
type. In other words, you must be able to call `Perform<R>(args)` where `R` is
|
4169
|
+
the mock function's return type and `args` is its arguments in a tuple.
|
4170
|
+
|
4171
|
+
Next, we use `MakePolymorphicAction()` to turn an instance of the implementation
|
4172
|
+
class into the polymorphic action we need. It will be convenient to have a
|
4173
|
+
wrapper for this:
|
4174
|
+
|
4175
|
+
```cpp
|
4176
|
+
using ::testing::MakePolymorphicAction;
|
4177
|
+
using ::testing::PolymorphicAction;
|
4178
|
+
|
4179
|
+
PolymorphicAction<ReturnSecondArgumentAction> ReturnSecondArgument() {
|
4180
|
+
return MakePolymorphicAction(ReturnSecondArgumentAction());
|
4181
|
+
}
|
4182
|
+
```
|
4183
|
+
|
4184
|
+
Now, you can use this polymorphic action the same way you use the built-in ones:
|
4185
|
+
|
4186
|
+
```cpp
|
4187
|
+
using ::testing::_;
|
4188
|
+
|
4189
|
+
class MockFoo : public Foo {
|
4190
|
+
public:
|
4191
|
+
MOCK_METHOD(int, DoThis, (bool flag, int n), (override));
|
4192
|
+
MOCK_METHOD(string, DoThat, (int x, const char* str1, const char* str2),
|
4193
|
+
(override));
|
4194
|
+
};
|
4195
|
+
|
4196
|
+
...
|
4197
|
+
MockFoo foo;
|
4198
|
+
EXPECT_CALL(foo, DoThis).WillOnce(ReturnSecondArgument());
|
4199
|
+
EXPECT_CALL(foo, DoThat).WillOnce(ReturnSecondArgument());
|
4200
|
+
...
|
4201
|
+
foo.DoThis(true, 5); // Will return 5.
|
4202
|
+
foo.DoThat(1, "Hi", "Bye"); // Will return "Hi".
|
4203
|
+
```
|
4204
|
+
|
4205
|
+
### Teaching gMock How to Print Your Values
|
4206
|
+
|
4207
|
+
When an uninteresting or unexpected call occurs, gMock prints the argument
|
4208
|
+
values and the stack trace to help you debug. Assertion macros like
|
4209
|
+
`EXPECT_THAT` and `EXPECT_EQ` also print the values in question when the
|
4210
|
+
assertion fails. gMock and googletest do this using googletest's user-extensible
|
4211
|
+
value printer.
|
4212
|
+
|
4213
|
+
This printer knows how to print built-in C++ types, native arrays, STL
|
4214
|
+
containers, and any type that supports the `<<` operator. For other types, it
|
4215
|
+
prints the raw bytes in the value and hopes that you the user can figure it out.
|
4216
|
+
[googletest's advanced guide](../../googletest/docs/advanced.md#teaching-googletest-how-to-print-your-values)
|
4217
|
+
explains how to extend the printer to do a better job at printing your
|
4218
|
+
particular type than to dump the bytes.
|
4219
|
+
|
4220
|
+
## Useful Mocks Created Using gMock
|
4221
|
+
|
4222
|
+
<!--#include file="includes/g3_testing_LOGs.md"-->
|
4223
|
+
<!--#include file="includes/g3_mock_callbacks.md"-->
|
4224
|
+
|
4225
|
+
### Mock std::function {#MockFunction}
|
4226
|
+
|
4227
|
+
`std::function` is a general function type introduced in C++11. It is a
|
4228
|
+
preferred way of passing callbacks to new interfaces. Functions are copiable,
|
4229
|
+
and are not usually passed around by pointer, which makes them tricky to mock.
|
4230
|
+
But fear not - `MockFunction` can help you with that.
|
4231
|
+
|
4232
|
+
`MockFunction<R(T1, ..., Tn)>` has a mock method `Call()` with the signature:
|
4233
|
+
|
4234
|
+
```cpp
|
4235
|
+
R Call(T1, ..., Tn);
|
4236
|
+
```
|
4237
|
+
|
4238
|
+
It also has a `AsStdFunction()` method, which creates a `std::function` proxy
|
4239
|
+
forwarding to Call:
|
4240
|
+
|
4241
|
+
```cpp
|
4242
|
+
std::function<R(T1, ..., Tn)> AsStdFunction();
|
4243
|
+
```
|
4244
|
+
|
4245
|
+
To use `MockFunction`, first create `MockFunction` object and set up
|
4246
|
+
expectations on its `Call` method. Then pass proxy obtained from
|
4247
|
+
`AsStdFunction()` to the code you are testing. For example:
|
4248
|
+
|
4249
|
+
```cpp
|
4250
|
+
TEST(FooTest, RunsCallbackWithBarArgument) {
|
4251
|
+
// 1. Create a mock object.
|
4252
|
+
MockFunction<int(string)> mock_function;
|
4253
|
+
|
4254
|
+
// 2. Set expectations on Call() method.
|
4255
|
+
EXPECT_CALL(mock_function, Call("bar")).WillOnce(Return(1));
|
4256
|
+
|
4257
|
+
// 3. Exercise code that uses std::function.
|
4258
|
+
Foo(mock_function.AsStdFunction());
|
4259
|
+
// Foo's signature can be either of:
|
4260
|
+
// void Foo(const std::function<int(string)>& fun);
|
4261
|
+
// void Foo(std::function<int(string)> fun);
|
4262
|
+
|
4263
|
+
// 4. All expectations will be verified when mock_function
|
4264
|
+
// goes out of scope and is destroyed.
|
4265
|
+
}
|
4266
|
+
```
|
4267
|
+
|
4268
|
+
Remember that function objects created with `AsStdFunction()` are just
|
4269
|
+
forwarders. If you create multiple of them, they will share the same set of
|
4270
|
+
expectations.
|
4271
|
+
|
4272
|
+
Although `std::function` supports unlimited number of arguments, `MockFunction`
|
4273
|
+
implementation is limited to ten. If you ever hit that limit... well, your
|
4274
|
+
callback has bigger problems than being mockable. :-)
|
4275
|
+
|
4276
|
+
<!-- GOOGLETEST_CM0034 DO NOT DELETE -->
|