Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: webrtc/base/safe_minmax_unittest.cc

Issue 2916083003: SafeMin/SafeMax: Fix wrong return type when given two enum arguments (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/safe_minmax.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2017 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 static_assert(TypeCheckMinMax< uint8_t, uint64_t, uint8_t, uint64_t>(), ""); 55 static_assert(TypeCheckMinMax< uint8_t, uint64_t, uint8_t, uint64_t>(), "");
56 static_assert(TypeCheckMinMax< int64_t, int8_t, int64_t, int64_t>(), ""); 56 static_assert(TypeCheckMinMax< int64_t, int8_t, int64_t, int64_t>(), "");
57 static_assert(TypeCheckMinMax< int64_t, uint8_t, int64_t, int64_t>(), ""); 57 static_assert(TypeCheckMinMax< int64_t, uint8_t, int64_t, int64_t>(), "");
58 static_assert(TypeCheckMinMax< int64_t, int64_t, int64_t, int64_t>(), ""); 58 static_assert(TypeCheckMinMax< int64_t, int64_t, int64_t, int64_t>(), "");
59 static_assert(TypeCheckMinMax< int64_t, uint64_t, int64_t, uint64_t>(), ""); 59 static_assert(TypeCheckMinMax< int64_t, uint64_t, int64_t, uint64_t>(), "");
60 static_assert(TypeCheckMinMax<uint64_t, int8_t, int8_t, uint64_t>(), ""); 60 static_assert(TypeCheckMinMax<uint64_t, int8_t, int8_t, uint64_t>(), "");
61 static_assert(TypeCheckMinMax<uint64_t, uint8_t, uint8_t, uint64_t>(), ""); 61 static_assert(TypeCheckMinMax<uint64_t, uint8_t, uint8_t, uint64_t>(), "");
62 static_assert(TypeCheckMinMax<uint64_t, int64_t, int64_t, uint64_t>(), ""); 62 static_assert(TypeCheckMinMax<uint64_t, int64_t, int64_t, uint64_t>(), "");
63 static_assert(TypeCheckMinMax<uint64_t, uint64_t, uint64_t, uint64_t>(), ""); 63 static_assert(TypeCheckMinMax<uint64_t, uint64_t, uint64_t, uint64_t>(), "");
64 64
65 // SafeMin/SafeMax: Check that we can use enum types.
66 enum DefaultE { kFoo = -17 }; 65 enum DefaultE { kFoo = -17 };
67 enum UInt8E : uint8_t { kBar = 17 }; 66 enum UInt8E : uint8_t { kBar = 17 };
68 static_assert(TypeCheckMinMax<unsigned, DefaultE, int, unsigned>(), ""); 67
69 static_assert(TypeCheckMinMax<unsigned, UInt8E, uint8_t, unsigned>(), ""); 68 // SafeMin/SafeMax: Check that we can use enum types.
70 static_assert(TypeCheckMinMax<DefaultE, UInt8E, int, int>(), ""); 69 static_assert(TypeCheckMinMax<unsigned, unsigned, unsigned, unsigned>(), "");
70 static_assert(TypeCheckMinMax<unsigned, DefaultE, int, unsigned>(), "");
71 static_assert(TypeCheckMinMax<unsigned, UInt8E, uint8_t, unsigned>(), "");
72 static_assert(TypeCheckMinMax<DefaultE, unsigned, int, unsigned>(), "");
73 static_assert(TypeCheckMinMax<DefaultE, DefaultE, int, int>(), "");
74 static_assert(TypeCheckMinMax<DefaultE, UInt8E, int, int>(), "");
kwiberg-webrtc 2017/06/02 10:14:03 This (line 74) is the test that failed without the
75 static_assert(TypeCheckMinMax< UInt8E, unsigned, uint8_t, unsigned>(), "");
76 static_assert(TypeCheckMinMax< UInt8E, DefaultE, int, int>(), "");
77 static_assert(TypeCheckMinMax< UInt8E, UInt8E, uint8_t, uint8_t>(), "");
71 78
72 using ld = long double; 79 using ld = long double;
73 80
74 // SafeMin/SafeMax: Check that all floating-point combinations give the 81 // SafeMin/SafeMax: Check that all floating-point combinations give the
75 // correct result type. 82 // correct result type.
76 static_assert(TypeCheckMinMax< float, float, float, float>(), ""); 83 static_assert(TypeCheckMinMax< float, float, float, float>(), "");
77 static_assert(TypeCheckMinMax< float, double, double, double>(), ""); 84 static_assert(TypeCheckMinMax< float, double, double, double>(), "");
78 static_assert(TypeCheckMinMax< float, ld, ld, ld>(), ""); 85 static_assert(TypeCheckMinMax< float, ld, ld, ld>(), "");
79 static_assert(TypeCheckMinMax<double, float, double, double>(), ""); 86 static_assert(TypeCheckMinMax<double, float, double, double>(), "");
80 static_assert(TypeCheckMinMax<double, double, double, double>(), ""); 87 static_assert(TypeCheckMinMax<double, double, double, double>(), "");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 int32_t TestMinRef( int32_t a, int32_t b) { return std::min(a, b); } 139 int32_t TestMinRef( int32_t a, int32_t b) { return std::min(a, b); }
133 uint32_t TestMinRef( uint32_t a, uint32_t b) { return std::min(a, b); } 140 uint32_t TestMinRef( uint32_t a, uint32_t b) { return std::min(a, b); }
134 int32_t TestMinSafe( int32_t a, int32_t b) { return SafeMin(a, b); } 141 int32_t TestMinSafe( int32_t a, int32_t b) { return SafeMin(a, b); }
135 int32_t TestMinSafe( int32_t a, uint32_t b) { return SafeMin(a, b); } 142 int32_t TestMinSafe( int32_t a, uint32_t b) { return SafeMin(a, b); }
136 int32_t TestMinSafe(uint32_t a, int32_t b) { return SafeMin(a, b); } 143 int32_t TestMinSafe(uint32_t a, int32_t b) { return SafeMin(a, b); }
137 uint32_t TestMinSafe(uint32_t a, uint32_t b) { return SafeMin(a, b); } 144 uint32_t TestMinSafe(uint32_t a, uint32_t b) { return SafeMin(a, b); }
138 145
139 // clang-format on 146 // clang-format on
140 147
141 } // namespace rtc 148 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/safe_minmax.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698