Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:19:55

0001 // Copyright 2007, Google Inc.
0002 // All rights reserved.
0003 //
0004 // Redistribution and use in source and binary forms, with or without
0005 // modification, are permitted provided that the following conditions are
0006 // met:
0007 //
0008 //     * Redistributions of source code must retain the above copyright
0009 // notice, this list of conditions and the following disclaimer.
0010 //     * Redistributions in binary form must reproduce the above
0011 // copyright notice, this list of conditions and the following disclaimer
0012 // in the documentation and/or other materials provided with the
0013 // distribution.
0014 //     * Neither the name of Google Inc. nor the names of its
0015 // contributors may be used to endorse or promote products derived from
0016 // this software without specific prior written permission.
0017 //
0018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0029 //
0030 // Author: wan@google.com (Zhanyong Wan)
0031 
0032 // Google Mock - a framework for writing C++ mock classes.
0033 //
0034 // This file tests the internal utilities.
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 // Tests the MatcherTuple template struct.
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 // Tests the Function template struct.
0073 
0074 TEST(FunctionTest, Nullary) {
0075   typedef Function<int()> F;  // NOLINT
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;  // NOLINT
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>();  // NOLINT
0090   CompileAssertTypesEqual<IgnoredValue(bool),  // NOLINT
0091       F::MakeResultIgnoredValue>();
0092 }
0093 
0094 TEST(FunctionTest, Binary) {
0095   typedef Function<int(bool, const long&)> F;  // NOLINT
0096   CompileAssertTypesEqual<int, F::Result>();
0097   CompileAssertTypesEqual<bool, F::Argument1>();
0098   CompileAssertTypesEqual<const long&, F::Argument2>();  // NOLINT
0099   CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>();  // NOLINT
0100   CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<const long&> >,  // NOLINT
0101                           F::ArgumentMatcherTuple>();
0102   CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>();  // NOLINT
0103   CompileAssertTypesEqual<IgnoredValue(bool, const long&),  // NOLINT
0104       F::MakeResultIgnoredValue>();
0105 }
0106 
0107 TEST(FunctionTest, LongArgumentList) {
0108   typedef Function<char(bool, int, char*, int&, const long&)> F;  // NOLINT
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>();  // NOLINT
0115   CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>,  // NOLINT
0116                           F::ArgumentTuple>();
0117   CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<int>, Matcher<char*>,
0118                                 Matcher<int&>, Matcher<const long&> >,  // NOLINT
0119                           F::ArgumentMatcherTuple>();
0120   CompileAssertTypesEqual<void(bool, int, char*, int&, const long&),  // NOLINT
0121                           F::MakeResultVoid>();
0122   CompileAssertTypesEqual<
0123       IgnoredValue(bool, int, char*, int&, const long&),  // NOLINT
0124       F::MakeResultIgnoredValue>();
0125 }
0126 
0127 }  // Unnamed namespace