summaryrefslogtreecommitdiffstats
path: root/base/build_time_unittest.cc
blob: aac64a7dc7c1f63d3b664b809245680faeef43d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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 "base/build_time.h"

#include "testing/gtest/include/gtest/gtest.h"

TEST(BuildTime, DateLooksValid) {
#if !defined(DONT_EMBED_BUILD_METADATA)
  char build_date[] = __DATE__;
#else
  char build_date[] = "Sep 02 2008";
#endif

  EXPECT_EQ(11u, strlen(build_date));
  EXPECT_EQ(' ', build_date[3]);
  EXPECT_EQ(' ', build_date[6]);
}

TEST(BuildTime, TimeLooksValid) {
#if defined(DONT_EMBED_BUILD_METADATA)
  char build_time[] = "08:00:00";
#else
  char build_time[] = __TIME__;
#endif

  EXPECT_EQ(8u, strlen(build_time));
  EXPECT_EQ(':', build_time[2]);
  EXPECT_EQ(':', build_time[5]);
}

TEST(BuildTime, DoesntCrash) {
  // Since __DATE__ isn't updated unless one does a clobber build, we can't
  // really test the value returned by it, except to check that it doesn't
  // crash.
  base::GetBuildTime();
}