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

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

Issue 1276333006: Really 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
11 // Unit test covering cases where PDFium replaces well-known library 11 // Unit test covering cases where PDFium replaces well-known library
12 // functionality on any given platformn. 12 // functionality on any given platformn.
Lei Zhang 2015/08/07 23:36:50 BTW, typo heere.
13
14 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
15
13 namespace { 16 namespace {
14 17
15 const FX_CHAR kSentinel = 0x7f; 18 const FX_CHAR kSentinel = 0x7f;
16 19
17 void Check32BitBase16Itoa(int32_t input, const char* expected_output) { 20 void Check32BitBase16Itoa(int32_t input, const char* expected_output) {
18 const size_t kBufLen = 11; // "-" + 8 digits + NUL + sentinel. 21 const size_t kBufLen = 11; // "-" + 8 digits + NUL + sentinel.
19 FX_CHAR buf[kBufLen]; 22 FX_CHAR buf[kBufLen];
20 buf[kBufLen - 1] = kSentinel; 23 buf[kBufLen - 1] = kSentinel;
21 FXSYS_itoa(input, buf, 16); 24 FXSYS_itoa(input, buf, 16);
22 EXPECT_EQ(std::string(expected_output), buf); 25 EXPECT_EQ(std::string(expected_output), buf);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const size_t kBufLen = 67; // "-" + 64 digits + NUL + sentinel. 66 const size_t kBufLen = 67; // "-" + 64 digits + NUL + sentinel.
64 FX_CHAR buf[kBufLen]; 67 FX_CHAR buf[kBufLen];
65 buf[kBufLen - 1] = kSentinel; 68 buf[kBufLen - 1] = kSentinel;
66 FXSYS_i64toa(input, buf, 2); 69 FXSYS_i64toa(input, buf, 2);
67 EXPECT_EQ(std::string(expected_output), buf); 70 EXPECT_EQ(std::string(expected_output), buf);
68 EXPECT_EQ(kSentinel, buf[kBufLen - 1]); 71 EXPECT_EQ(kSentinel, buf[kBufLen - 1]);
69 } 72 }
70 73
71 } // namespace 74 } // namespace
72 75
73 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
74
75 TEST(fxcrt, FXSYS_itoa_InvalidRadix) { 76 TEST(fxcrt, FXSYS_itoa_InvalidRadix) {
76 FX_CHAR buf[32]; 77 FX_CHAR buf[32];
77 78
78 FXSYS_itoa(42, buf, 17); // Ours stops at 16. 79 FXSYS_itoa(42, buf, 17); // Ours stops at 16.
79 EXPECT_EQ(std::string(""), buf); 80 EXPECT_EQ(std::string(""), buf);
80 81
81 FXSYS_itoa(42, buf, 1); 82 FXSYS_itoa(42, buf, 1);
82 EXPECT_EQ(std::string(""), buf); 83 EXPECT_EQ(std::string(""), buf);
83 84
84 FXSYS_itoa(42, buf, 0); 85 FXSYS_itoa(42, buf, 0);
85 EXPECT_EQ(std::string(""), buf); 86 EXPECT_EQ(std::string(""), buf);
86 87
87 FXSYS_itoa(42, buf, -1); 88 FXSYS_itoa(42, buf, -1);
88 EXPECT_EQ(std::string(""), buf); 89 EXPECT_EQ(std::string(""), buf);
89 } 90 }
90 91
91 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
92
93 TEST(fxcrt, FXSYS_itoa) { 92 TEST(fxcrt, FXSYS_itoa) {
94 Check32BitBase16Itoa(std::numeric_limits<int32_t>::min(), "-80000000"); 93 Check32BitBase16Itoa(std::numeric_limits<int32_t>::min(), "-80000000");
95 Check32BitBase10Itoa(std::numeric_limits<int32_t>::min(), "-2147483648"); 94 Check32BitBase10Itoa(std::numeric_limits<int32_t>::min(), "-2147483648");
96 Check32BitBase2Itoa(std::numeric_limits<int32_t>::min(), 95 Check32BitBase2Itoa(std::numeric_limits<int32_t>::min(),
97 "-10000000000000000000000000000000"); 96 "-10000000000000000000000000000000");
98 97
99 Check32BitBase16Itoa(-1, "-1"); 98 Check32BitBase16Itoa(-1, "-1");
100 Check32BitBase10Itoa(-1, "-1"); 99 Check32BitBase10Itoa(-1, "-1");
101 Check32BitBase2Itoa(-1, "-1"); 100 Check32BitBase2Itoa(-1, "-1");
102 101
103 Check32BitBase16Itoa(0, "0"); 102 Check32BitBase16Itoa(0, "0");
104 Check32BitBase10Itoa(0, "0"); 103 Check32BitBase10Itoa(0, "0");
105 Check32BitBase2Itoa(0, "0"); 104 Check32BitBase2Itoa(0, "0");
106 105
107 Check32BitBase16Itoa(42, "2a"); 106 Check32BitBase16Itoa(42, "2a");
108 Check32BitBase10Itoa(42, "42"); 107 Check32BitBase10Itoa(42, "42");
109 Check32BitBase2Itoa(42, "101010"); 108 Check32BitBase2Itoa(42, "101010");
110 109
111 Check32BitBase16Itoa(std::numeric_limits<int32_t>::max(), "7fffffff"); 110 Check32BitBase16Itoa(std::numeric_limits<int32_t>::max(), "7fffffff");
112 Check32BitBase10Itoa(std::numeric_limits<int32_t>::max(), "2147483647"); 111 Check32BitBase10Itoa(std::numeric_limits<int32_t>::max(), "2147483647");
113 Check32BitBase2Itoa(std::numeric_limits<int32_t>::max(), 112 Check32BitBase2Itoa(std::numeric_limits<int32_t>::max(),
114 "1111111111111111111111111111111"); 113 "1111111111111111111111111111111");
115 } 114 }
116 115
117 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
118
119 TEST(fxcrt, FXSYS_i64toa_InvalidRadix) { 116 TEST(fxcrt, FXSYS_i64toa_InvalidRadix) {
120 FX_CHAR buf[32]; 117 FX_CHAR buf[32];
121 118
122 FXSYS_i64toa(42, buf, 17); // Ours stops at 16. 119 FXSYS_i64toa(42, buf, 17); // Ours stops at 16.
123 EXPECT_EQ(std::string(""), buf); 120 EXPECT_EQ(std::string(""), buf);
124 121
125 FXSYS_i64toa(42, buf, 1); 122 FXSYS_i64toa(42, buf, 1);
126 EXPECT_EQ(std::string(""), buf); 123 EXPECT_EQ(std::string(""), buf);
127 124
128 FXSYS_i64toa(42, buf, 0); 125 FXSYS_i64toa(42, buf, 0);
129 EXPECT_EQ(std::string(""), buf); 126 EXPECT_EQ(std::string(""), buf);
130 127
131 FXSYS_i64toa(42, buf, -1); 128 FXSYS_i64toa(42, buf, -1);
132 EXPECT_EQ(std::string(""), buf); 129 EXPECT_EQ(std::string(""), buf);
133 }; 130 };
134 131
135 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
136 132
137 TEST(fxcrt, FXSYS_i64toa) { 133 TEST(fxcrt, FXSYS_i64toa) {
138 Check64BitBase16Itoa( 134 Check64BitBase16Itoa(
139 std::numeric_limits<int64_t>::min(), "-8000000000000000"); 135 std::numeric_limits<int64_t>::min(), "-8000000000000000");
140 Check64BitBase10Itoa( 136 Check64BitBase10Itoa(
141 std::numeric_limits<int64_t>::min(), "-9223372036854775808"); 137 std::numeric_limits<int64_t>::min(), "-9223372036854775808");
142 Check64BitBase2Itoa( 138 Check64BitBase2Itoa(
143 std::numeric_limits<int64_t>::min(), 139 std::numeric_limits<int64_t>::min(),
144 "-1000000000000000000000000000000000000000000000000000000000000000"); 140 "-1000000000000000000000000000000000000000000000000000000000000000");
145 141
(...skipping 10 matching lines...) Expand all
156 Check64BitBase2Itoa(42, "101010"); 152 Check64BitBase2Itoa(42, "101010");
157 153
158 Check64BitBase16Itoa( 154 Check64BitBase16Itoa(
159 std::numeric_limits<int64_t>::max(), "7fffffffffffffff"); 155 std::numeric_limits<int64_t>::max(), "7fffffffffffffff");
160 Check64BitBase10Itoa( 156 Check64BitBase10Itoa(
161 std::numeric_limits<int64_t>::max(), "9223372036854775807"); 157 std::numeric_limits<int64_t>::max(), "9223372036854775807");
162 Check64BitBase2Itoa( 158 Check64BitBase2Itoa(
163 std::numeric_limits<int64_t>::max(), 159 std::numeric_limits<int64_t>::max(),
164 "111111111111111111111111111111111111111111111111111111111111111"); 160 "111111111111111111111111111111111111111111111111111111111111111");
165 } 161 }
162
163 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
164
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