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

Side by Side Diff: core/src/fxcrt/fx_system_unittest.cpp

Issue 1280043005: Really fix tests broken at 9778206. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | 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 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium 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 <string> 5 #include <string>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "../../../testing/fx_string_testhelpers.h" 8 #include "../../../testing/fx_string_testhelpers.h"
9 #include "../../include/fxcrt/fx_system.h" 9 #include "../../include/fxcrt/fx_system.h"
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const size_t kBufLen = 67; // "-" + 64 digits + NUL + sentinel. 63 const size_t kBufLen = 67; // "-" + 64 digits + NUL + sentinel.
64 FX_CHAR buf[kBufLen]; 64 FX_CHAR buf[kBufLen];
65 buf[kBufLen - 1] = kSentinel; 65 buf[kBufLen - 1] = kSentinel;
66 FXSYS_i64toa(input, buf, 2); 66 FXSYS_i64toa(input, buf, 2);
67 EXPECT_EQ(std::string(expected_output), buf); 67 EXPECT_EQ(std::string(expected_output), buf);
68 EXPECT_EQ(kSentinel, buf[kBufLen - 1]); 68 EXPECT_EQ(kSentinel, buf[kBufLen - 1]);
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72 72
73 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
74
73 TEST(fxcrt, FXSYS_itoa_InvalidRadix) { 75 TEST(fxcrt, FXSYS_itoa_InvalidRadix) {
74 FX_CHAR buf[32]; 76 FX_CHAR buf[32];
75 77
76 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
77 FXSYS_itoa(42, buf, 17); // Ours stops at 16. 78 FXSYS_itoa(42, buf, 17); // Ours stops at 16.
78 #else
79 FXSYS_itoa(42, buf, 37); // Theirs goes up to 36.
80 #endif
81 EXPECT_EQ(std::string(""), buf); 79 EXPECT_EQ(std::string(""), buf);
82 80
83 FXSYS_itoa(42, buf, 1); 81 FXSYS_itoa(42, buf, 1);
84 EXPECT_EQ(std::string(""), buf); 82 EXPECT_EQ(std::string(""), buf);
85 83
86 FXSYS_itoa(42, buf, 0); 84 FXSYS_itoa(42, buf, 0);
87 EXPECT_EQ(std::string(""), buf); 85 EXPECT_EQ(std::string(""), buf);
88 86
89 FXSYS_itoa(42, buf, -1); 87 FXSYS_itoa(42, buf, -1);
90 EXPECT_EQ(std::string(""), buf); 88 EXPECT_EQ(std::string(""), buf);
91 } 89 }
92 90
91 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
92
93 TEST(fxcrt, FXSYS_itoa) { 93 TEST(fxcrt, FXSYS_itoa) {
94 Check32BitBase16Itoa(std::numeric_limits<int32_t>::min(), "-80000000"); 94 Check32BitBase16Itoa(std::numeric_limits<int32_t>::min(), "-80000000");
95 Check32BitBase10Itoa(std::numeric_limits<int32_t>::min(), "-2147483648"); 95 Check32BitBase10Itoa(std::numeric_limits<int32_t>::min(), "-2147483648");
96 Check32BitBase2Itoa(std::numeric_limits<int32_t>::min(), 96 Check32BitBase2Itoa(std::numeric_limits<int32_t>::min(),
97 "-10000000000000000000000000000000"); 97 "-10000000000000000000000000000000");
98 98
99 Check32BitBase16Itoa(-1, "-1"); 99 Check32BitBase16Itoa(-1, "-1");
100 Check32BitBase10Itoa(-1, "-1"); 100 Check32BitBase10Itoa(-1, "-1");
101 Check32BitBase2Itoa(-1, "-1"); 101 Check32BitBase2Itoa(-1, "-1");
102 102
103 Check32BitBase16Itoa(0, "0"); 103 Check32BitBase16Itoa(0, "0");
104 Check32BitBase10Itoa(0, "0"); 104 Check32BitBase10Itoa(0, "0");
105 Check32BitBase2Itoa(0, "0"); 105 Check32BitBase2Itoa(0, "0");
106 106
107 Check32BitBase16Itoa(42, "2a"); 107 Check32BitBase16Itoa(42, "2a");
108 Check32BitBase10Itoa(42, "42"); 108 Check32BitBase10Itoa(42, "42");
109 Check32BitBase2Itoa(42, "101010"); 109 Check32BitBase2Itoa(42, "101010");
110 110
111 Check32BitBase16Itoa(std::numeric_limits<int32_t>::max(), "7fffffff"); 111 Check32BitBase16Itoa(std::numeric_limits<int32_t>::max(), "7fffffff");
112 Check32BitBase10Itoa(std::numeric_limits<int32_t>::max(), "2147483647"); 112 Check32BitBase10Itoa(std::numeric_limits<int32_t>::max(), "2147483647");
113 Check32BitBase2Itoa(std::numeric_limits<int32_t>::max(), 113 Check32BitBase2Itoa(std::numeric_limits<int32_t>::max(),
114 "1111111111111111111111111111111"); 114 "1111111111111111111111111111111");
115 } 115 }
116 116
117 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
117 118
118 TEST(fxcrt, FXSYS_i64toa_InvalidRadix) { 119 TEST(fxcrt, FXSYS_i64toa_InvalidRadix) {
119 FX_CHAR buf[32]; 120 FX_CHAR buf[32];
120 121
121 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
122 FXSYS_i64toa(42, buf, 17); // Ours stops at 16. 122 FXSYS_i64toa(42, buf, 17); // Ours stops at 16.
123 #else
124 FXSYS_i64toa(42, buf, 37); // Theirs goes up to 36.
125 #endif
126 EXPECT_EQ(std::string(""), buf); 123 EXPECT_EQ(std::string(""), buf);
127 124
128 FXSYS_i64toa(42, buf, 1); 125 FXSYS_i64toa(42, buf, 1);
129 EXPECT_EQ(std::string(""), buf); 126 EXPECT_EQ(std::string(""), buf);
130 127
131 FXSYS_i64toa(42, buf, 0); 128 FXSYS_i64toa(42, buf, 0);
132 EXPECT_EQ(std::string(""), buf); 129 EXPECT_EQ(std::string(""), buf);
133 130
134 FXSYS_i64toa(42, buf, -1); 131 FXSYS_i64toa(42, buf, -1);
135 EXPECT_EQ(std::string(""), buf); 132 EXPECT_EQ(std::string(""), buf);
136 }; 133 };
137 134
135 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
136
138 TEST(fxcrt, FXSYS_i64toa) { 137 TEST(fxcrt, FXSYS_i64toa) {
139 Check64BitBase16Itoa( 138 Check64BitBase16Itoa(
140 std::numeric_limits<int64_t>::min(), "-8000000000000000"); 139 std::numeric_limits<int64_t>::min(), "-8000000000000000");
141 Check64BitBase10Itoa( 140 Check64BitBase10Itoa(
142 std::numeric_limits<int64_t>::min(), "-9223372036854775808"); 141 std::numeric_limits<int64_t>::min(), "-9223372036854775808");
143 Check64BitBase2Itoa( 142 Check64BitBase2Itoa(
144 std::numeric_limits<int64_t>::min(), 143 std::numeric_limits<int64_t>::min(),
145 "-1000000000000000000000000000000000000000000000000000000000000000"); 144 "-1000000000000000000000000000000000000000000000000000000000000000");
146 145
147 Check64BitBase16Itoa(-1, "-1"); 146 Check64BitBase16Itoa(-1, "-1");
148 Check64BitBase10Itoa(-1, "-1"); 147 Check64BitBase10Itoa(-1, "-1");
149 Check64BitBase2Itoa(-1, "-1"); 148 Check64BitBase2Itoa(-1, "-1");
150 149
151 Check64BitBase16Itoa(0, "0"); 150 Check64BitBase16Itoa(0, "0");
152 Check64BitBase10Itoa(0, "0"); 151 Check64BitBase10Itoa(0, "0");
153 Check64BitBase2Itoa(0, "0"); 152 Check64BitBase2Itoa(0, "0");
154 153
155 Check64BitBase16Itoa(42, "2a"); 154 Check64BitBase16Itoa(42, "2a");
156 Check64BitBase10Itoa(42, "42"); 155 Check64BitBase10Itoa(42, "42");
157 Check64BitBase2Itoa(42, "101010"); 156 Check64BitBase2Itoa(42, "101010");
158 157
159 Check64BitBase16Itoa( 158 Check64BitBase16Itoa(
160 std::numeric_limits<int64_t>::max(), "7fffffffffffffff"); 159 std::numeric_limits<int64_t>::max(), "7fffffffffffffff");
161 Check64BitBase10Itoa( 160 Check64BitBase10Itoa(
162 std::numeric_limits<int64_t>::max(), "9223372036854775807"); 161 std::numeric_limits<int64_t>::max(), "9223372036854775807");
163 Check64BitBase2Itoa( 162 Check64BitBase2Itoa(
164 std::numeric_limits<int64_t>::max(), 163 std::numeric_limits<int64_t>::max(),
165 "111111111111111111111111111111111111111111111111111111111111111"); 164 "111111111111111111111111111111111111111111111111111111111111111");
166 } 165 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698