OLD | NEW |
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 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "chrome/installer/mini_installer/mini_string.h" | 10 #include "chrome/installer/mini_installer/mini_string.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using mini_installer::StackString; | 13 using mini_installer::StackString; |
14 | 14 |
15 namespace { | 15 namespace { |
16 class MiniInstallerStringTest : public testing::Test { | 16 class MiniInstallerStringTest : public testing::Test { |
17 protected: | 17 protected: |
18 virtual void SetUp() { | 18 void SetUp() override {} |
19 } | 19 void TearDown() override {} |
20 virtual void TearDown() { | |
21 } | |
22 }; | 20 }; |
23 } | 21 } |
24 | 22 |
25 // Tests the strcat/strcpy/length support of the StackString class. | 23 // Tests the strcat/strcpy/length support of the StackString class. |
26 TEST_F(MiniInstallerStringTest, StackStringOverflow) { | 24 TEST_F(MiniInstallerStringTest, StackStringOverflow) { |
27 static const wchar_t kTestString[] = L"1234567890"; | 25 static const wchar_t kTestString[] = L"1234567890"; |
28 | 26 |
29 StackString<MAX_PATH> str; | 27 StackString<MAX_PATH> str; |
30 EXPECT_EQ(MAX_PATH, str.capacity()); | 28 EXPECT_EQ(MAX_PATH, str.capacity()); |
31 | 29 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 66 |
69 StackString<MAX_PATH> str; | 67 StackString<MAX_PATH> str; |
70 EXPECT_TRUE(str.assign(kTestStringSource)); | 68 EXPECT_TRUE(str.assign(kTestStringSource)); |
71 EXPECT_EQ(str.get(), str.findi(kTestStringSource)); | 69 EXPECT_EQ(str.get(), str.findi(kTestStringSource)); |
72 EXPECT_EQ(static_cast<const wchar_t*>(NULL), str.findi(kTestStringNotFound)); | 70 EXPECT_EQ(static_cast<const wchar_t*>(NULL), str.findi(kTestStringNotFound)); |
73 const wchar_t* found = str.findi(kTestStringFind); | 71 const wchar_t* found = str.findi(kTestStringFind); |
74 EXPECT_NE(static_cast<const wchar_t*>(NULL), found); | 72 EXPECT_NE(static_cast<const wchar_t*>(NULL), found); |
75 std::wstring check(found, arraysize(kTestStringFind) - 1); | 73 std::wstring check(found, arraysize(kTestStringFind) - 1); |
76 EXPECT_EQ(0, lstrcmpi(check.c_str(), kTestStringFind)); | 74 EXPECT_EQ(0, lstrcmpi(check.c_str(), kTestStringFind)); |
77 } | 75 } |
OLD | NEW |