1 // Copyright 2018 The Chromium OS 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 <stdlib.h>
6
7 #include <base/files/file_path.h>
8 #include <gtest/gtest.h>
9
10 #include "brillo/timezone/tzif_parser.h"
11
12 namespace brillo {
13
14 namespace timezone {
15
16 class TzifParserTest : public ::testing::Test {
17 public:
TzifParserTest()18 TzifParserTest() {
19 source_dir_ =
20 base::FilePath(getenv("SRC")).Append("brillo").Append("timezone");
21 }
22
23 protected:
24 base::FilePath source_dir_;
25 };
26
TEST_F(TzifParserTest,EST)27 TEST_F(TzifParserTest, EST) {
28 auto posix_result = GetPosixTimezone(source_dir_.Append("EST_test.tzif"));
29 EXPECT_EQ(posix_result, "EST5");
30 }
31
TEST_F(TzifParserTest,TzifVersionTwo)32 TEST_F(TzifParserTest, TzifVersionTwo) {
33 auto posix_result =
34 GetPosixTimezone(source_dir_.Append("Indian_Christmas_test.tzif"));
35 EXPECT_EQ(posix_result, "<+07>-7");
36 }
37
TEST_F(TzifParserTest,TzifVersionThree)38 TEST_F(TzifParserTest, TzifVersionThree) {
39 auto posix_result =
40 GetPosixTimezone(source_dir_.Append("Pacific_Fiji_test.tzif"));
41 EXPECT_EQ(posix_result, "<+12>-12<+13>,M11.1.0,M1.2.2/123");
42 }
43
44 } // namespace timezone
45
46 } // namespace brillo
47