4f6609129a
Fix std::move to std::forward where appropriate to support reference types. PiperOrigin-RevId: 292923058
125 lines
4.8 KiB
C++
125 lines
4.8 KiB
C++
$$ -*- mode: c++; -*-
|
|
$$ This is a Pump source file. Please use Pump to convert
|
|
$$ it to gmock-generated-matchers.h.
|
|
$$
|
|
$var n = 10 $$ The maximum arity we support.
|
|
$$ }} This line fixes auto-indentation of the following code in Emacs.
|
|
// Copyright 2008, Google Inc.
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without
|
|
// modification, are permitted provided that the following conditions are
|
|
// met:
|
|
//
|
|
// * Redistributions of source code must retain the above copyright
|
|
// notice, this list of conditions and the following disclaimer.
|
|
// * Redistributions in binary form must reproduce the above
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
// in the documentation and/or other materials provided with the
|
|
// distribution.
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
// contributors may be used to endorse or promote products derived from
|
|
// this software without specific prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
// Google Mock - a framework for writing C++ mock classes.
|
|
//
|
|
// This file implements some commonly used variadic matchers.
|
|
|
|
// GOOGLETEST_CM0002 DO NOT DELETE
|
|
|
|
#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
|
#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|
|
|
|
#include <iterator>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include "gmock/gmock-matchers.h"
|
|
|
|
$range i 0..n
|
|
$for i
|
|
|
|
[[
|
|
$var macro_name = [[$if i==0 [[GMOCK_INTERNAL_MATCHER]] $elif i==1 [[GMOCK_INTERNAL_MATCHER_P]]
|
|
$else [[GMOCK_INTERNAL_MATCHER_P$i]]]]
|
|
$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]]
|
|
$else [[P$i]]]]]]
|
|
$range j 0..i-1
|
|
$var template = [[$if i==0 [[]] $else [[
|
|
|
|
template <$for j, [[typename p$j##_type]]>\
|
|
]]]]
|
|
$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]
|
|
$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(::std::forward<p$j##_type>(gmock_p$j))]]]]]]
|
|
$var params = [[$for j, [[p$j]]]]
|
|
$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]
|
|
$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]
|
|
$var param_field_decls = [[$for j
|
|
[[
|
|
|
|
p$j##_type const p$j;\
|
|
]]]]
|
|
$var param_field_decls2 = [[$for j
|
|
[[
|
|
|
|
p$j##_type const p$j;\
|
|
]]]]
|
|
|
|
#define $macro_name(name, description$for j [[, p$j]])\$template
|
|
class $class_name : public ::testing::internal::MatcherBaseImpl<$class_name$param_types> {\
|
|
public:\
|
|
using $class_name::MatcherBaseImpl::MatcherBaseImpl;\
|
|
template <typename arg_type>\
|
|
class gmock_Impl : public ::testing::MatcherInterface<\
|
|
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
|
|
public:\
|
|
[[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\
|
|
$impl_inits {}\
|
|
bool MatchAndExplain(\
|
|
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
|
|
::testing::MatchResultListener* result_listener) const override;\
|
|
void DescribeTo(::std::ostream* gmock_os) const override {\
|
|
*gmock_os << FormatDescription(false);\
|
|
}\
|
|
void DescribeNegationTo(::std::ostream* gmock_os) const override {\
|
|
*gmock_os << FormatDescription(true);\
|
|
}\$param_field_decls
|
|
private:\
|
|
::std::string FormatDescription(bool negation) const {\
|
|
::std::string gmock_description = (description);\
|
|
if (!gmock_description.empty()) {\
|
|
return gmock_description;\
|
|
}\
|
|
return ::testing::internal::FormatMatcherDescription(\
|
|
negation, #name, \
|
|
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
|
|
::std::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
|
|
}\
|
|
};\
|
|
};\$template
|
|
inline $class_name$param_types name($param_types_and_names) {\
|
|
return $class_name$param_types($params);\
|
|
}\$template
|
|
template <typename arg_type>\
|
|
bool $class_name$param_types::gmock_Impl<arg_type>::MatchAndExplain(\
|
|
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
|
|
::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\
|
|
const
|
|
]]
|
|
|
|
|
|
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_
|