test_walltime.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 The urg_stamped Authors
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 #include <gtest/gtest.h>
18 
19 #include <scip2/walltime.h>
20 
21 TEST(WalltimeTest, testTimestampOverflow)
22 {
23  for (uint64_t start_device_time = 0;
24  start_device_time < (1 << 24);
25  start_device_time += (1 << 23))
26  {
27  scip2::Walltime<24> walltime;
28 
29  for (uint64_t device_time = start_device_time;
30  device_time < (1 << 25);
31  device_time += 25)
32  {
33  const uint32_t device_timestamp = device_time & 0xFFFFFF;
34  ASSERT_EQ(walltime.update(device_timestamp), device_time);
35  }
36  }
37 }
38 
39 TEST(WalltimeTest, testDeviceTimeBoundary)
40 {
41  scip2::Walltime<24> walltime;
42 
43  uint64_t device_time = (1 << 24) - 1;
44  uint32_t device_timestamp = device_time & 0xFFFFFF;
45  ASSERT_EQ(walltime.update(device_timestamp), device_time);
46 
47  device_time = 0;
48  device_timestamp = device_time & 0xFFFFFF;
49  ASSERT_EQ(walltime.update(device_timestamp), (1 << 24) + device_time);
50 
51  device_time = (1 << 24) - 1;
52  device_timestamp = device_time & 0xFFFFFF;
53  ASSERT_EQ(walltime.update(device_timestamp), device_time);
54 
55  device_time = 0;
56  device_timestamp = device_time & 0xFFFFFF;
57  ASSERT_EQ(walltime.update(device_timestamp), (1 << 24) + device_time);
58 }
59 
60 int main(int argc, char** argv)
61 {
62  testing::InitGoogleTest(&argc, argv);
63 
64  return RUN_ALL_TESTS();
65 }
uint64_t update(const uint32_t &time_device)
Definition: walltime.h:35
int main(int argc, char **argv)
TEST(WalltimeTest, testTimestampOverflow)


urg_stamped
Author(s): Atsushi Watanabe
autogenerated on Tue May 11 2021 02:14:05