blob: c6038b597f4ea4e0657ad4be7c7cfc5a68a3063a [file] [log] [blame]
Mathias Agopian1f5762e2013-05-06 20:20:34 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Narayan Kamathafd31e02013-12-03 13:16:03 +000017#define LOG_TAG "ZipUtils_test"
Mathias Agopian1f5762e2013-05-06 20:20:34 -070018#include <utils/Log.h>
Narayan Kamathafd31e02013-12-03 13:16:03 +000019#include <androidfw/ZipUtils.h>
Mathias Agopian1f5762e2013-05-06 20:20:34 -070020
21#include <gtest/gtest.h>
22
23#include <fcntl.h>
24#include <string.h>
25
26namespace android {
27
Narayan Kamathafd31e02013-12-03 13:16:03 +000028class ZipUtilsTest : public testing::Test {
Mathias Agopian1f5762e2013-05-06 20:20:34 -070029protected:
30 virtual void SetUp() {
31 }
32
33 virtual void TearDown() {
34 }
35};
36
Narayan Kamathafd31e02013-12-03 13:16:03 +000037TEST_F(ZipUtilsTest, ZipTimeConvertSuccess) {
Mathias Agopian1f5762e2013-05-06 20:20:34 -070038 struct tm t;
39
40 // 2011-06-29 14:40:40
41 long when = 0x3EDD7514;
42
Narayan Kamathafd31e02013-12-03 13:16:03 +000043 ZipUtils::zipTimeToTimespec(when, &t);
Mathias Agopian1f5762e2013-05-06 20:20:34 -070044
45 EXPECT_EQ(2011, t.tm_year + 1900)
46 << "Year was improperly converted.";
47
48 EXPECT_EQ(6, t.tm_mon)
49 << "Month was improperly converted.";
50
51 EXPECT_EQ(29, t.tm_mday)
52 << "Day was improperly converted.";
53
54 EXPECT_EQ(14, t.tm_hour)
55 << "Hour was improperly converted.";
56
57 EXPECT_EQ(40, t.tm_min)
58 << "Minute was improperly converted.";
59
60 EXPECT_EQ(40, t.tm_sec)
61 << "Second was improperly converted.";
62}
63
64}