time-test.cc revision 1a23f9c274071a91edde9fc28895c45940d4e90d
1/*
2 Time formatting tests
3
4 Copyright (c) 2012 - 2016, Victor Zverovich
5 All rights reserved.
6
7 For the license information refer to format.h.
8 */
9
10#include "gmock/gmock.h"
11#include "fmt/time.h"
12
13TEST(TimeTest, Format) {
14  std::tm tm = std::tm();
15  tm.tm_year = 116;
16  tm.tm_mon  = 3;
17  tm.tm_mday = 25;
18  EXPECT_EQ("The date is 2016-04-25.",
19            fmt::format("The date is {:%Y-%m-%d}.", tm));
20}
21
22TEST(TimeTest, GrowBuffer) {
23  std::string s = "{:";
24  for (int i = 0; i < 30; ++i)
25    s += "%c";
26  s += "}\n";
27  std::time_t t = std::time(0);
28  fmt::format(s, *std::localtime(&t));
29}
30