summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 22:05:45 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 22:05:45 +0000
commitbc2ff51999fe9ef5c041f2df2ffbbdb4c30baec9 (patch)
tree98113aa6f92a67972c0000db1ef6dbd5979f94bd /base
parentff0450cc3834b456ab6eb8ee664eb5b98dcecbc0 (diff)
downloadchromium_src-bc2ff51999fe9ef5c041f2df2ffbbdb4c30baec9.zip
chromium_src-bc2ff51999fe9ef5c041f2df2ffbbdb4c30baec9.tar.gz
chromium_src-bc2ff51999fe9ef5c041f2df2ffbbdb4c30baec9.tar.bz2
Implement most of the ridealong fixes/cleanups I suggested during review for enabling warn-on-signed-versus-unsigned-equality-comparisions on Windows.
BUG=none TEST=none Review URL: http://codereview.chromium.org/2395001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48666 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/scoped_bstr_win_unittest.cc54
1 files changed, 27 insertions, 27 deletions
diff --git a/base/scoped_bstr_win_unittest.cc b/base/scoped_bstr_win_unittest.cc
index 276f13b..fbb327a 100644
--- a/base/scoped_bstr_win_unittest.cc
+++ b/base/scoped_bstr_win_unittest.cc
@@ -9,14 +9,14 @@ namespace {
static const wchar_t kTestString1[] = L"123";
static const wchar_t kTestString2[] = L"456789";
-uint32 test1_len = arraysize(kTestString1) - 1;
-uint32 test2_len = arraysize(kTestString2) - 1;
+size_t test1_len = arraysize(kTestString1) - 1;
+size_t test2_len = arraysize(kTestString2) - 1;
void DumbBstrTests() {
ScopedBstr b;
EXPECT_TRUE(b == NULL);
- EXPECT_TRUE(b.Length() == 0);
- EXPECT_TRUE(b.ByteLength() == 0);
+ EXPECT_EQ(0, b.Length());
+ EXPECT_EQ(0, b.ByteLength());
b.Reset(NULL);
EXPECT_TRUE(b == NULL);
EXPECT_TRUE(b.Release() == NULL);
@@ -31,17 +31,17 @@ void GiveMeABstr(BSTR* ret) {
void BasicBstrTests() {
ScopedBstr b1(kTestString1);
- EXPECT_TRUE(b1.Length() == test1_len);
- EXPECT_TRUE(b1.ByteLength() == test1_len * sizeof(kTestString1[0]));
+ EXPECT_EQ(test1_len, b1.Length());
+ EXPECT_EQ(test1_len * sizeof(kTestString1[0]), b1.ByteLength());
ScopedBstr b2;
b1.Swap(b2);
- EXPECT_TRUE(b2.Length() == test1_len);
- EXPECT_TRUE(b1.Length() == 0);
- EXPECT_TRUE(lstrcmpW(b2, kTestString1) == 0);
+ EXPECT_EQ(test1_len, b2.Length());
+ EXPECT_EQ(0, b1.Length());
+ EXPECT_EQ(0, lstrcmp(b2, kTestString1));
BSTR tmp = b2.Release();
EXPECT_TRUE(tmp != NULL);
- EXPECT_TRUE(lstrcmpW(tmp, kTestString1) == 0);
+ EXPECT_EQ(0, lstrcmp(tmp, kTestString1));
EXPECT_TRUE(b2 == NULL);
SysFreeString(tmp);
@@ -49,18 +49,18 @@ void BasicBstrTests() {
EXPECT_TRUE(b2 != NULL);
b2.Reset();
EXPECT_TRUE(b2.AllocateBytes(100) != NULL);
- EXPECT_TRUE(b2.ByteLength() == 100);
- EXPECT_TRUE(b2.Length() == 100 / sizeof(kTestString1[0]));
- lstrcpyW(static_cast<BSTR>(b2), kTestString1);
- EXPECT_TRUE(lstrlen(b2) == static_cast<int>(test1_len));
- EXPECT_TRUE(b2.Length() == 100 / sizeof(kTestString1[0]));
+ EXPECT_EQ(100, b2.ByteLength());
+ EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length());
+ lstrcpy(static_cast<BSTR>(b2), kTestString1);
+ EXPECT_EQ(test1_len, lstrlen(b2));
+ EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length());
b2.SetByteLen(lstrlen(b2) * sizeof(kTestString2[0]));
- EXPECT_TRUE(lstrlen(b2) == static_cast<int>(b2.Length()));
+ EXPECT_EQ(b2.Length(), lstrlen(b2));
EXPECT_TRUE(b1.Allocate(kTestString2) != NULL);
- EXPECT_TRUE(b1.Length() == test2_len);
+ EXPECT_EQ(test2_len, b1.Length());
b1.SetByteLen((test2_len - 1) * sizeof(kTestString2[0]));
- EXPECT_TRUE(b1.Length() == test2_len - 1);
+ EXPECT_EQ(test2_len - 1, b1.Length());
}
} // namespace
@@ -76,18 +76,18 @@ TEST(ScopedBstrTest, ScopedBstr) {
TEST(StackBstrTest, StackBstr) {
ScopedBstr system_bstr(kSourceStr);
StackBstrVar(kSourceStr, stack_bstr);
- EXPECT_EQ(VarBstrCmp(system_bstr, stack_bstr, LOCALE_USER_DEFAULT, 0),
- VARCMP_EQ);
+ EXPECT_EQ(VARCMP_EQ,
+ VarBstrCmp(system_bstr, stack_bstr, LOCALE_USER_DEFAULT, 0));
StackBstrVar(kSourceStrEmpty, empty);
- uint32 l1 = SysStringLen(stack_bstr);
- uint32 l2 = SysStringLen(StackBstr(kSourceStr));
- uint32 l3 = SysStringLen(system_bstr);
- EXPECT_TRUE(l1 == l2);
- EXPECT_TRUE(l2 == l3);
- EXPECT_TRUE(SysStringLen(empty) == 0);
+ UINT l1 = SysStringLen(stack_bstr);
+ UINT l2 = SysStringLen(StackBstr(kSourceStr));
+ UINT l3 = SysStringLen(system_bstr);
+ EXPECT_EQ(l1, l2);
+ EXPECT_EQ(l2, l3);
+ EXPECT_EQ(0, SysStringLen(empty));
const wchar_t one_more_test[] = L"this is my const string";
EXPECT_EQ(SysStringLen(StackBstr(one_more_test)),
- lstrlenW(one_more_test));
+ lstrlen(one_more_test));
}