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

Side by Side Diff: third_party/WebKit/Source/wtf/dtoa_test.cpp

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "wtf/dtoa.h" 6 #include "wtf/dtoa.h"
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 9
10 namespace WTF { 10 namespace WTF {
11 11
12 TEST(DtoaTest, TestNumberToFixedPrecisionString) 12 TEST(DtoaTest, TestNumberToFixedPrecisionString) {
13 { 13 NumberToStringBuffer buffer;
14 NumberToStringBuffer buffer;
15 14
16 // There should be no trailing decimal or zeros. 15 // There should be no trailing decimal or zeros.
17 numberToFixedPrecisionString(0.0, 6, buffer, true); 16 numberToFixedPrecisionString(0.0, 6, buffer, true);
18 EXPECT_STREQ("0", buffer); 17 EXPECT_STREQ("0", buffer);
19 18
20 // Up to 6 leading zeros. 19 // Up to 6 leading zeros.
21 numberToFixedPrecisionString(0.00000123123123, 6, buffer, true); 20 numberToFixedPrecisionString(0.00000123123123, 6, buffer, true);
22 EXPECT_STREQ("0.00000123123", buffer); 21 EXPECT_STREQ("0.00000123123", buffer);
23 22
24 numberToFixedPrecisionString(0.000000123123123, 6, buffer, true); 23 numberToFixedPrecisionString(0.000000123123123, 6, buffer, true);
25 EXPECT_STREQ("1.23123e-7", buffer); 24 EXPECT_STREQ("1.23123e-7", buffer);
26 25
27 // Up to 6 places before the decimal. 26 // Up to 6 places before the decimal.
28 numberToFixedPrecisionString(123123.123, 6, buffer, true); 27 numberToFixedPrecisionString(123123.123, 6, buffer, true);
29 EXPECT_STREQ("123123", buffer); 28 EXPECT_STREQ("123123", buffer);
30 29
31 numberToFixedPrecisionString(1231231.23, 6, buffer, true); 30 numberToFixedPrecisionString(1231231.23, 6, buffer, true);
32 EXPECT_STREQ("1.23123e+6", buffer); 31 EXPECT_STREQ("1.23123e+6", buffer);
33 32
34 // Don't strip trailing zeros in exponents. 33 // Don't strip trailing zeros in exponents.
35 // http://crbug.com/545711 34 // http://crbug.com/545711
36 numberToFixedPrecisionString(0.000000000123123, 6, buffer, true); 35 numberToFixedPrecisionString(0.000000000123123, 6, buffer, true);
37 EXPECT_STREQ("1.23123e-10", buffer); 36 EXPECT_STREQ("1.23123e-10", buffer);
38 37
39 // FIXME: Trailing zeros before exponents should be stripped. 38 // FIXME: Trailing zeros before exponents should be stripped.
40 numberToFixedPrecisionString(0.0000000001, 6, buffer, true); 39 numberToFixedPrecisionString(0.0000000001, 6, buffer, true);
41 EXPECT_STREQ("1.00000e-10", buffer); 40 EXPECT_STREQ("1.00000e-10", buffer);
42 } 41 }
43 42
44 TEST(DtoaTest, TestNumberToFixedPrecisionString_DontTruncateTrailingZeros) 43 TEST(DtoaTest, TestNumberToFixedPrecisionString_DontTruncateTrailingZeros) {
45 { 44 NumberToStringBuffer buffer;
46 NumberToStringBuffer buffer;
47 45
48 // There should be a trailing decimal and zeros. 46 // There should be a trailing decimal and zeros.
49 numberToFixedPrecisionString(0.0, 6, buffer, false); 47 numberToFixedPrecisionString(0.0, 6, buffer, false);
50 EXPECT_STREQ("0.00000", buffer); 48 EXPECT_STREQ("0.00000", buffer);
51 } 49 }
52 50
53 } // namespace WTF 51 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/dtoa/utils.h ('k') | third_party/WebKit/Source/wtf/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698