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

Side by Side Diff: base/win/scoped_bstr_unittest.cc

Issue 3781009: Move the windows-specific scoped_* stuff from base to base/win and in the bas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_bstr_win.h" 5 #include "base/win/scoped_bstr.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace base {
9 namespace win {
10
8 namespace { 11 namespace {
9 12
10 static const wchar_t kTestString1[] = L"123"; 13 static const wchar_t kTestString1[] = L"123";
11 static const wchar_t kTestString2[] = L"456789"; 14 static const wchar_t kTestString2[] = L"456789";
12 size_t test1_len = arraysize(kTestString1) - 1; 15 size_t test1_len = arraysize(kTestString1) - 1;
13 size_t test2_len = arraysize(kTestString2) - 1; 16 size_t test2_len = arraysize(kTestString2) - 1;
14 17
15 void DumbBstrTests() { 18 void DumbBstrTests() {
16 ScopedBstr b; 19 ScopedBstr b;
17 EXPECT_TRUE(b == NULL); 20 EXPECT_TRUE(b == NULL);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 EXPECT_EQ(test2_len - 1, b1.Length()); 66 EXPECT_EQ(test2_len - 1, b1.Length());
64 } 67 }
65 68
66 } // namespace 69 } // namespace
67 70
68 TEST(ScopedBstrTest, ScopedBstr) { 71 TEST(ScopedBstrTest, ScopedBstr) {
69 DumbBstrTests(); 72 DumbBstrTests();
70 BasicBstrTests(); 73 BasicBstrTests();
71 } 74 }
72 75
73 #define kSourceStr L"this is a string" 76 } // namespace win
74 #define kSourceStrEmpty L"" 77 } // namespace base
75
76 TEST(StackBstrTest, StackBstr) {
77 ScopedBstr system_bstr(kSourceStr);
78 StackBstrVar(kSourceStr, stack_bstr);
79 EXPECT_EQ(VARCMP_EQ,
80 VarBstrCmp(system_bstr, stack_bstr, LOCALE_USER_DEFAULT, 0));
81
82 StackBstrVar(kSourceStrEmpty, empty);
83 UINT l1 = SysStringLen(stack_bstr);
84 UINT l2 = SysStringLen(StackBstr(kSourceStr));
85 UINT l3 = SysStringLen(system_bstr);
86 EXPECT_EQ(l1, l2);
87 EXPECT_EQ(l2, l3);
88 EXPECT_EQ(0, SysStringLen(empty));
89
90 const wchar_t one_more_test[] = L"this is my const string";
91 EXPECT_EQ(SysStringLen(StackBstr(one_more_test)),
92 lstrlen(one_more_test));
93 }
OLDNEW
« no previous file with comments | « base/win/scoped_bstr.cc ('k') | base/win/scoped_comptr.h » ('j') | base/win/scoped_comptr.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698