2017-02-19 01:03:48 +08:00
|
|
|
#include <chrono>
|
|
|
|
#include <iostream>
|
|
|
|
#include <thread>
|
|
|
|
|
2021-01-21 22:47:56 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <utils/timestamp.hpp>
|
2017-02-19 01:03:48 +08:00
|
|
|
|
2017-02-20 06:47:09 +08:00
|
|
|
TEST(TimestampTest, BasicUsage) {
|
2018-04-22 14:31:09 +08:00
|
|
|
auto timestamp = utils::Timestamp::Now();
|
2017-02-19 01:03:48 +08:00
|
|
|
|
|
|
|
std::cout << timestamp << std::endl;
|
2018-04-22 14:31:09 +08:00
|
|
|
std::cout << utils::Timestamp::Now() << std::endl;
|
2017-02-19 01:03:48 +08:00
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
|
|
|
|
2018-04-22 14:31:09 +08:00
|
|
|
std::cout << utils::Timestamp::Now().ToIso8601() << std::endl;
|
2017-02-19 01:03:48 +08:00
|
|
|
|
2018-04-22 14:31:09 +08:00
|
|
|
ASSERT_GT(utils::Timestamp::Now(), timestamp);
|
2017-02-20 06:47:09 +08:00
|
|
|
|
2017-02-19 01:03:48 +08:00
|
|
|
std::cout << std::boolalpha;
|
|
|
|
|
2018-04-22 14:31:09 +08:00
|
|
|
std::cout << (timestamp == utils::Timestamp::Now()) << std::endl;
|
2017-02-19 01:03:48 +08:00
|
|
|
|
2018-04-22 14:31:09 +08:00
|
|
|
ASSERT_NE(timestamp, utils::Timestamp::Now());
|
2017-02-20 06:47:09 +08:00
|
|
|
}
|