summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 17:04:28 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-03 17:04:28 +0000
commit35dabb168a48a717d9ba0ecabff33295abf9f073 (patch)
tree36a182c2ff5868c6c0d07c9c8b73ce0a73b72b5e
parent8be50f06b56d45e148a0f84118ba0f8c2aa61db0 (diff)
downloadchromium_src-35dabb168a48a717d9ba0ecabff33295abf9f073.zip
chromium_src-35dabb168a48a717d9ba0ecabff33295abf9f073.tar.gz
chromium_src-35dabb168a48a717d9ba0ecabff33295abf9f073.tar.bz2
base: Use TEST() macro when possible.
There is no need to inherit from testing::Test and then have to use TEST_F(), if you aren't overridding SetUp() or TearDow(). So if you don't need to customize it, you can use TEST() macro directly and it does that for us automagically. Fix all the cases found with the following command line: $ git grep -n1 "public testing::Test" base/ | grep "};" TEST=base_unittests R=willchan@chromium.org Review URL: https://codereview.chromium.org/11308261 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170747 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_version_info_unittest.cc3
-rw-r--r--base/id_map_unittest.cc22
-rw-r--r--base/message_loop_unittest.cc2
-rw-r--r--base/prefs/pref_value_map_unittest.cc16
-rw-r--r--base/string_tokenizer_unittest.cc5
-rw-r--r--base/version_unittest.cc19
-rw-r--r--base/vlog_unittest.cc11
7 files changed, 34 insertions, 44 deletions
diff --git a/base/file_version_info_unittest.cc b/base/file_version_info_unittest.cc
index 4184e04..916e7bc5 100644
--- a/base/file_version_info_unittest.cc
+++ b/base/file_version_info_unittest.cc
@@ -14,9 +14,6 @@
namespace {
-class FileVersionInfoTest : public testing::Test {
-};
-
#if defined(OS_WIN)
FilePath GetTestDataPath() {
FilePath path;
diff --git a/base/id_map_unittest.cc b/base/id_map_unittest.cc
index 80c4c66..76d7c3e 100644
--- a/base/id_map_unittest.cc
+++ b/base/id_map_unittest.cc
@@ -8,9 +8,6 @@
namespace {
-class IDMapTest : public testing::Test {
-};
-
class TestObject {
};
@@ -18,11 +15,12 @@ class DestructorCounter {
public:
explicit DestructorCounter(int* counter) : counter_(counter) {}
~DestructorCounter() { ++(*counter_); }
+
private:
int* counter_;
};
-TEST_F(IDMapTest, Basic) {
+TEST(IDMapTest, Basic) {
IDMap<TestObject> map;
EXPECT_TRUE(map.IsEmpty());
EXPECT_EQ(0U, map.size());
@@ -58,7 +56,7 @@ TEST_F(IDMapTest, Basic) {
EXPECT_EQ(0, map.iteration_depth());
}
-TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) {
+TEST(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) {
IDMap<TestObject> map;
TestObject obj1;
@@ -91,7 +89,7 @@ TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingCurrentElement) {
EXPECT_EQ(0, map.iteration_depth());
}
-TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) {
+TEST(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) {
IDMap<TestObject> map;
const int kCount = 5;
@@ -133,7 +131,7 @@ TEST_F(IDMapTest, IteratorRemainsValidWhenRemovingOtherElements) {
EXPECT_EQ(0, map.iteration_depth());
}
-TEST_F(IDMapTest, CopyIterator) {
+TEST(IDMapTest, CopyIterator) {
IDMap<TestObject> map;
TestObject obj1;
@@ -161,7 +159,7 @@ TEST_F(IDMapTest, CopyIterator) {
EXPECT_EQ(0, map.iteration_depth());
}
-TEST_F(IDMapTest, AssignIterator) {
+TEST(IDMapTest, AssignIterator) {
IDMap<TestObject> map;
TestObject obj1;
@@ -191,7 +189,7 @@ TEST_F(IDMapTest, AssignIterator) {
EXPECT_EQ(0, map.iteration_depth());
}
-TEST_F(IDMapTest, IteratorRemainsValidWhenClearing) {
+TEST(IDMapTest, IteratorRemainsValidWhenClearing) {
IDMap<TestObject> map;
const int kCount = 5;
@@ -227,7 +225,7 @@ TEST_F(IDMapTest, IteratorRemainsValidWhenClearing) {
EXPECT_EQ(0U, map.size());
}
-TEST_F(IDMapTest, OwningPointersDeletesThemOnRemove) {
+TEST(IDMapTest, OwningPointersDeletesThemOnRemove) {
const int kCount = 3;
int external_del_count = 0;
@@ -265,7 +263,7 @@ TEST_F(IDMapTest, OwningPointersDeletesThemOnRemove) {
EXPECT_EQ(owned_del_count, kCount);
}
-TEST_F(IDMapTest, OwningPointersDeletesThemOnClear) {
+TEST(IDMapTest, OwningPointersDeletesThemOnClear) {
const int kCount = 3;
int external_del_count = 0;
@@ -302,7 +300,7 @@ TEST_F(IDMapTest, OwningPointersDeletesThemOnClear) {
EXPECT_EQ(owned_del_count, kCount);
}
-TEST_F(IDMapTest, OwningPointersDeletesThemOnDestruct) {
+TEST(IDMapTest, OwningPointersDeletesThemOnDestruct) {
const int kCount = 3;
int external_del_count = 0;
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index 62721d3..ba37b2f 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -33,8 +33,6 @@ using base::TimeTicks;
namespace {
-class MessageLoopTest : public testing::Test {};
-
class Foo : public base::RefCounted<Foo> {
public:
Foo() : test_count_(0) {
diff --git a/base/prefs/pref_value_map_unittest.cc b/base/prefs/pref_value_map_unittest.cc
index b406db8..48ee747 100644
--- a/base/prefs/pref_value_map_unittest.cc
+++ b/base/prefs/pref_value_map_unittest.cc
@@ -3,13 +3,11 @@
// found in the LICENSE file.
#include "base/prefs/pref_value_map.h"
+
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
-class PrefValueMapTest : public testing::Test {
-};
-
-TEST_F(PrefValueMapTest, SetValue) {
+TEST(PrefValueMapTest, SetValue) {
PrefValueMap map;
const Value* result = NULL;
EXPECT_FALSE(map.GetValue("key", &result));
@@ -23,7 +21,7 @@ TEST_F(PrefValueMapTest, SetValue) {
EXPECT_TRUE(StringValue("hi mom!").Equals(result));
}
-TEST_F(PrefValueMapTest, GetAndSetIntegerValue) {
+TEST(PrefValueMapTest, GetAndSetIntegerValue) {
PrefValueMap map;
ASSERT_TRUE(map.SetValue("key", Value::CreateIntegerValue(5)));
@@ -36,7 +34,7 @@ TEST_F(PrefValueMapTest, GetAndSetIntegerValue) {
EXPECT_EQ(-14, int_value);
}
-TEST_F(PrefValueMapTest, RemoveValue) {
+TEST(PrefValueMapTest, RemoveValue) {
PrefValueMap map;
EXPECT_FALSE(map.RemoveValue("key"));
@@ -49,7 +47,7 @@ TEST_F(PrefValueMapTest, RemoveValue) {
EXPECT_FALSE(map.RemoveValue("key"));
}
-TEST_F(PrefValueMapTest, Clear) {
+TEST(PrefValueMapTest, Clear) {
PrefValueMap map;
EXPECT_TRUE(map.SetValue("key", Value::CreateStringValue("test")));
EXPECT_TRUE(map.GetValue("key", NULL));
@@ -59,7 +57,7 @@ TEST_F(PrefValueMapTest, Clear) {
EXPECT_FALSE(map.GetValue("key", NULL));
}
-TEST_F(PrefValueMapTest, GetDifferingKeys) {
+TEST(PrefValueMapTest, GetDifferingKeys) {
PrefValueMap reference;
EXPECT_TRUE(reference.SetValue("b", Value::CreateStringValue("test")));
EXPECT_TRUE(reference.SetValue("c", Value::CreateStringValue("test")));
@@ -88,7 +86,7 @@ TEST_F(PrefValueMapTest, GetDifferingKeys) {
EXPECT_EQ(expected_differing_paths, differing_paths);
}
-TEST_F(PrefValueMapTest, SwapTwoMaps) {
+TEST(PrefValueMapTest, SwapTwoMaps) {
PrefValueMap first_map;
EXPECT_TRUE(first_map.SetValue("a", Value::CreateStringValue("test")));
EXPECT_TRUE(first_map.SetValue("b", Value::CreateStringValue("test")));
diff --git a/base/string_tokenizer_unittest.cc b/base/string_tokenizer_unittest.cc
index 80cb960..61841f2 100644
--- a/base/string_tokenizer_unittest.cc
+++ b/base/string_tokenizer_unittest.cc
@@ -3,13 +3,12 @@
// found in the LICENSE file.
#include "base/string_tokenizer.h"
+
#include "testing/gtest/include/gtest/gtest.h"
using std::string;
namespace {
-class StringTokenizerTest : public testing::Test {};
-}
TEST(StringTokenizerTest, Simple) {
string input = "this is a test";
@@ -227,3 +226,5 @@ TEST(StringTokenizerTest, ParseQuotedString_EscapedQuotes2) {
EXPECT_FALSE(t.GetNext());
}
+
+} // namespace
diff --git a/base/version_unittest.cc b/base/version_unittest.cc
index 15f3052..2a2309e 100644
--- a/base/version_unittest.cc
+++ b/base/version_unittest.cc
@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/scoped_ptr.h"
#include "base/version.h"
+
#include "testing/gtest/include/gtest/gtest.h"
-class VersionTest : public testing::Test {
-};
+namespace {
-TEST_F(VersionTest, DefaultConstructor) {
+TEST(VersionTest, DefaultConstructor) {
Version v;
EXPECT_FALSE(v.IsValid());
}
-TEST_F(VersionTest, ValueSemantics) {
+TEST(VersionTest, ValueSemantics) {
Version v1("1.2.3.4");
EXPECT_TRUE(v1.IsValid());
Version v3;
@@ -28,7 +27,7 @@ TEST_F(VersionTest, ValueSemantics) {
EXPECT_TRUE(v3.Equals(v1));
}
-TEST_F(VersionTest, GetVersionFromString) {
+TEST(VersionTest, GetVersionFromString) {
static const struct version_string {
const char* input;
size_t parts;
@@ -62,7 +61,7 @@ TEST_F(VersionTest, GetVersionFromString) {
}
}
-TEST_F(VersionTest, Compare) {
+TEST(VersionTest, Compare) {
static const struct version_compare {
const char* lhs;
const char* rhs;
@@ -89,7 +88,7 @@ TEST_F(VersionTest, Compare) {
}
}
-TEST_F(VersionTest, CompareToWildcardString) {
+TEST(VersionTest, CompareToWildcardString) {
static const struct version_compare {
const char* lhs;
const char* rhs;
@@ -116,7 +115,7 @@ TEST_F(VersionTest, CompareToWildcardString) {
}
}
-TEST_F(VersionTest, IsValidWildcardString) {
+TEST(VersionTest, IsValidWildcardString) {
static const struct version_compare {
const char* version;
bool expected;
@@ -138,3 +137,5 @@ TEST_F(VersionTest, IsValidWildcardString) {
cases[i].expected) << cases[i].version << "?" << cases[i].expected;
}
}
+
+} // namespace
diff --git a/base/vlog_unittest.cc b/base/vlog_unittest.cc
index f583f44..ef7247f 100644
--- a/base/vlog_unittest.cc
+++ b/base/vlog_unittest.cc
@@ -14,10 +14,7 @@ namespace logging {
namespace {
-class VlogTest : public testing::Test {
-};
-
-TEST_F(VlogTest, NoVmodule) {
+TEST(VlogTest, NoVmodule) {
int min_log_level = 0;
EXPECT_EQ(0, VlogInfo("", "", &min_log_level).GetVlogLevel("test1"));
EXPECT_EQ(0, VlogInfo("0", "", &min_log_level).GetVlogLevel("test2"));
@@ -27,7 +24,7 @@ TEST_F(VlogTest, NoVmodule) {
EXPECT_EQ(5, VlogInfo("5", "", &min_log_level).GetVlogLevel("test6"));
}
-TEST_F(VlogTest, MatchVlogPattern) {
+TEST(VlogTest, MatchVlogPattern) {
// Degenerate cases.
EXPECT_TRUE(MatchVlogPattern("", ""));
EXPECT_TRUE(MatchVlogPattern("", "****"));
@@ -75,7 +72,7 @@ TEST_F(VlogTest, MatchVlogPattern) {
EXPECT_TRUE(MatchVlogPattern("\\b/lah", "/b\\lah"));
}
-TEST_F(VlogTest, VmoduleBasic) {
+TEST(VlogTest, VmoduleBasic) {
const char kVSwitch[] = "-1";
const char kVModuleSwitch[] =
"foo=,bar=0,baz=blah,,qux=0blah1,quux=1,corge.ext=5";
@@ -91,7 +88,7 @@ TEST_F(VlogTest, VmoduleBasic) {
EXPECT_EQ(5, vlog_info.GetVlogLevel("c:\\path/to/corge.ext.h"));
}
-TEST_F(VlogTest, VmoduleDirs) {
+TEST(VlogTest, VmoduleDirs) {
const char kVModuleSwitch[] =
"foo/bar.cc=1,baz\\*\\qux.cc=2,*quux/*=3,*/*-inl.h=4";
int min_log_level = 0;