File indexing completed on 2025-08-06 08:19:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include "gmock/internal/gmock-generated-internal-utils.h"
0037 #include "gmock/internal/gmock-internal-utils.h"
0038 #include "gtest/gtest.h"
0039
0040 namespace {
0041
0042 using ::testing::tuple;
0043 using ::testing::Matcher;
0044 using ::testing::internal::CompileAssertTypesEqual;
0045 using ::testing::internal::MatcherTuple;
0046 using ::testing::internal::Function;
0047 using ::testing::internal::IgnoredValue;
0048
0049
0050
0051 TEST(MatcherTupleTest, ForSize0) {
0052 CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();
0053 }
0054
0055 TEST(MatcherTupleTest, ForSize1) {
0056 CompileAssertTypesEqual<tuple<Matcher<int> >,
0057 MatcherTuple<tuple<int> >::type>();
0058 }
0059
0060 TEST(MatcherTupleTest, ForSize2) {
0061 CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,
0062 MatcherTuple<tuple<int, char> >::type>();
0063 }
0064
0065 TEST(MatcherTupleTest, ForSize5) {
0066 CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
0067 Matcher<double>, Matcher<char*> >,
0068 MatcherTuple<tuple<int, char, bool, double, char*>
0069 >::type>();
0070 }
0071
0072
0073
0074 TEST(FunctionTest, Nullary) {
0075 typedef Function<int()> F;
0076 CompileAssertTypesEqual<int, F::Result>();
0077 CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();
0078 CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();
0079 CompileAssertTypesEqual<void(), F::MakeResultVoid>();
0080 CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();
0081 }
0082
0083 TEST(FunctionTest, Unary) {
0084 typedef Function<int(bool)> F;
0085 CompileAssertTypesEqual<int, F::Result>();
0086 CompileAssertTypesEqual<bool, F::Argument1>();
0087 CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();
0088 CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();
0089 CompileAssertTypesEqual<void(bool), F::MakeResultVoid>();
0090 CompileAssertTypesEqual<IgnoredValue(bool),
0091 F::MakeResultIgnoredValue>();
0092 }
0093
0094 TEST(FunctionTest, Binary) {
0095 typedef Function<int(bool, const long&)> F;
0096 CompileAssertTypesEqual<int, F::Result>();
0097 CompileAssertTypesEqual<bool, F::Argument1>();
0098 CompileAssertTypesEqual<const long&, F::Argument2>();
0099 CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>();
0100 CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<const long&> >,
0101 F::ArgumentMatcherTuple>();
0102 CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>();
0103 CompileAssertTypesEqual<IgnoredValue(bool, const long&),
0104 F::MakeResultIgnoredValue>();
0105 }
0106
0107 TEST(FunctionTest, LongArgumentList) {
0108 typedef Function<char(bool, int, char*, int&, const long&)> F;
0109 CompileAssertTypesEqual<char, F::Result>();
0110 CompileAssertTypesEqual<bool, F::Argument1>();
0111 CompileAssertTypesEqual<int, F::Argument2>();
0112 CompileAssertTypesEqual<char*, F::Argument3>();
0113 CompileAssertTypesEqual<int&, F::Argument4>();
0114 CompileAssertTypesEqual<const long&, F::Argument5>();
0115 CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>,
0116 F::ArgumentTuple>();
0117 CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<int>, Matcher<char*>,
0118 Matcher<int&>, Matcher<const long&> >,
0119 F::ArgumentMatcherTuple>();
0120 CompileAssertTypesEqual<void(bool, int, char*, int&, const long&),
0121 F::MakeResultVoid>();
0122 CompileAssertTypesEqual<
0123 IgnoredValue(bool, int, char*, int&, const long&),
0124 F::MakeResultIgnoredValue>();
0125 }
0126
0127 }