Home | History | Annotate | Download | only in tests
      1 /*
      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 
     17 #define LOG_TAG "ZipFileRO_test"
     18 #include <utils/Log.h>
     19 #include <utils/ZipFileRO.h>
     20 
     21 #include <gtest/gtest.h>
     22 
     23 #include <fcntl.h>
     24 #include <string.h>
     25 
     26 namespace android {
     27 
     28 class ZipFileROTest : public testing::Test {
     29 protected:
     30     virtual void SetUp() {
     31     }
     32 
     33     virtual void TearDown() {
     34     }
     35 };
     36 
     37 TEST_F(ZipFileROTest, ZipTimeConvertSuccess) {
     38     struct tm t;
     39 
     40     // 2011-06-29 14:40:40
     41     long when = 0x3EDD7514;
     42 
     43     ZipFileRO::zipTimeToTimespec(when, &t);
     44 
     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 }
     65