00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "gmock/internal/gmock-generated-internal-utils.h"
00037 #include "gmock/internal/gmock-internal-utils.h"
00038 #include "gtest/gtest.h"
00039
00040 namespace {
00041
00042 using ::std::tr1::tuple;
00043 using ::testing::Matcher;
00044 using ::testing::internal::CompileAssertTypesEqual;
00045 using ::testing::internal::MatcherTuple;
00046 using ::testing::internal::Function;
00047 using ::testing::internal::IgnoredValue;
00048
00049
00050
00051 TEST(MatcherTupleTest, ForSize0) {
00052 CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();
00053 }
00054
00055 TEST(MatcherTupleTest, ForSize1) {
00056 CompileAssertTypesEqual<tuple<Matcher<int> >,
00057 MatcherTuple<tuple<int> >::type>();
00058 }
00059
00060 TEST(MatcherTupleTest, ForSize2) {
00061 CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,
00062 MatcherTuple<tuple<int, char> >::type>();
00063 }
00064
00065 TEST(MatcherTupleTest, ForSize5) {
00066 CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
00067 Matcher<double>, Matcher<char*> >,
00068 MatcherTuple<tuple<int, char, bool, double, char*>
00069 >::type>();
00070 }
00071
00072
00073
00074 TEST(FunctionTest, Nullary) {
00075 typedef Function<int()> F;
00076 CompileAssertTypesEqual<int, F::Result>();
00077 CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();
00078 CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();
00079 CompileAssertTypesEqual<void(), F::MakeResultVoid>();
00080 CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();
00081 }
00082
00083 TEST(FunctionTest, Unary) {
00084 typedef Function<int(bool)> F;
00085 CompileAssertTypesEqual<int, F::Result>();
00086 CompileAssertTypesEqual<bool, F::Argument1>();
00087 CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();
00088 CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();
00089 CompileAssertTypesEqual<void(bool), F::MakeResultVoid>();
00090 CompileAssertTypesEqual<IgnoredValue(bool),
00091 F::MakeResultIgnoredValue>();
00092 }
00093
00094 TEST(FunctionTest, Binary) {
00095 typedef Function<int(bool, const long&)> F;
00096 CompileAssertTypesEqual<int, F::Result>();
00097 CompileAssertTypesEqual<bool, F::Argument1>();
00098 CompileAssertTypesEqual<const long&, F::Argument2>();
00099 CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>();
00100 CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<const long&> >,
00101 F::ArgumentMatcherTuple>();
00102 CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>();
00103 CompileAssertTypesEqual<IgnoredValue(bool, const long&),
00104 F::MakeResultIgnoredValue>();
00105 }
00106
00107 TEST(FunctionTest, LongArgumentList) {
00108 typedef Function<char(bool, int, char*, int&, const long&)> F;
00109 CompileAssertTypesEqual<char, F::Result>();
00110 CompileAssertTypesEqual<bool, F::Argument1>();
00111 CompileAssertTypesEqual<int, F::Argument2>();
00112 CompileAssertTypesEqual<char*, F::Argument3>();
00113 CompileAssertTypesEqual<int&, F::Argument4>();
00114 CompileAssertTypesEqual<const long&, F::Argument5>();
00115 CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>,
00116 F::ArgumentTuple>();
00117 CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<int>, Matcher<char*>,
00118 Matcher<int&>, Matcher<const long&> >,
00119 F::ArgumentMatcherTuple>();
00120 CompileAssertTypesEqual<void(bool, int, char*, int&, const long&),
00121 F::MakeResultVoid>();
00122 CompileAssertTypesEqual<
00123 IgnoredValue(bool, int, char*, int&, const long&),
00124 F::MakeResultIgnoredValue>();
00125 }
00126
00127 }