protobuf/src/google/protobuf/stubs/template_util_unittest.cc
Go to the documentation of this file.
1 // Copyright 2005 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 // Author: lar@google.com (Laramie Leavitt)
32 //
33 // These tests are really compile time tests.
34 // If you try to step through this in a debugger
35 // you will not see any evaluations, merely that
36 // value is assigned true or false sequentially.
37 
38 #include <google/protobuf/stubs/template_util.h>
39 
40 #include <google/protobuf/testing/googletest.h>
41 #include <gtest/gtest.h>
42 
44 
45 namespace google {
46 namespace protobuf {
47 namespace internal {
48 namespace {
49 
50 TEST(TemplateUtilTest, TestSize) {
52 }
53 
54 TEST(TemplateUtilTest, TestIntegralConstants) {
55  // test the built-in types.
58 
59  typedef integral_constant<int, 1> one_type;
61 }
62 
63 TEST(TemplateUtilTest, TestTemplateIf) {
66 
69 }
70 
71 TEST(TemplateUtilTest, TestTemplateTypeEquals) {
72  // Check that the TemplateTypeEquals works correctly.
73  bool value = false;
74 
75  // Test the same type is true.
78 
79  // Test different types are false.
82 
83  // Test type aliasing.
84  typedef const int foo;
87 }
88 
89 TEST(TemplateUtilTest, TestTemplateAndOr) {
90  // Check that the TemplateTypeEquals works correctly.
91  bool value = false;
92 
93  // Yes && Yes == true.
96  // Yes && No == false.
99  // No && Yes == false.
102  // No && No == false.
105 
106  // Yes || Yes == true.
109  // Yes || No == true.
112  // No || Yes == true.
115  // No || No == false.
118 }
119 
120 TEST(TemplateUtilTest, TestIdentity) {
121  EXPECT_TRUE(
122  (type_equals_<GOOGLE_NAMESPACE::identity_<int>::type, int>::value));
123  EXPECT_TRUE(
124  (type_equals_<GOOGLE_NAMESPACE::identity_<void>::type, void>::value));
125 }
126 
127 } // anonymous namespace
128 } // namespace internal
129 } // namespace protobuf
130 } // namespace google
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1970
google::protobuf.internal::if_::type
A type
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:99
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf.internal::small_
char small_
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:59
EXPECT_GT
#define EXPECT_GT(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2036
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
google::protobuf.internal
Definition: third_party/bloaty/third_party/protobuf/python/google/protobuf/internal/__init__.py:1
google::protobuf.internal::identity_
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:67
value
const char * value
Definition: hpack_parser_table.cc:165
foo
int foo
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/statusor_test.cc:66
google::protobuf.internal::big_
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:61
google::protobuf.internal::TEST
TEST(GeneratedMapFieldTest, Accessors)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/map_test.cc:1847
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
google::protobuf.internal::integral_constant::value
static const T value
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/template_util.h:78
internal
Definition: benchmark/test/output_test_helper.cc:20
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:26