29 lines
481 B
C++
29 lines
481 B
C++
#include <di/time.h>
|
|
#include <stdio.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <time.h>
|
|
#include <sys/time.h>
|
|
|
|
|
|
TEST(time, get_stamp) {
|
|
uint64_t before;
|
|
struct timeval tv;
|
|
if (gettimeofday(&tv, NULL) < 0) {
|
|
before = 0;
|
|
}
|
|
else {
|
|
// Chomp off micros
|
|
before = (uint64_t)(tv.tv_usec / 1000U);
|
|
// Add in the seconds * 1000
|
|
before += (uint64_t)(tv.tv_sec * 1000U);
|
|
}
|
|
|
|
uint64_t current;
|
|
current = di_time_get_stamp();
|
|
|
|
|
|
EXPECT_NEAR((double)before, (double)current, 10);
|
|
}
|