xref: /aosp_15_r20/system/logging/liblog/tests/log_time_test.cpp (revision 598139dc91b21518d67c408eaea2644226490971)
1*598139dcSAndroid Build Coastguard Worker /*
2*598139dcSAndroid Build Coastguard Worker  * Copyright (C) 2017 The Android Open Source Project
3*598139dcSAndroid Build Coastguard Worker  *
4*598139dcSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*598139dcSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*598139dcSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*598139dcSAndroid Build Coastguard Worker  *
8*598139dcSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*598139dcSAndroid Build Coastguard Worker  *
10*598139dcSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*598139dcSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*598139dcSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*598139dcSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*598139dcSAndroid Build Coastguard Worker  * limitations under the License.
15*598139dcSAndroid Build Coastguard Worker  */
16*598139dcSAndroid Build Coastguard Worker 
17*598139dcSAndroid Build Coastguard Worker #include <time.h>
18*598139dcSAndroid Build Coastguard Worker 
19*598139dcSAndroid Build Coastguard Worker #include <gtest/gtest.h>
20*598139dcSAndroid Build Coastguard Worker // Test the APIs in this standalone include file
21*598139dcSAndroid Build Coastguard Worker #include <log/log_time.h>
22*598139dcSAndroid Build Coastguard Worker 
TEST(liblog,log_time)23*598139dcSAndroid Build Coastguard Worker TEST(liblog, log_time) {
24*598139dcSAndroid Build Coastguard Worker   struct timespec ts;
25*598139dcSAndroid Build Coastguard Worker   clock_gettime(CLOCK_MONOTONIC, &ts);
26*598139dcSAndroid Build Coastguard Worker   log_time tl(ts);
27*598139dcSAndroid Build Coastguard Worker 
28*598139dcSAndroid Build Coastguard Worker   EXPECT_EQ(tl, ts);
29*598139dcSAndroid Build Coastguard Worker   EXPECT_GE(tl, ts);
30*598139dcSAndroid Build Coastguard Worker   EXPECT_LE(tl, ts);
31*598139dcSAndroid Build Coastguard Worker }
32