blob: 742aa28724ab8e6dd8ba24e19b4db960e7a3b484 (
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
39
40
41
|
#include "libntptest.h"
#include <sstream>
#include <string>
class humandateTest : public libntptest {
};
TEST_F(humandateTest, RegularTime) {
time_t sample = 1276601278;
std::ostringstream expected;
tm* time;
time = localtime(&sample);
ASSERT_TRUE(time != NULL);
expected << std::setfill('0')
<< std::setw(2) << time->tm_hour << ":"
<< std::setw(2) << time->tm_min << ":"
<< std::setw(2) << time->tm_sec;
EXPECT_STREQ(expected.str().c_str(), humantime(sample));
}
TEST_F(humandateTest, CurrentTime) {
time_t sample;
std::ostringstream expected;
time(&sample);
tm* time;
time = localtime(&sample);
ASSERT_TRUE(time != NULL);
expected << std::setfill('0')
<< std::setw(2) << time->tm_hour << ":"
<< std::setw(2) << time->tm_min << ":"
<< std::setw(2) << time->tm_sec;
EXPECT_STREQ(expected.str().c_str(), humantime(sample));
}
|