diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-22 00:37:21 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-22 00:37:21 +0000 |
commit | 7a1c5ab3654723cfe4489e6981dcd67da1489f3f (patch) | |
tree | fca8c695a824dd834b95c29b5f618f6673066a5f /base/stats_table_unittest.cc | |
parent | f5eddaf87e378c29412a028e027f91d48fbab551 (diff) | |
download | chromium_src-7a1c5ab3654723cfe4489e6981dcd67da1489f3f.zip chromium_src-7a1c5ab3654723cfe4489e6981dcd67da1489f3f.tar.gz chromium_src-7a1c5ab3654723cfe4489e6981dcd67da1489f3f.tar.bz2 |
Remove use of wide characters in stats table identifiers.
Review URL: http://codereview.chromium.org/11544
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/stats_table_unittest.cc')
-rw-r--r-- | base/stats_table_unittest.cc | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/base/stats_table_unittest.cc b/base/stats_table_unittest.cc index 68a07ac..59b1215 100644 --- a/base/stats_table_unittest.cc +++ b/base/stats_table_unittest.cc @@ -24,27 +24,27 @@ class StatsTableTest : public MultiProcessTest { // Open a StatsTable and verify that we can write to each of the // locations in the table. TEST_F(StatsTableTest, VerifySlots) { - const std::wstring kTableName = L"VerifySlotsStatTable"; + const std::string kTableName = "VerifySlotsStatTable"; const int kMaxThreads = 1; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); // Register a single thread. - std::wstring thread_name = L"mainThread"; + std::string thread_name = "mainThread"; int slot_id = table.RegisterThread(thread_name); EXPECT_TRUE(slot_id); // Fill up the table with counters. - std::wstring counter_base_name = L"counter"; + std::string counter_base_name = "counter"; for (int index=0; index < kMaxCounter; index++) { - std::wstring counter_name = counter_base_name; - StringAppendF(&counter_name, L"counter.ctr%d", index); + std::string counter_name = counter_base_name; + StringAppendF(&counter_name, "counter.ctr%d", index); int counter_id = table.FindCounter(counter_name); EXPECT_GT(counter_id, 0); } // Try to allocate an additional thread. Verify it fails. - slot_id = table.RegisterThread(L"too many threads"); + slot_id = table.RegisterThread("too many threads"); EXPECT_EQ(slot_id, 0); // Try to allocate an additional counter. Verify it fails. @@ -53,16 +53,16 @@ TEST_F(StatsTableTest, VerifySlots) { } // CounterZero will continually be set to 0. -const std::wstring kCounterZero = L"CounterZero"; +const std::string kCounterZero = "CounterZero"; // Counter1313 will continually be set to 1313. -const std::wstring kCounter1313 = L"Counter1313"; +const std::string kCounter1313 = "Counter1313"; // CounterIncrement will be incremented each time. -const std::wstring kCounterIncrement = L"CounterIncrement"; +const std::string kCounterIncrement = "CounterIncrement"; // CounterDecrement will be decremented each time. -const std::wstring kCounterDecrement = L"CounterDecrement"; +const std::string kCounterDecrement = "CounterDecrement"; // CounterMixed will be incremented by odd numbered threads and // decremented by even threads. -const std::wstring kCounterMixed = L"CounterMixed"; +const std::string kCounterMixed = "CounterMixed"; // The number of thread loops that we will do. const int kThreadLoops = 1000; @@ -101,7 +101,7 @@ void StatsTableThread::Run() { // Create a few threads and have them poke on their counters. TEST_F(StatsTableTest, MultipleThreads) { // Create a stats table. - const std::wstring kTableName = L"MultipleThreadStatTable"; + const std::string kTableName = "MultipleThreadStatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); @@ -133,25 +133,25 @@ TEST_F(StatsTableTest, MultipleThreads) { StatsCounter mixed_counter(kCounterMixed); // Verify the various counters are correct. - std::wstring name; - name = L"c:" + kCounterZero; + std::string name; + name = "c:" + kCounterZero; EXPECT_EQ(0, table.GetCounterValue(name)); - name = L"c:" + kCounter1313; + name = "c:" + kCounter1313; EXPECT_EQ(1313 * kMaxThreads, table.GetCounterValue(name)); - name = L"c:" + kCounterIncrement; + name = "c:" + kCounterIncrement; EXPECT_EQ(kMaxThreads * kThreadLoops, table.GetCounterValue(name)); - name = L"c:" + kCounterDecrement; + name = "c:" + kCounterDecrement; EXPECT_EQ(-kMaxThreads * kThreadLoops, table.GetCounterValue(name)); - name = L"c:" + kCounterMixed; + name = "c:" + kCounterMixed; EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, table.GetCounterValue(name)); EXPECT_EQ(0, table.CountThreadsRegistered()); } -const std::wstring kTableName = L"MultipleProcessStatTable"; +const std::string kTableName = "MultipleProcessStatTable"; MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { // Each process will open the shared memory and set counters @@ -177,7 +177,7 @@ MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { // Create a few processes and have them poke on their counters. TEST_F(StatsTableTest, MultipleProcesses) { // Create a stats table. - const std::wstring kTableName = L"MultipleProcessStatTable"; + const std::string kTableName = "MultipleProcessStatTable"; const int kMaxProcs = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxProcs, kMaxCounter); @@ -207,16 +207,16 @@ TEST_F(StatsTableTest, MultipleProcesses) { StatsCounter decrement_counter(kCounterDecrement); // Verify the various counters are correct. - std::wstring name; - name = L"c:" + kCounterZero; + std::string name; + name = "c:" + kCounterZero; EXPECT_EQ(0, table.GetCounterValue(name)); - name = L"c:" + kCounter1313; + name = "c:" + kCounter1313; EXPECT_EQ(1313 * kMaxProcs, table.GetCounterValue(name)); - name = L"c:" + kCounterIncrement; + name = "c:" + kCounterIncrement; EXPECT_EQ(kMaxProcs * kThreadLoops, table.GetCounterValue(name)); - name = L"c:" + kCounterDecrement; + name = "c:" + kCounterDecrement; EXPECT_EQ(-kMaxProcs * kThreadLoops, table.GetCounterValue(name)); EXPECT_EQ(0, table.CountThreadsRegistered()); @@ -224,7 +224,7 @@ TEST_F(StatsTableTest, MultipleProcesses) { class MockStatsCounter : public StatsCounter { public: - MockStatsCounter(const std::wstring& name) + MockStatsCounter(const std::string& name) : StatsCounter(name) {} int* Pointer() { return GetPtr(); } }; @@ -232,50 +232,50 @@ class MockStatsCounter : public StatsCounter { // Test some basic StatsCounter operations TEST_F(StatsTableTest, StatsCounter) { // Create a stats table. - const std::wstring kTableName = L"StatTable"; + const std::string kTableName = "StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - MockStatsCounter foo(L"foo"); + MockStatsCounter foo("foo"); // Test initial state. EXPECT_TRUE(foo.Enabled()); EXPECT_NE(foo.Pointer(), static_cast<int*>(0)); - EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(0, table.GetCounterValue("c:foo")); EXPECT_EQ(0, *(foo.Pointer())); // Test Increment. while(*(foo.Pointer()) < 123) foo.Increment(); - EXPECT_EQ(123, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(123, table.GetCounterValue("c:foo")); foo.Add(0); - EXPECT_EQ(123, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(123, table.GetCounterValue("c:foo")); foo.Add(-1); - EXPECT_EQ(122, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(122, table.GetCounterValue("c:foo")); // Test Set. foo.Set(0); - EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(0, table.GetCounterValue("c:foo")); foo.Set(100); - EXPECT_EQ(100, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(100, table.GetCounterValue("c:foo")); foo.Set(-1); - EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(-1, table.GetCounterValue("c:foo")); foo.Set(0); - EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(0, table.GetCounterValue("c:foo")); // Test Decrement. foo.Decrement(1); - EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(-1, table.GetCounterValue("c:foo")); foo.Decrement(0); - EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(-1, table.GetCounterValue("c:foo")); foo.Decrement(-1); - EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); + EXPECT_EQ(0, table.GetCounterValue("c:foo")); } class MockStatsCounterTimer : public StatsCounterTimer { public: - MockStatsCounterTimer(const std::wstring& name) + MockStatsCounterTimer(const std::string& name) : StatsCounterTimer(name) {} TimeTicks start_time() { return start_time_; } @@ -285,13 +285,13 @@ class MockStatsCounterTimer : public StatsCounterTimer { // Test some basic StatsCounterTimer operations TEST_F(StatsTableTest, StatsCounterTimer) { // Create a stats table. - const std::wstring kTableName = L"StatTable"; + const std::string kTableName = "StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - MockStatsCounterTimer bar(L"bar"); + MockStatsCounterTimer bar("bar"); // Test initial state. EXPECT_FALSE(bar.Running()); @@ -302,62 +302,62 @@ TEST_F(StatsTableTest, StatsCounterTimer) { bar.Start(); PlatformThread::Sleep(500); bar.Stop(); - EXPECT_LE(500, table.GetCounterValue(L"t:bar")); + EXPECT_LE(500, table.GetCounterValue("t:bar")); // Verify that timing again is additive. bar.Start(); PlatformThread::Sleep(500); bar.Stop(); - EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); + EXPECT_LE(1000, table.GetCounterValue("t:bar")); } // Test some basic StatsRate operations TEST_F(StatsTableTest, StatsRate) { // Create a stats table. - const std::wstring kTableName = L"StatTable"; + const std::string kTableName = "StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - StatsRate baz(L"baz"); + StatsRate baz("baz"); // Test initial state. EXPECT_FALSE(baz.Running()); - EXPECT_EQ(0, table.GetCounterValue(L"c:baz")); - EXPECT_EQ(0, table.GetCounterValue(L"t:baz")); + EXPECT_EQ(0, table.GetCounterValue("c:baz")); + EXPECT_EQ(0, table.GetCounterValue("t:baz")); // Do some timing. baz.Start(); PlatformThread::Sleep(500); baz.Stop(); - EXPECT_EQ(1, table.GetCounterValue(L"c:baz")); - EXPECT_LE(500, table.GetCounterValue(L"t:baz")); + EXPECT_EQ(1, table.GetCounterValue("c:baz")); + EXPECT_LE(500, table.GetCounterValue("t:baz")); // Verify that timing again is additive. baz.Start(); PlatformThread::Sleep(500); baz.Stop(); - EXPECT_EQ(2, table.GetCounterValue(L"c:baz")); - EXPECT_LE(1000, table.GetCounterValue(L"t:baz")); + EXPECT_EQ(2, table.GetCounterValue("c:baz")); + EXPECT_LE(1000, table.GetCounterValue("t:baz")); } // Test some basic StatsScope operations TEST_F(StatsTableTest, StatsScope) { // Create a stats table. - const std::wstring kTableName = L"StatTable"; + const std::string kTableName = "StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - StatsCounterTimer foo(L"foo"); - StatsRate bar(L"bar"); + StatsCounterTimer foo("foo"); + StatsRate bar("bar"); // Test initial state. - EXPECT_EQ(0, table.GetCounterValue(L"t:foo")); - EXPECT_EQ(0, table.GetCounterValue(L"t:bar")); - EXPECT_EQ(0, table.GetCounterValue(L"c:bar")); + EXPECT_EQ(0, table.GetCounterValue("t:foo")); + EXPECT_EQ(0, table.GetCounterValue("t:bar")); + EXPECT_EQ(0, table.GetCounterValue("c:bar")); // Try a scope. { @@ -365,9 +365,9 @@ TEST_F(StatsTableTest, StatsScope) { StatsScope<StatsRate> timer2(bar); PlatformThread::Sleep(500); } - EXPECT_LE(500, table.GetCounterValue(L"t:foo")); - EXPECT_LE(500, table.GetCounterValue(L"t:bar")); - EXPECT_EQ(1, table.GetCounterValue(L"c:bar")); + EXPECT_LE(500, table.GetCounterValue("t:foo")); + EXPECT_LE(500, table.GetCounterValue("t:bar")); + EXPECT_EQ(1, table.GetCounterValue("c:bar")); // Try a second scope. { @@ -375,9 +375,9 @@ TEST_F(StatsTableTest, StatsScope) { StatsScope<StatsRate> timer2(bar); PlatformThread::Sleep(500); } - EXPECT_LE(1000, table.GetCounterValue(L"t:foo")); - EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); - EXPECT_EQ(2, table.GetCounterValue(L"c:bar")); + EXPECT_LE(1000, table.GetCounterValue("t:foo")); + EXPECT_LE(1000, table.GetCounterValue("t:bar")); + EXPECT_EQ(2, table.GetCounterValue("c:bar")); } } // namespace base |