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

Side by Side Diff: Source/wtf/MathExtrasTest.cpp

Issue 184103006: Reinstate workarounds for atan2, fmod, pow in MathExtras on vs2013 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: use numeric_limits Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/wtf/MathExtras.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 Intel Corporation 2 * Copyright (C) 2012 Intel Corporation
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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 unsigned long long overflowUnsigned = maxUnsigned + 1; 168 unsigned long long overflowUnsigned = maxUnsigned + 1;
169 169
170 EXPECT_GT(overflowUnsigned, maxUnsigned); 170 EXPECT_GT(overflowUnsigned, maxUnsigned);
171 171
172 EXPECT_EQ(clampTo<unsigned>(maxUnsigned), maxUnsigned); 172 EXPECT_EQ(clampTo<unsigned>(maxUnsigned), maxUnsigned);
173 173
174 EXPECT_EQ(clampTo<unsigned>(overflowUnsigned), maxUnsigned); 174 EXPECT_EQ(clampTo<unsigned>(overflowUnsigned), maxUnsigned);
175 EXPECT_EQ(clampTo<unsigned>(-1), 0u); 175 EXPECT_EQ(clampTo<unsigned>(-1), 0u);
176 } 176 }
177 177
178 // Make sure that various +-inf cases are handled properly (they aren't
179 // by default on VS).
180 TEST(WTF, infinityMath)
181 {
182 double posInf = std::numeric_limits<double>::infinity();
183 double negInf = -std::numeric_limits<double>::infinity();
184 double nan = std::numeric_limits<double>::quiet_NaN();
185
186 EXPECT_EQ(atan2(posInf, posInf), M_PI_4);
187 EXPECT_EQ(atan2(posInf, negInf), 3.0 * M_PI_4);
188 EXPECT_EQ(atan2(negInf, posInf), -M_PI_4);
189 EXPECT_EQ(atan2(negInf, negInf), -3.0 * M_PI_4);
190
191 EXPECT_EQ(fmod(0.0, posInf), 0.0);
192 EXPECT_EQ(fmod(7.0, posInf), 7.0);
193 EXPECT_EQ(fmod(-7.0, posInf), -7.0);
194 EXPECT_EQ(fmod(0.0, negInf), 0.0);
195 EXPECT_EQ(fmod(7.0, negInf), 7.0);
196 EXPECT_EQ(fmod(-7.0, negInf), -7.0);
197
198 EXPECT_EQ(pow(5.0, 0.0), 1.0);
199 EXPECT_EQ(pow(-5.0, 0.0), 1.0);
200 EXPECT_EQ(pow(nan, 0.0), 1.0);
201 }
202
178 } // namespace 203 } // namespace
OLDNEW
« no previous file with comments | « Source/wtf/MathExtras.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698