This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/tests/data/TestTimestamp.cpp
FrankE a2c9e575a2 huge commit
- worked on about everything
- grid walker using plugable modules
- wifi models
- new distributions
- worked on geometric data-structures
- added typesafe timestamps
- worked on grid-building
- added sensor-classes
- added sensor analysis (step-detection, turn-detection)
- offline data reader
- many test-cases
2016-08-29 08:18:44 +02:00

56 lines
991 B
C++

#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../data/Timestamp.h"
TEST(Timestamp, convert) {
Timestamp ts1 = Timestamp::fromMS(100);
ASSERT_EQ(100, ts1.ms());
ASSERT_NEAR(0.1, ts1.sec(), 0.00001);
Timestamp ts2 = Timestamp::fromSec(0.1);
ASSERT_EQ(100, ts2.ms());
ASSERT_NEAR(0.1, ts2.sec(), 0.00001);
}
TEST(Timestamp, equal) {
Timestamp ts1 = Timestamp::fromMS(100);
Timestamp ts2 = Timestamp::fromSec(0.1);
ASSERT_EQ(ts1, ts2);
}
TEST(Timestamp, comp) {
Timestamp ts1 = Timestamp::fromMS(100);
Timestamp ts2 = Timestamp::fromSec(0.1);
Timestamp ts3 = Timestamp::fromSec(150);
ASSERT_FALSE(ts1 < ts2);
ASSERT_FALSE(ts1 > ts2);
ASSERT_TRUE(ts1 < ts3);
ASSERT_FALSE(ts1 > ts3);
ASSERT_TRUE(ts3 > ts1);
ASSERT_FALSE(ts3 < ts1);
}
TEST(Timestamp, add) {
Timestamp ts1 = Timestamp::fromMS(100);
Timestamp ts2 = Timestamp::fromSec(0.2);
ASSERT_EQ(300, (ts1+ts2).ms());
ASSERT_EQ(-100, (ts1-ts2).ms());
ASSERT_EQ(+100, (ts2-ts1).ms());
}
#endif