Add first version
[ric-plt/sdl.git] / 3rdparty / googletest / googlemock / test / gmock-generated-internal-utils_test.cc
1 // Copyright 2007, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
31 // Google Mock - a framework for writing C++ mock classes.
32 //
33 // This file tests the internal utilities.
34
35 #include "gmock/internal/gmock-generated-internal-utils.h"
36 #include "gmock/internal/gmock-internal-utils.h"
37 #include "gtest/gtest.h"
38
39 namespace {
40
41 using ::testing::tuple;
42 using ::testing::Matcher;
43 using ::testing::internal::CompileAssertTypesEqual;
44 using ::testing::internal::MatcherTuple;
45 using ::testing::internal::Function;
46 using ::testing::internal::IgnoredValue;
47
48 // Tests the MatcherTuple template struct.
49
50 TEST(MatcherTupleTest, ForSize0) {
51   CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();
52 }
53
54 TEST(MatcherTupleTest, ForSize1) {
55   CompileAssertTypesEqual<tuple<Matcher<int> >,
56                           MatcherTuple<tuple<int> >::type>();
57 }
58
59 TEST(MatcherTupleTest, ForSize2) {
60   CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,
61                           MatcherTuple<tuple<int, char> >::type>();
62 }
63
64 TEST(MatcherTupleTest, ForSize5) {
65   CompileAssertTypesEqual<
66       tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<double>,
67             Matcher<char*> >,
68       MatcherTuple<tuple<int, char, bool, double, char*> >::type>();
69 }
70
71 // Tests the Function template struct.
72
73 TEST(FunctionTest, Nullary) {
74   typedef Function<int()> F;  // NOLINT
75   CompileAssertTypesEqual<int, F::Result>();
76   CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();
77   CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();
78   CompileAssertTypesEqual<void(), F::MakeResultVoid>();
79   CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();
80 }
81
82 TEST(FunctionTest, Unary) {
83   typedef Function<int(bool)> F;  // NOLINT
84   CompileAssertTypesEqual<int, F::Result>();
85   CompileAssertTypesEqual<bool, F::Argument1>();
86   CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();
87   CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();
88   CompileAssertTypesEqual<void(bool), F::MakeResultVoid>();  // NOLINT
89   CompileAssertTypesEqual<IgnoredValue(bool),  // NOLINT
90       F::MakeResultIgnoredValue>();
91 }
92
93 TEST(FunctionTest, Binary) {
94   typedef Function<int(bool, const long&)> F;  // NOLINT
95   CompileAssertTypesEqual<int, F::Result>();
96   CompileAssertTypesEqual<bool, F::Argument1>();
97   CompileAssertTypesEqual<const long&, F::Argument2>();  // NOLINT
98   CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>();  // NOLINT
99   CompileAssertTypesEqual<
100       tuple<Matcher<bool>, Matcher<const long&> >,  // NOLINT
101       F::ArgumentMatcherTuple>();
102   CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>();  // NOLINT
103   CompileAssertTypesEqual<IgnoredValue(bool, const long&),  // NOLINT
104       F::MakeResultIgnoredValue>();
105 }
106
107 TEST(FunctionTest, LongArgumentList) {
108   typedef Function<char(bool, int, char*, int&, const long&)> F;  // NOLINT
109   CompileAssertTypesEqual<char, F::Result>();
110   CompileAssertTypesEqual<bool, F::Argument1>();
111   CompileAssertTypesEqual<int, F::Argument2>();
112   CompileAssertTypesEqual<char*, F::Argument3>();
113   CompileAssertTypesEqual<int&, F::Argument4>();
114   CompileAssertTypesEqual<const long&, F::Argument5>();  // NOLINT
115   CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>,  // NOLINT
116                           F::ArgumentTuple>();
117   CompileAssertTypesEqual<
118       tuple<Matcher<bool>, Matcher<int>, Matcher<char*>, Matcher<int&>,
119             Matcher<const long&> >,  // NOLINT
120       F::ArgumentMatcherTuple>();
121   CompileAssertTypesEqual<void(bool, int, char*, int&, const long&),  // NOLINT
122                           F::MakeResultVoid>();
123   CompileAssertTypesEqual<
124       IgnoredValue(bool, int, char*, int&, const long&),  // NOLINT
125       F::MakeResultIgnoredValue>();
126 }
127
128 }  // Unnamed namespace