Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: base/build_time_unittest.cc

Issue 1641413002: Makes GetBuildTime behave identically on all build types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/build_time.h" 5 #include "base/build_time.h"
6 #include "base/generated_build_date.h"
7 #include "base/time/time.h"
6 8
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 TEST(BuildTime, DateLooksValid) { 11 TEST(BuildTime, DateLooksValid) {
10 #if !defined(DONT_EMBED_BUILD_METADATA) 12 char build_date[] = BUILD_DATE;
11 char build_date[] = __DATE__;
12 #else
13 char build_date[] = "Sep 02 2008";
14 #endif
15 13
16 EXPECT_EQ(11u, strlen(build_date)); 14 EXPECT_EQ(11u, strlen(build_date));
17 EXPECT_EQ(' ', build_date[3]); 15 EXPECT_EQ(' ', build_date[3]);
18 EXPECT_EQ(' ', build_date[6]); 16 EXPECT_EQ(' ', build_date[6]);
19 } 17 }
20 18
21 TEST(BuildTime, TimeLooksValid) { 19 TEST(BuildTime, TimeLooksValid) {
22 #if defined(DONT_EMBED_BUILD_METADATA) 20 char build_time[] = "00:00:00";
23 char build_time[] = "08:00:00";
24 #else
25 char build_time[] = __TIME__;
26 #endif
27 21
28 EXPECT_EQ(8u, strlen(build_time)); 22 EXPECT_EQ(8u, strlen(build_time));
29 EXPECT_EQ(':', build_time[2]); 23 EXPECT_EQ(':', build_time[2]);
30 EXPECT_EQ(':', build_time[5]); 24 EXPECT_EQ(':', build_time[5]);
31 } 25 }
32 26
33 TEST(BuildTime, DoesntCrash) { 27 TEST(BuildTime, DoesntCrash) {
34 // Since __DATE__ isn't updated unless one does a clobber build, we can't 28 // Since BUILD_DATE isn't updated unless one does a clobber build, we can't
35 // really test the value returned by it, except to check that it doesn't 29 // really test the value returned by it, except to check that it doesn't
36 // crash. 30 // crash.
Dirk Pranke 2016/02/09 02:46:56 this comment is wrong, now, right? BUILD_DATE will
37 base::GetBuildTime(); 31 base::GetBuildTime();
38 } 32 }
33
34 TEST(BuildTime, InThePast) {
35 EXPECT_TRUE(base::GetBuildTime() < base::Time::Now());
36 EXPECT_TRUE(base::GetBuildTime() < base::Time::NowFromSystemTime());
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698