blob: bcd3e5c9e57d94eef5e4b109eda1db86b0b12276 [file] [log] [blame]
Sampa Misra032bd502019-03-06 05:03:22 -06001
2#include "libpldmresponder/bios.hpp"
3
4#include <string.h>
5
6#include <array>
7#include <ctime>
8
9#include "libpldm/base.h"
10#include "libpldm/bios.h"
11
12#include <gtest/gtest.h>
13
14using namespace pldm::responder;
15using namespace pldm::responder::utils;
16
17TEST(epochToBCDTime, testTime)
18{
19 struct tm time
20 {
21 };
22 time.tm_year = 119;
23 time.tm_mon = 3;
24 time.tm_mday = 13;
25 time.tm_hour = 5;
26 time.tm_min = 18;
27 time.tm_sec = 13;
28 time.tm_isdst = -1;
29
30 time_t epochTime = mktime(&time);
31 uint8_t seconds = 0;
32 uint8_t minutes = 0;
33 uint8_t hours = 0;
34 uint8_t day = 0;
35 uint8_t month = 0;
36 uint16_t year = 0;
37
38 epochToBCDTime(epochTime, seconds, minutes, hours, day, month, year);
39
40 ASSERT_EQ(0x13, seconds);
41 ASSERT_EQ(0x18, minutes);
42 ASSERT_EQ(0x5, hours);
43 ASSERT_EQ(0x13, day);
44 ASSERT_EQ(0x4, month);
45 ASSERT_EQ(0x2019, year);
46}