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

Side by Side Diff: base/strings/string_util_unittest.cc

Issue 248843004: Remove WCHAR_T_IS_UNSIGNED definition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove WCHAR_T_IS_UNSIGNED Created 6 years, 8 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 | build/build_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/string_util.h" 5 #include "base/strings/string_util.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stdarg.h> 8 #include <stdarg.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1004
1005 // Test dst_size == 0, nothing should be written to |dst| and we should 1005 // Test dst_size == 0, nothing should be written to |dst| and we should
1006 // have the equivalent of strlen(src). 1006 // have the equivalent of strlen(src).
1007 { 1007 {
1008 char dst[2] = {1, 2}; 1008 char dst[2] = {1, 2};
1009 wchar_t wdst[2] = {1, 2}; 1009 wchar_t wdst[2] = {1, 2};
1010 EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", 0)); 1010 EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", 0));
1011 EXPECT_EQ(1, dst[0]); 1011 EXPECT_EQ(1, dst[0]);
1012 EXPECT_EQ(2, dst[1]); 1012 EXPECT_EQ(2, dst[1]);
1013 EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", 0)); 1013 EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", 0));
1014 #if defined(WCHAR_T_IS_UNSIGNED) 1014 EXPECT_EQ(static_cast<wchar_t>(1), wdst[0]);
1015 EXPECT_EQ(1U, wdst[0]); 1015 EXPECT_EQ(static_cast<wchar_t>(2), wdst[1]);
1016 EXPECT_EQ(2U, wdst[1]);
1017 #else
1018 EXPECT_EQ(1, wdst[0]);
1019 EXPECT_EQ(2, wdst[1]);
1020 #endif
1021 } 1016 }
1022 1017
1023 // Test the case were we _just_ competely fit including the null. 1018 // Test the case were we _just_ competely fit including the null.
1024 { 1019 {
1025 char dst[8]; 1020 char dst[8];
1026 wchar_t wdst[8]; 1021 wchar_t wdst[8];
1027 EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst))); 1022 EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst)));
1028 EXPECT_EQ(0, memcmp(dst, "abcdefg", 8)); 1023 EXPECT_EQ(0, memcmp(dst, "abcdefg", 8));
1029 EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); 1024 EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst)));
1030 EXPECT_EQ(0, memcmp(wdst, L"abcdefg", sizeof(wchar_t) * 8)); 1025 EXPECT_EQ(0, memcmp(wdst, L"abcdefg", sizeof(wchar_t) * 8));
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 const std::string live = kLive; 1184 const std::string live = kLive;
1190 std::string dead = live; 1185 std::string dead = live;
1191 strncpy(WriteInto(&dead, 5), kDead, 4); 1186 strncpy(WriteInto(&dead, 5), kDead, 4);
1192 EXPECT_EQ(kDead, dead); 1187 EXPECT_EQ(kDead, dead);
1193 EXPECT_EQ(4u, dead.size()); 1188 EXPECT_EQ(4u, dead.size());
1194 EXPECT_EQ(kLive, live); 1189 EXPECT_EQ(kLive, live);
1195 EXPECT_EQ(4u, live.size()); 1190 EXPECT_EQ(4u, live.size());
1196 } 1191 }
1197 1192
1198 } // namespace base 1193 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | build/build_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698