blob: aac64a7dc7c1f63d3b664b809245680faeef43d8 [file] [log] [blame]
James Robinson646469d2014-10-03 15:33:28 -07001// 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
3// found in the LICENSE file.
4
5#include "base/build_time.h"
6
7#include "testing/gtest/include/gtest/gtest.h"
8
9TEST(BuildTime, DateLooksValid) {
James Robinsond4531882014-10-17 16:14:32 -070010#if !defined(DONT_EMBED_BUILD_METADATA)
James Robinson646469d2014-10-03 15:33:28 -070011 char build_date[] = __DATE__;
James Robinsond4531882014-10-17 16:14:32 -070012#else
13 char build_date[] = "Sep 02 2008";
14#endif
James Robinson646469d2014-10-03 15:33:28 -070015
16 EXPECT_EQ(11u, strlen(build_date));
17 EXPECT_EQ(' ', build_date[3]);
18 EXPECT_EQ(' ', build_date[6]);
19}
20
21TEST(BuildTime, TimeLooksValid) {
James Robinsond4531882014-10-17 16:14:32 -070022#if defined(DONT_EMBED_BUILD_METADATA)
23 char build_time[] = "08:00:00";
24#else
James Robinson646469d2014-10-03 15:33:28 -070025 char build_time[] = __TIME__;
James Robinsond4531882014-10-17 16:14:32 -070026#endif
James Robinson646469d2014-10-03 15:33:28 -070027
28 EXPECT_EQ(8u, strlen(build_time));
29 EXPECT_EQ(':', build_time[2]);
30 EXPECT_EQ(':', build_time[5]);
31}
32
33TEST(BuildTime, DoesntCrash) {
34 // Since __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
36 // crash.
37 base::GetBuildTime();
38}