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

Side by Side Diff: third_party/WebKit/Source/platform/LayoutUnitTest.cpp

Issue 2160983007: Avoid integer overflow in LayoutUnit's unary minus operator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « third_party/WebKit/Source/platform/LayoutUnit.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 (c) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 TEST(LayoutUnitTest, LayoutUnitFloatOverflow) 250 TEST(LayoutUnitTest, LayoutUnitFloatOverflow)
251 { 251 {
252 // These should overflow to the max/min according to their sign. 252 // These should overflow to the max/min according to their sign.
253 EXPECT_EQ(intMaxForLayoutUnit, LayoutUnit(176972000.0f).toInt()); 253 EXPECT_EQ(intMaxForLayoutUnit, LayoutUnit(176972000.0f).toInt());
254 EXPECT_EQ(intMinForLayoutUnit, LayoutUnit(-176972000.0f).toInt()); 254 EXPECT_EQ(intMinForLayoutUnit, LayoutUnit(-176972000.0f).toInt());
255 EXPECT_EQ(intMaxForLayoutUnit, LayoutUnit(176972000.0).toInt()); 255 EXPECT_EQ(intMaxForLayoutUnit, LayoutUnit(176972000.0).toInt());
256 EXPECT_EQ(intMinForLayoutUnit, LayoutUnit(-176972000.0).toInt()); 256 EXPECT_EQ(intMinForLayoutUnit, LayoutUnit(-176972000.0).toInt());
257 } 257 }
258 258
259 TEST(LayoutUnitTest, UnaryMinusSaturated)
pdr. 2016/07/20 21:03:55 What about -(LayoutUnit::min + 1)?
Xianzhu 2016/07/20 21:09:10 This won't be saturated, just a normal negative.
Xianzhu 2016/07/20 21:19:20 Converted this test case to a full UnaryMinus case
260 {
261 EXPECT_EQ(LayoutUnit::max(), -LayoutUnit::min());
262 }
263
259 } // namespace blink 264 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/LayoutUnit.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698