diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 20:27:29 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-14 20:27:29 +0000 |
commit | cb2f36323ab5dbecc2ecc6e00ec04956e49b356b (patch) | |
tree | 1147a72e3e49ffb869aa67e8084309ed4d616c54 | |
parent | edc286198b90c629bbf6081440512d02aef603d8 (diff) | |
download | chromium_src-cb2f36323ab5dbecc2ecc6e00ec04956e49b356b.zip chromium_src-cb2f36323ab5dbecc2ecc6e00ec04956e49b356b.tar.gz chromium_src-cb2f36323ab5dbecc2ecc6e00ec04956e49b356b.tar.bz2 |
Fix some compiler warnings, and cleanup EXPECT_EQ comparisons. Hello "U" suffix :-)
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@882 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/command_line_unittest.cc | 4 | ||||
-rw-r--r-- | base/json_reader_unittest.cc | 12 | ||||
-rw-r--r-- | base/observer_list.h | 4 | ||||
-rw-r--r-- | base/string_util_unittest.cc | 62 |
4 files changed, 41 insertions, 41 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index a564f0b..d9992c2 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -81,7 +81,7 @@ TEST(CommandLineTest, CommandLineConstructor) { EXPECT_EQ(L"--dog=canine --cat=feline", cl.GetSwitchValue(L"other-switches")); EXPECT_EQ(L"45--output-rotation", cl.GetSwitchValue(L"input-translation")); - EXPECT_EQ(static_cast<size_t>(3), cl.GetLooseValueCount()); + EXPECT_EQ(3U, cl.GetLooseValueCount()); CommandLine::LooseValueIterator iter = cl.GetLooseValuesBegin(); EXPECT_EQ(L"flim", *iter); @@ -109,7 +109,7 @@ TEST(CommandLineTest, EmptyString) { #endif EXPECT_TRUE(cl.command_line_string().empty()); EXPECT_TRUE(cl.program().empty()); - EXPECT_EQ(static_cast<size_t>(0), cl.GetLooseValueCount()); + EXPECT_EQ(0U, cl.GetLooseValueCount()); } // Test static functions for appending switches to a command line. diff --git a/base/json_reader_unittest.cc b/base/json_reader_unittest.cc index da902f2..13c4228 100644 --- a/base/json_reader_unittest.cc +++ b/base/json_reader_unittest.cc @@ -291,7 +291,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(Value::TYPE_LIST)); ListValue* list = static_cast<ListValue*>(root); - ASSERT_EQ(static_cast<size_t>(3), list->GetSize()); + ASSERT_EQ(3U, list->GetSize()); // Test with trailing comma. Should be parsed the same as above. Value* root2 = NULL; @@ -306,7 +306,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root); - ASSERT_EQ(static_cast<size_t>(0), list->GetSize()); + ASSERT_EQ(0U, list->GetSize()); delete root; // Nested arrays @@ -316,7 +316,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root); - ASSERT_EQ(static_cast<size_t>(4), list->GetSize()); + ASSERT_EQ(4U, list->GetSize()); // Lots of trailing commas. root2 = NULL; @@ -354,7 +354,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root); - EXPECT_EQ(static_cast<size_t>(1), list->GetSize()); + EXPECT_EQ(1U, list->GetSize()); Value* tmp_value = NULL; ASSERT_TRUE(list->Get(0, &tmp_value)); EXPECT_TRUE(tmp_value->IsType(Value::TYPE_BOOLEAN)); @@ -418,7 +418,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(dict_val->GetDictionary(L"inner", &inner_dict)); ListValue* inner_array = NULL; ASSERT_TRUE(inner_dict->GetList(L"array", &inner_array)); - ASSERT_EQ(static_cast<size_t>(1), inner_array->GetSize()); + ASSERT_EQ(1U, inner_array->GetSize()); bool_value = true; ASSERT_TRUE(dict_val->GetBoolean(L"false", &bool_value)); ASSERT_FALSE(bool_value); @@ -492,7 +492,7 @@ TEST(JSONReaderTest, Reading) { ASSERT_TRUE(root); ASSERT_TRUE(root->IsType(Value::TYPE_LIST)); list = static_cast<ListValue*>(root); - ASSERT_EQ(static_cast<size_t>(5001), list->GetSize()); + ASSERT_EQ(5001U, list->GetSize()); delete root; // Test utf8 encoded input diff --git a/base/observer_list.h b/base/observer_list.h index 0242d6a..f4876df 100644 --- a/base/observer_list.h +++ b/base/observer_list.h @@ -87,7 +87,7 @@ class ObserverList { // When check_empty is true, assert that the list is empty on destruction. if (check_empty) { Compact(); - DCHECK_EQ(observers_.size(), 0); + DCHECK_EQ(observers_.size(), 0U); } } @@ -164,7 +164,7 @@ class ObserverList { do { \ ObserverList<ObserverType>::Iterator it(observer_list); \ ObserverType* obs; \ - while (obs = it.GetNext()) \ + while ((obs = it.GetNext()) != NULL) \ obs->func; \ } while (0) diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index c286222..8807aaf7 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -227,14 +227,14 @@ TEST(StringUtilTest, ConvertUTF8ToWide) { // Manually test an embedded NULL. std::wstring converted; EXPECT_TRUE(UTF8ToWide("\00Z\t", 3, &converted)); - ASSERT_EQ(static_cast<std::wstring::size_type>(3), converted.length()); + ASSERT_EQ(3U, converted.length()); EXPECT_EQ(0, converted[0]); EXPECT_EQ('Z', converted[1]); EXPECT_EQ('\t', converted[2]); // Make sure that conversion replaces, not appends. EXPECT_TRUE(UTF8ToWide("B", 1, &converted)); - ASSERT_EQ(static_cast<std::wstring::size_type>(1), converted.length()); + ASSERT_EQ(1U, converted.length()); EXPECT_EQ('B', converted[0]); } @@ -665,14 +665,14 @@ TEST(StringUtilTest, IntToString) { "9223372036854775808" }, }; - for (int i = 0; i < arraysize(int_tests); ++i) { + for (size_t i = 0; i < arraysize(int_tests); ++i) { const IntToStringTest<int>* test = &int_tests[i]; EXPECT_EQ(IntToString(test->num), test->sexpected); EXPECT_EQ(IntToWString(test->num), UTF8ToWide(test->sexpected)); EXPECT_EQ(UintToString(test->num), test->uexpected); EXPECT_EQ(UintToWString(test->num), UTF8ToWide(test->uexpected)); } - for (int i = 0; i < arraysize(int64_tests); ++i) { + for (size_t i = 0; i < arraysize(int64_tests); ++i) { const IntToStringTest<int64>* test = &int64_tests[i]; EXPECT_EQ(Int64ToString(test->num), test->sexpected); EXPECT_EQ(Int64ToWString(test->num), UTF8ToWide(test->sexpected)); @@ -1104,50 +1104,50 @@ TEST(StringUtilTest, SplitString) { std::vector<std::wstring> r; SplitString(L"a,b,c", L',', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(3), r.size()); + EXPECT_EQ(3U, r.size()); EXPECT_EQ(r[0], L"a"); EXPECT_EQ(r[1], L"b"); EXPECT_EQ(r[2], L"c"); r.clear(); SplitString(L"a, b, c", L',', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(3), r.size()); + EXPECT_EQ(3U, r.size()); EXPECT_EQ(r[0], L"a"); EXPECT_EQ(r[1], L"b"); EXPECT_EQ(r[2], L"c"); r.clear(); SplitString(L"a,,c", L',', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(3), r.size()); + EXPECT_EQ(3U, r.size()); EXPECT_EQ(r[0], L"a"); EXPECT_EQ(r[1], L""); EXPECT_EQ(r[2], L"c"); r.clear(); SplitString(L"", L'*', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(1), r.size()); + EXPECT_EQ(1U, r.size()); EXPECT_EQ(r[0], L""); r.clear(); SplitString(L"foo", L'*', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(1), r.size()); + EXPECT_EQ(1U, r.size()); EXPECT_EQ(r[0], L"foo"); r.clear(); SplitString(L"foo ,", L',', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(2), r.size()); + EXPECT_EQ(2U, r.size()); EXPECT_EQ(r[0], L"foo"); EXPECT_EQ(r[1], L""); r.clear(); SplitString(L",", L',', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(2), r.size()); + EXPECT_EQ(2U, r.size()); EXPECT_EQ(r[0], L""); EXPECT_EQ(r[1], L""); r.clear(); SplitString(L"\t\ta\t", L'\t', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(4), r.size()); + EXPECT_EQ(4U, r.size()); EXPECT_EQ(r[0], L""); EXPECT_EQ(r[1], L""); EXPECT_EQ(r[2], L"a"); @@ -1155,7 +1155,7 @@ TEST(StringUtilTest, SplitString) { r.clear(); SplitStringDontTrim(L"\t\ta\t", L'\t', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(4), r.size()); + EXPECT_EQ(4U, r.size()); EXPECT_EQ(r[0], L""); EXPECT_EQ(r[1], L""); EXPECT_EQ(r[2], L"a"); @@ -1163,13 +1163,13 @@ TEST(StringUtilTest, SplitString) { r.clear(); SplitString(L"\ta\t\nb\tcc", L'\n', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(2), r.size()); + EXPECT_EQ(2U, r.size()); EXPECT_EQ(r[0], L"a"); EXPECT_EQ(r[1], L"b\tcc"); r.clear(); SplitStringDontTrim(L"\ta\t\nb\tcc", L'\n', &r); - EXPECT_EQ(static_cast<std::vector<std::wstring>::size_type>(2), r.size()); + EXPECT_EQ(2U, r.size()); EXPECT_EQ(r[0], L"\ta\t"); EXPECT_EQ(r[1], L"b\tcc"); r.clear(); @@ -1188,16 +1188,16 @@ TEST(StringUtilTest, GetStringFWithOffsets) { ReplaceStringPlaceholders(L"Hello, $1. Your number is $2.", L"1", L"2", &offsets); - EXPECT_EQ(static_cast<std::vector<size_t>::size_type>(2), offsets.size()); - EXPECT_EQ(static_cast<size_t>(7), offsets[0]); - EXPECT_EQ(static_cast<size_t>(25), offsets[1]); + EXPECT_EQ(2U, offsets.size()); + EXPECT_EQ(7U, offsets[0]); + EXPECT_EQ(25U, offsets[1]); offsets.clear(); ReplaceStringPlaceholders(L"Hello, $2. Your number is $1.", L"1", L"2", &offsets); - EXPECT_EQ(static_cast<std::vector<size_t>::size_type>(2), offsets.size()); - EXPECT_EQ(static_cast<size_t>(25), offsets[0]); - EXPECT_EQ(static_cast<size_t>(7), offsets[1]); + EXPECT_EQ(2U, offsets.size()); + EXPECT_EQ(25U, offsets[0]); + EXPECT_EQ(7U, offsets[1]); offsets.clear(); } @@ -1257,9 +1257,9 @@ TEST(StringUtilTest, LcpyTest) { { char dst[10]; wchar_t wdst[10]; - EXPECT_EQ(7, base::strlcpy(dst, "abcdefg", arraysize(dst))); + EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst))); EXPECT_EQ(0, memcmp(dst, "abcdefg", 8)); - EXPECT_EQ(7, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); + EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); EXPECT_EQ(0, memcmp(wdst, L"abcdefg", sizeof(wchar_t) * 8)); } @@ -1268,10 +1268,10 @@ TEST(StringUtilTest, LcpyTest) { { char dst[2] = {1, 2}; wchar_t wdst[2] = {1, 2}; - EXPECT_EQ(7, base::strlcpy(dst, "abcdefg", 0)); + EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", 0)); EXPECT_EQ(1, dst[0]); EXPECT_EQ(2, dst[1]); - EXPECT_EQ(7, base::wcslcpy(wdst, L"abcdefg", 0)); + EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", 0)); EXPECT_EQ(1, wdst[0]); EXPECT_EQ(2, wdst[1]); } @@ -1280,9 +1280,9 @@ TEST(StringUtilTest, LcpyTest) { { char dst[8]; wchar_t wdst[8]; - EXPECT_EQ(7, base::strlcpy(dst, "abcdefg", arraysize(dst))); + EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst))); EXPECT_EQ(0, memcmp(dst, "abcdefg", 8)); - EXPECT_EQ(7, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); + EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); EXPECT_EQ(0, memcmp(wdst, L"abcdefg", sizeof(wchar_t) * 8)); } @@ -1290,9 +1290,9 @@ TEST(StringUtilTest, LcpyTest) { { char dst[7]; wchar_t wdst[7]; - EXPECT_EQ(7, base::strlcpy(dst, "abcdefg", arraysize(dst))); + EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst))); EXPECT_EQ(0, memcmp(dst, "abcdef", 7)); - EXPECT_EQ(7, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); + EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); EXPECT_EQ(0, memcmp(wdst, L"abcdef", sizeof(wchar_t) * 7)); } @@ -1300,9 +1300,9 @@ TEST(StringUtilTest, LcpyTest) { { char dst[3]; wchar_t wdst[3]; - EXPECT_EQ(7, base::strlcpy(dst, "abcdefg", arraysize(dst))); + EXPECT_EQ(7U, base::strlcpy(dst, "abcdefg", arraysize(dst))); EXPECT_EQ(0, memcmp(dst, "ab", 3)); - EXPECT_EQ(7, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); + EXPECT_EQ(7U, base::wcslcpy(wdst, L"abcdefg", arraysize(wdst))); EXPECT_EQ(0, memcmp(wdst, L"ab", sizeof(wchar_t) * 3)); } } |