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

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

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 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') | webrtc/base/sanitizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <algorithm>
12 #include <limits>
13
14 #include "webrtc/base/safe_minmax.h"
15 #include "webrtc/test/gtest.h"
16
17 namespace rtc {
18
19 namespace {
20
21 // Functions that check that SafeMin(), SafeMax(), and SafeClamp() return the
22 // specified type. The functions that end in "R" use an explicitly given return
23 // type.
24
25 template <typename T1, typename T2, typename Tmin, typename Tmax>
26 constexpr bool TypeCheckMinMax() {
27 return std::is_same<decltype(SafeMin(std::declval<T1>(), std::declval<T2>())),
28 Tmin>::value &&
29 std::is_same<decltype(SafeMax(std::declval<T1>(), std::declval<T2>())),
30 Tmax>::value;
31 }
32
33 template <typename T1, typename T2, typename R>
34 constexpr bool TypeCheckMinR() {
35 return std::is_same<
36 decltype(SafeMin<R>(std::declval<T1>(), std::declval<T2>())), R>::value;
37 }
38
39 template <typename T1, typename T2, typename R>
40 constexpr bool TypeCheckMaxR() {
41 return std::is_same<
42 decltype(SafeMax<R>(std::declval<T1>(), std::declval<T2>())), R>::value;
43 }
44
45 template <typename T, typename L, typename H, typename R>
46 constexpr bool TypeCheckClamp() {
47 return std::is_same<decltype(SafeClamp(std::declval<T>(), std::declval<L>(),
48 std::declval<H>())),
49 R>::value;
50 }
51
52 template <typename T, typename L, typename H, typename R>
53 constexpr bool TypeCheckClampR() {
54 return std::is_same<decltype(SafeClamp<R>(std::declval<T>(),
55 std::declval<L>(),
56 std::declval<H>())),
57 R>::value;
58 }
59
60 // clang-format off
61
62 // SafeMin/SafeMax: Check that all combinations of signed/unsigned 8/64 bits
63 // give the correct default result type.
64 static_assert(TypeCheckMinMax< int8_t, int8_t, int8_t, int8_t>(), "");
65 static_assert(TypeCheckMinMax< int8_t, uint8_t, int8_t, uint8_t>(), "");
66 static_assert(TypeCheckMinMax< int8_t, int64_t, int64_t, int64_t>(), "");
67 static_assert(TypeCheckMinMax< int8_t, uint64_t, int8_t, uint64_t>(), "");
68 static_assert(TypeCheckMinMax< uint8_t, int8_t, int8_t, uint8_t>(), "");
69 static_assert(TypeCheckMinMax< uint8_t, uint8_t, uint8_t, uint8_t>(), "");
70 static_assert(TypeCheckMinMax< uint8_t, int64_t, int64_t, int64_t>(), "");
71 static_assert(TypeCheckMinMax< uint8_t, uint64_t, uint8_t, uint64_t>(), "");
72 static_assert(TypeCheckMinMax< int64_t, int8_t, int64_t, int64_t>(), "");
73 static_assert(TypeCheckMinMax< int64_t, uint8_t, int64_t, int64_t>(), "");
74 static_assert(TypeCheckMinMax< int64_t, int64_t, int64_t, int64_t>(), "");
75 static_assert(TypeCheckMinMax< int64_t, uint64_t, int64_t, uint64_t>(), "");
76 static_assert(TypeCheckMinMax<uint64_t, int8_t, int8_t, uint64_t>(), "");
77 static_assert(TypeCheckMinMax<uint64_t, uint8_t, uint8_t, uint64_t>(), "");
78 static_assert(TypeCheckMinMax<uint64_t, int64_t, int64_t, uint64_t>(), "");
79 static_assert(TypeCheckMinMax<uint64_t, uint64_t, uint64_t, uint64_t>(), "");
80
81 // SafeClamp: Check that all combinations of signed/unsigned 8/64 bits give the
82 // correct result type.
83 static_assert(TypeCheckClamp< int8_t, int8_t, int8_t, int8_t>(), "");
84 static_assert(TypeCheckClamp< int8_t, int8_t, uint8_t, int8_t>(), "");
85 static_assert(TypeCheckClamp< int8_t, int8_t, int64_t, int8_t>(), "");
86 static_assert(TypeCheckClamp< int8_t, int8_t, uint64_t, int8_t>(), "");
87 static_assert(TypeCheckClamp< int8_t, uint8_t, int8_t, int8_t>(), "");
88 static_assert(TypeCheckClamp< int8_t, uint8_t, uint8_t, uint8_t>(), "");
89 static_assert(TypeCheckClamp< int8_t, uint8_t, int64_t, int16_t>(), "");
90 static_assert(TypeCheckClamp< int8_t, uint8_t, uint64_t, int16_t>(), "");
91 static_assert(TypeCheckClamp< int8_t, int64_t, int8_t, int8_t>(), "");
92 static_assert(TypeCheckClamp< int8_t, int64_t, uint8_t, int16_t>(), "");
93 static_assert(TypeCheckClamp< int8_t, int64_t, int64_t, int64_t>(), "");
94 static_assert(TypeCheckClamp< int8_t, int64_t, uint64_t, int64_t>(), "");
95 static_assert(TypeCheckClamp< int8_t, uint64_t, int8_t, int8_t>(), "");
96 static_assert(TypeCheckClamp< int8_t, uint64_t, uint8_t, int16_t>(), "");
97 static_assert(TypeCheckClamp< int8_t, uint64_t, int64_t, int64_t>(), "");
98 static_assert(TypeCheckClamp< int8_t, uint64_t, uint64_t, uint64_t>(), "");
99 static_assert(TypeCheckClamp< uint8_t, int8_t, int8_t, int8_t>(), "");
100 static_assert(TypeCheckClamp< uint8_t, int8_t, uint8_t, uint8_t>(), "");
101 static_assert(TypeCheckClamp< uint8_t, int8_t, int64_t, int16_t>(), "");
102 static_assert(TypeCheckClamp< uint8_t, int8_t, uint64_t, uint8_t>(), "");
103 static_assert(TypeCheckClamp< uint8_t, uint8_t, int8_t, uint8_t>(), "");
104 static_assert(TypeCheckClamp< uint8_t, uint8_t, uint8_t, uint8_t>(), "");
105 static_assert(TypeCheckClamp< uint8_t, uint8_t, int64_t, uint8_t>(), "");
106 static_assert(TypeCheckClamp< uint8_t, uint8_t, uint64_t, uint8_t>(), "");
107 static_assert(TypeCheckClamp< uint8_t, int64_t, int8_t, int8_t>(), "");
108 static_assert(TypeCheckClamp< uint8_t, int64_t, uint8_t, uint8_t>(), "");
109 static_assert(TypeCheckClamp< uint8_t, int64_t, int64_t, int64_t>(), "");
110 static_assert(TypeCheckClamp< uint8_t, int64_t, uint64_t, uint64_t>(), "");
111 static_assert(TypeCheckClamp< uint8_t, uint64_t, int8_t, uint8_t>(), "");
112 static_assert(TypeCheckClamp< uint8_t, uint64_t, uint8_t, uint8_t>(), "");
113 static_assert(TypeCheckClamp< uint8_t, uint64_t, int64_t, uint64_t>(), "");
114 static_assert(TypeCheckClamp< uint8_t, uint64_t, uint64_t, uint64_t>(), "");
115 static_assert(TypeCheckClamp< int64_t, int8_t, int8_t, int8_t>(), "");
116 static_assert(TypeCheckClamp< int64_t, int8_t, uint8_t, int16_t>(), "");
117 static_assert(TypeCheckClamp< int64_t, int8_t, int64_t, int64_t>(), "");
118 static_assert(TypeCheckClamp< int64_t, int8_t, uint64_t, int64_t>(), "");
119 static_assert(TypeCheckClamp< int64_t, uint8_t, int8_t, int8_t>(), "");
120 static_assert(TypeCheckClamp< int64_t, uint8_t, uint8_t, int16_t>(), "");
121 static_assert(TypeCheckClamp< int64_t, uint8_t, int64_t, int64_t>(), "");
122 static_assert(TypeCheckClamp< int64_t, uint8_t, uint64_t, int64_t>(), "");
123 static_assert(TypeCheckClamp< int64_t, int64_t, int8_t, int64_t>(), "");
124 static_assert(TypeCheckClamp< int64_t, int64_t, uint8_t, int64_t>(), "");
125 static_assert(TypeCheckClamp< int64_t, int64_t, int64_t, int64_t>(), "");
126 static_assert(TypeCheckClamp< int64_t, int64_t, uint64_t, int64_t>(), "");
127 static_assert(TypeCheckClamp< int64_t, uint64_t, int8_t, int8_t>(), "");
128 static_assert(TypeCheckClamp< int64_t, uint64_t, uint8_t, int16_t>(), "");
129 static_assert(TypeCheckClamp< int64_t, uint64_t, int64_t, int64_t>(), "");
130 static_assert(TypeCheckClamp< int64_t, uint64_t, uint64_t, uint64_t>(), "");
131 static_assert(TypeCheckClamp<uint64_t, int8_t, int8_t, int8_t>(), "");
132 static_assert(TypeCheckClamp<uint64_t, int8_t, uint8_t, uint8_t>(), "");
133 static_assert(TypeCheckClamp<uint64_t, int8_t, int64_t, int64_t>(), "");
134 static_assert(TypeCheckClamp<uint64_t, int8_t, uint64_t, uint64_t>(), "");
135 static_assert(TypeCheckClamp<uint64_t, uint8_t, int8_t, uint8_t>(), "");
136 static_assert(TypeCheckClamp<uint64_t, uint8_t, uint8_t, uint8_t>(), "");
137 static_assert(TypeCheckClamp<uint64_t, uint8_t, int64_t, uint64_t>(), "");
138 static_assert(TypeCheckClamp<uint64_t, uint8_t, uint64_t, uint64_t>(), "");
139 static_assert(TypeCheckClamp<uint64_t, int64_t, int8_t, int8_t>(), "");
140 static_assert(TypeCheckClamp<uint64_t, int64_t, uint8_t, uint8_t>(), "");
141 static_assert(TypeCheckClamp<uint64_t, int64_t, int64_t, int64_t>(), "");
142 static_assert(TypeCheckClamp<uint64_t, int64_t, uint64_t, uint64_t>(), "");
143 static_assert(TypeCheckClamp<uint64_t, uint64_t, int8_t, uint8_t>(), "");
144 static_assert(TypeCheckClamp<uint64_t, uint64_t, uint8_t, uint8_t>(), "");
145 static_assert(TypeCheckClamp<uint64_t, uint64_t, int64_t, uint64_t>(), "");
146 static_assert(TypeCheckClamp<uint64_t, uint64_t, uint64_t, uint64_t>(), "");
147
148 enum DefaultE { kFoo = -17 };
149 enum UInt8E : uint8_t { kBar = 17 };
150
151 // SafeMin/SafeMax: Check that we can use enum types.
152 static_assert(TypeCheckMinMax<unsigned, unsigned, unsigned, unsigned>(), "");
153 static_assert(TypeCheckMinMax<unsigned, DefaultE, int, unsigned>(), "");
154 static_assert(TypeCheckMinMax<unsigned, UInt8E, uint8_t, unsigned>(), "");
155 static_assert(TypeCheckMinMax<DefaultE, unsigned, int, unsigned>(), "");
156 static_assert(TypeCheckMinMax<DefaultE, DefaultE, int, int>(), "");
157 static_assert(TypeCheckMinMax<DefaultE, UInt8E, int, int>(), "");
158 static_assert(TypeCheckMinMax< UInt8E, unsigned, uint8_t, unsigned>(), "");
159 static_assert(TypeCheckMinMax< UInt8E, DefaultE, int, int>(), "");
160 static_assert(TypeCheckMinMax< UInt8E, UInt8E, uint8_t, uint8_t>(), "");
161
162 // SafeClamp: Check that we can use enum types.
163 static_assert(TypeCheckClamp<unsigned, unsigned, unsigned, unsigned>(), "");
164 static_assert(TypeCheckClamp<unsigned, unsigned, DefaultE, unsigned>(), "");
165 static_assert(TypeCheckClamp<unsigned, unsigned, UInt8E, uint8_t>(), "");
166 static_assert(TypeCheckClamp<unsigned, DefaultE, unsigned, unsigned>(), "");
167 static_assert(TypeCheckClamp<unsigned, DefaultE, DefaultE, int>(), "");
168 static_assert(TypeCheckClamp<unsigned, DefaultE, UInt8E, uint8_t>(), "");
169 static_assert(TypeCheckClamp<unsigned, UInt8E, unsigned, unsigned>(), "");
170 static_assert(TypeCheckClamp<unsigned, UInt8E, DefaultE, unsigned>(), "");
171 static_assert(TypeCheckClamp<unsigned, UInt8E, UInt8E, uint8_t>(), "");
172 static_assert(TypeCheckClamp<DefaultE, unsigned, unsigned, unsigned>(), "");
173 static_assert(TypeCheckClamp<DefaultE, unsigned, DefaultE, int>(), "");
174 static_assert(TypeCheckClamp<DefaultE, unsigned, UInt8E, int16_t>(), "");
175 static_assert(TypeCheckClamp<DefaultE, DefaultE, unsigned, int>(), "");
176 static_assert(TypeCheckClamp<DefaultE, DefaultE, DefaultE, int>(), "");
177 static_assert(TypeCheckClamp<DefaultE, DefaultE, UInt8E, int>(), "");
178 static_assert(TypeCheckClamp<DefaultE, UInt8E, unsigned, int>(), "");
179 static_assert(TypeCheckClamp<DefaultE, UInt8E, DefaultE, int>(), "");
180 static_assert(TypeCheckClamp<DefaultE, UInt8E, UInt8E, int16_t>(), "");
181 static_assert(TypeCheckClamp< UInt8E, unsigned, unsigned, unsigned>(), "");
182 static_assert(TypeCheckClamp< UInt8E, unsigned, DefaultE, unsigned>(), "");
183 static_assert(TypeCheckClamp< UInt8E, unsigned, UInt8E, uint8_t>(), "");
184 static_assert(TypeCheckClamp< UInt8E, DefaultE, unsigned, unsigned>(), "");
185 static_assert(TypeCheckClamp< UInt8E, DefaultE, DefaultE, int>(), "");
186 static_assert(TypeCheckClamp< UInt8E, DefaultE, UInt8E, uint8_t>(), "");
187 static_assert(TypeCheckClamp< UInt8E, UInt8E, unsigned, uint8_t>(), "");
188 static_assert(TypeCheckClamp< UInt8E, UInt8E, DefaultE, uint8_t>(), "");
189 static_assert(TypeCheckClamp< UInt8E, UInt8E, UInt8E, uint8_t>(), "");
190
191 using ld = long double;
192
193 // SafeMin/SafeMax: Check that all floating-point combinations give the
194 // correct result type.
195 static_assert(TypeCheckMinMax< float, float, float, float>(), "");
196 static_assert(TypeCheckMinMax< float, double, double, double>(), "");
197 static_assert(TypeCheckMinMax< float, ld, ld, ld>(), "");
198 static_assert(TypeCheckMinMax<double, float, double, double>(), "");
199 static_assert(TypeCheckMinMax<double, double, double, double>(), "");
200 static_assert(TypeCheckMinMax<double, ld, ld, ld>(), "");
201 static_assert(TypeCheckMinMax< ld, float, ld, ld>(), "");
202 static_assert(TypeCheckMinMax< ld, double, ld, ld>(), "");
203 static_assert(TypeCheckMinMax< ld, ld, ld, ld>(), "");
204
205 // SafeClamp: Check that all floating-point combinations give the correct
206 // result type.
207 static_assert(TypeCheckClamp< float, float, float, float>(), "");
208 static_assert(TypeCheckClamp< float, float, double, double>(), "");
209 static_assert(TypeCheckClamp< float, float, ld, ld>(), "");
210 static_assert(TypeCheckClamp< float, double, float, double>(), "");
211 static_assert(TypeCheckClamp< float, double, double, double>(), "");
212 static_assert(TypeCheckClamp< float, double, ld, ld>(), "");
213 static_assert(TypeCheckClamp< float, ld, float, ld>(), "");
214 static_assert(TypeCheckClamp< float, ld, double, ld>(), "");
215 static_assert(TypeCheckClamp< float, ld, ld, ld>(), "");
216 static_assert(TypeCheckClamp<double, float, float, double>(), "");
217 static_assert(TypeCheckClamp<double, float, double, double>(), "");
218 static_assert(TypeCheckClamp<double, float, ld, ld>(), "");
219 static_assert(TypeCheckClamp<double, double, float, double>(), "");
220 static_assert(TypeCheckClamp<double, double, double, double>(), "");
221 static_assert(TypeCheckClamp<double, double, ld, ld>(), "");
222 static_assert(TypeCheckClamp<double, ld, float, ld>(), "");
223 static_assert(TypeCheckClamp<double, ld, double, ld>(), "");
224 static_assert(TypeCheckClamp<double, ld, ld, ld>(), "");
225 static_assert(TypeCheckClamp< ld, float, float, ld>(), "");
226 static_assert(TypeCheckClamp< ld, float, double, ld>(), "");
227 static_assert(TypeCheckClamp< ld, float, ld, ld>(), "");
228 static_assert(TypeCheckClamp< ld, double, float, ld>(), "");
229 static_assert(TypeCheckClamp< ld, double, double, ld>(), "");
230 static_assert(TypeCheckClamp< ld, double, ld, ld>(), "");
231 static_assert(TypeCheckClamp< ld, ld, float, ld>(), "");
232 static_assert(TypeCheckClamp< ld, ld, double, ld>(), "");
233 static_assert(TypeCheckClamp< ld, ld, ld, ld>(), "");
234
235 // clang-format on
236
237 // SafeMin/SafeMax: Check some cases of explicitly specified return type. The
238 // commented-out lines give compilation errors due to the requested return type
239 // being too small or requiring an int<->float conversion.
240 static_assert(TypeCheckMinR<int8_t, int8_t, int16_t>(), "");
241 // static_assert(TypeCheckMinR<int8_t, int8_t, float>(), "");
242 static_assert(TypeCheckMinR<uint32_t, uint64_t, uint32_t>(), "");
243 // static_assert(TypeCheckMaxR<uint64_t, float, float>(), "");
244 // static_assert(TypeCheckMaxR<uint64_t, double, float>(), "");
245 static_assert(TypeCheckMaxR<uint32_t, int32_t, uint32_t>(), "");
246 // static_assert(TypeCheckMaxR<uint32_t, int32_t, int32_t>(), "");
247
248 // SafeClamp: Check some cases of explicitly specified return type. The
249 // commented-out lines give compilation errors due to the requested return type
250 // being too small.
251 static_assert(TypeCheckClampR<int16_t, int8_t, uint8_t, int16_t>(), "");
252 static_assert(TypeCheckClampR<int16_t, int8_t, uint8_t, int32_t>(), "");
253 // static_assert(TypeCheckClampR<int16_t, int8_t, uint8_t, uint32_t>(), "");
254
255 template <typename T1, typename T2, typename Tmin, typename Tmax>
256 constexpr bool CheckMinMax(T1 a, T2 b, Tmin min, Tmax max) {
257 return TypeCheckMinMax<T1, T2, Tmin, Tmax>() && SafeMin(a, b) == min &&
258 SafeMax(a, b) == max;
259 }
260
261 template <typename T, typename L, typename H, typename R>
262 bool CheckClamp(T x, L min, H max, R clamped) {
263 return TypeCheckClamp<T, L, H, R>() && SafeClamp(x, min, max) == clamped;
264 }
265
266 // SafeMin/SafeMax: Check a few values.
267 static_assert(CheckMinMax(int8_t{1}, int8_t{-1}, int8_t{-1}, int8_t{1}), "");
268 static_assert(CheckMinMax(uint8_t{1}, int8_t{-1}, int8_t{-1}, uint8_t{1}), "");
269 static_assert(CheckMinMax(uint8_t{5}, uint64_t{2}, uint8_t{2}, uint64_t{5}),
270 "");
271 static_assert(CheckMinMax(std::numeric_limits<int32_t>::min(),
272 std::numeric_limits<uint32_t>::max(),
273 std::numeric_limits<int32_t>::min(),
274 std::numeric_limits<uint32_t>::max()),
275 "");
276 static_assert(CheckMinMax(std::numeric_limits<int32_t>::min(),
277 std::numeric_limits<uint16_t>::max(),
278 std::numeric_limits<int32_t>::min(),
279 int32_t{std::numeric_limits<uint16_t>::max()}),
280 "");
281 // static_assert(CheckMinMax(1.f, 2, 1.f, 2.f), "");
282 static_assert(CheckMinMax(1.f, 0.0, 0.0, 1.0), "");
283
284 // SafeClamp: Check a few values.
285 TEST(SafeMinmaxTest, Clamp) {
286 EXPECT_TRUE(CheckClamp(int32_t{-1000000}, std::numeric_limits<int16_t>::min(),
287 std::numeric_limits<int16_t>::max(),
288 std::numeric_limits<int16_t>::min()));
289 EXPECT_TRUE(CheckClamp(uint32_t{1000000}, std::numeric_limits<int16_t>::min(),
290 std::numeric_limits<int16_t>::max(),
291 std::numeric_limits<int16_t>::max()));
292 EXPECT_TRUE(CheckClamp(3.f, -1.0, 1.f, 1.0));
293 EXPECT_TRUE(CheckClamp(3.0, -1.f, 1.f, 1.0));
294 }
295
296 } // namespace
297
298 // These functions aren't used in the tests, but it's useful to look at the
299 // compiler output for them, and verify that (1) the same-signedness Test*Safe
300 // functions result in exactly the same code as their Test*Ref counterparts,
301 // and that (2) the mixed-signedness Test*Safe functions have just a few extra
302 // arithmetic and logic instructions (but no extra control flow instructions).
303
304 // clang-format off
305 int32_t TestMinRef( int32_t a, int32_t b) { return std::min(a, b); }
306 uint32_t TestMinRef( uint32_t a, uint32_t b) { return std::min(a, b); }
307 int32_t TestMinSafe( int32_t a, int32_t b) { return SafeMin(a, b); }
308 int32_t TestMinSafe( int32_t a, uint32_t b) { return SafeMin(a, b); }
309 int32_t TestMinSafe(uint32_t a, int32_t b) { return SafeMin(a, b); }
310 uint32_t TestMinSafe(uint32_t a, uint32_t b) { return SafeMin(a, b); }
311 // clang-format on
312
313 int32_t TestClampRef(int32_t x, int32_t a, int32_t b) {
314 return std::max(a, std::min(x, b));
315 }
316 uint32_t TestClampRef(uint32_t x, uint32_t a, uint32_t b) {
317 return std::max(a, std::min(x, b));
318 }
319 int32_t TestClampSafe(int32_t x, int32_t a, int32_t b) {
320 return SafeClamp(x, a, b);
321 }
322 int32_t TestClampSafe(int32_t x, int32_t a, uint32_t b) {
323 return SafeClamp(x, a, b);
324 }
325 int32_t TestClampSafe(int32_t x, uint32_t a, int32_t b) {
326 return SafeClamp(x, a, b);
327 }
328 uint32_t TestClampSafe(int32_t x, uint32_t a, uint32_t b) {
329 return SafeClamp(x, a, b);
330 }
331 int32_t TestClampSafe(uint32_t x, int32_t a, int32_t b) {
332 return SafeClamp(x, a, b);
333 }
334 uint32_t TestClampSafe(uint32_t x, int32_t a, uint32_t b) {
335 return SafeClamp(x, a, b);
336 }
337 int32_t TestClampSafe(uint32_t x, uint32_t a, int32_t b) {
338 return SafeClamp(x, a, b);
339 }
340 uint32_t TestClampSafe(uint32_t x, uint32_t a, uint32_t b) {
341 return SafeClamp(x, a, b);
342 }
343
344 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/safe_minmax.h ('k') | webrtc/base/sanitizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698