summaryrefslogtreecommitdiffstats
path: root/chrome/common/time_format_unittest.cc
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 18:12:38 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 18:12:38 +0000
commit61a709434c07d04ff6ec0f871d87028565724a55 (patch)
tree262098e90d5961b669eec05461c56ee8896b8d73 /chrome/common/time_format_unittest.cc
parent8f08db25e83410e4bacd5311daf9e696042f20ec (diff)
downloadchromium_src-61a709434c07d04ff6ec0f871d87028565724a55.zip
chromium_src-61a709434c07d04ff6ec0f871d87028565724a55.tar.gz
chromium_src-61a709434c07d04ff6ec0f871d87028565724a55.tar.bz2
Wrap TimeFormat unittests into unnamed namespace.
Plus some other clean ups around. R=phajdan.jr@chromium.org Review URL: http://codereview.chromium.org/8313003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106085 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/time_format_unittest.cc')
-rw-r--r--chrome/common/time_format_unittest.cc52
1 files changed, 25 insertions, 27 deletions
diff --git a/chrome/common/time_format_unittest.cc b/chrome/common/time_format_unittest.cc
index 31976e3..d88488e 100644
--- a/chrome/common/time_format_unittest.cc
+++ b/chrome/common/time_format_unittest.cc
@@ -1,39 +1,19 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <time.h>
+#include "chrome/common/time_format.h"
-#include "base/basictypes.h"
#include "base/string16.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/common/time_format.h"
#include "testing/gtest/include/gtest/gtest.h"
-using base::Time;
-using base::TimeDelta;
-
-TEST(TimeFormat, RelativeDate) {
- Time now = Time::Now();
- string16 today_str = TimeFormat::RelativeDate(now, NULL);
- EXPECT_EQ(ASCIIToUTF16("Today"), today_str);
-
- Time yesterday = now - TimeDelta::FromDays(1);
- string16 yesterday_str = TimeFormat::RelativeDate(yesterday, NULL);
- EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str);
-
- Time two_days_ago = now - TimeDelta::FromDays(2);
- string16 two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL);
- EXPECT_TRUE(two_days_ago_str.empty());
+namespace {
- Time a_week_ago = now - TimeDelta::FromDays(7);
- string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL);
- EXPECT_TRUE(a_week_ago_str.empty());
-}
+using base::TimeDelta;
-namespace {
-void TestTimeFormats(const TimeDelta delta, const char* expected_ascii) {
+void TestTimeFormats(const TimeDelta& delta, const char* expected_ascii) {
string16 expected = ASCIIToUTF16(expected_ascii);
string16 expected_left = expected + ASCIIToUTF16(" left");
string16 expected_ago = expected + ASCIIToUTF16(" ago");
@@ -42,8 +22,6 @@ void TestTimeFormats(const TimeDelta delta, const char* expected_ascii) {
EXPECT_EQ(expected_ago, TimeFormat::TimeElapsed(delta));
}
-} // namespace
-
TEST(TimeFormat, FormatTime) {
const TimeDelta one_day = TimeDelta::FromDays(1);
const TimeDelta three_days = TimeDelta::FromDays(3);
@@ -69,3 +47,23 @@ TEST(TimeFormat, FormatTime) {
TestTimeFormats(three_days, "3 days");
TestTimeFormats(three_days + four_hours, "3 days");
}
+
+TEST(TimeFormat, RelativeDate) {
+ base::Time now = base::Time::Now();
+ string16 today_str = TimeFormat::RelativeDate(now, NULL);
+ EXPECT_EQ(ASCIIToUTF16("Today"), today_str);
+
+ base::Time yesterday = now - TimeDelta::FromDays(1);
+ string16 yesterday_str = TimeFormat::RelativeDate(yesterday, NULL);
+ EXPECT_EQ(ASCIIToUTF16("Yesterday"), yesterday_str);
+
+ base::Time two_days_ago = now - TimeDelta::FromDays(2);
+ string16 two_days_ago_str = TimeFormat::RelativeDate(two_days_ago, NULL);
+ EXPECT_TRUE(two_days_ago_str.empty());
+
+ base::Time a_week_ago = now - TimeDelta::FromDays(7);
+ string16 a_week_ago_str = TimeFormat::RelativeDate(a_week_ago, NULL);
+ EXPECT_TRUE(a_week_ago_str.empty());
+}
+
+} // namespace