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

Side by Side Diff: chrome/installer/mini_installer/mini_string_test.cc

Issue 1133613002: Revert of mini_installer: Change to use _countof rather than base's arraysize macro. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « chrome/installer/mini_installer/mini_string.cc ('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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <stdlib.h>
7 6
8 #include <string> 7 #include <string>
9 8
10 #include "base/basictypes.h" 9 #include "base/basictypes.h"
11 #include "chrome/installer/mini_installer/mini_string.h" 10 #include "chrome/installer/mini_installer/mini_string.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 using mini_installer::StackString; 13 using mini_installer::StackString;
15 14
16 namespace { 15 namespace {
(...skipping 11 matching lines...) Expand all
28 StackString<MAX_PATH> str; 27 StackString<MAX_PATH> str;
29 EXPECT_EQ(MAX_PATH, str.capacity()); 28 EXPECT_EQ(MAX_PATH, str.capacity());
30 29
31 std::wstring compare_str; 30 std::wstring compare_str;
32 31
33 EXPECT_EQ(str.length(), compare_str.length()); 32 EXPECT_EQ(str.length(), compare_str.length());
34 EXPECT_EQ(0, compare_str.compare(str.get())); 33 EXPECT_EQ(0, compare_str.compare(str.get()));
35 34
36 size_t max_chars = str.capacity() - 1; 35 size_t max_chars = str.capacity() - 1;
37 36
38 while ((str.length() + (_countof(kTestString) - 1)) <= max_chars) { 37 while ((str.length() + (arraysize(kTestString) - 1)) <= max_chars) {
39 EXPECT_TRUE(str.append(kTestString)); 38 EXPECT_TRUE(str.append(kTestString));
40 compare_str.append(kTestString); 39 compare_str.append(kTestString);
41 EXPECT_EQ(str.length(), compare_str.length()); 40 EXPECT_EQ(str.length(), compare_str.length());
42 EXPECT_EQ(0, compare_str.compare(str.get())); 41 EXPECT_EQ(0, compare_str.compare(str.get()));
43 } 42 }
44 43
45 EXPECT_GT(static_cast<size_t>(MAX_PATH), str.length()); 44 EXPECT_GT(static_cast<size_t>(MAX_PATH), str.length());
46 45
47 // Now we've exhausted the space we allocated for the string, 46 // Now we've exhausted the space we allocated for the string,
48 // so append should fail. 47 // so append should fail.
(...skipping 15 matching lines...) Expand all
64 static const wchar_t kTestStringSource[] = L"1234ABcD567890"; 63 static const wchar_t kTestStringSource[] = L"1234ABcD567890";
65 static const wchar_t kTestStringFind[] = L"abcd"; 64 static const wchar_t kTestStringFind[] = L"abcd";
66 static const wchar_t kTestStringNotFound[] = L"80"; 65 static const wchar_t kTestStringNotFound[] = L"80";
67 66
68 StackString<MAX_PATH> str; 67 StackString<MAX_PATH> str;
69 EXPECT_TRUE(str.assign(kTestStringSource)); 68 EXPECT_TRUE(str.assign(kTestStringSource));
70 EXPECT_EQ(str.get(), str.findi(kTestStringSource)); 69 EXPECT_EQ(str.get(), str.findi(kTestStringSource));
71 EXPECT_EQ(static_cast<const wchar_t*>(NULL), str.findi(kTestStringNotFound)); 70 EXPECT_EQ(static_cast<const wchar_t*>(NULL), str.findi(kTestStringNotFound));
72 const wchar_t* found = str.findi(kTestStringFind); 71 const wchar_t* found = str.findi(kTestStringFind);
73 EXPECT_NE(static_cast<const wchar_t*>(NULL), found); 72 EXPECT_NE(static_cast<const wchar_t*>(NULL), found);
74 std::wstring check(found, _countof(kTestStringFind) - 1); 73 std::wstring check(found, arraysize(kTestStringFind) - 1);
75 EXPECT_EQ(0, lstrcmpi(check.c_str(), kTestStringFind)); 74 EXPECT_EQ(0, lstrcmpi(check.c_str(), kTestStringFind));
76 } 75 }
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/mini_string.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698