2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2014-06-02 17:34:10 -04:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Timer.h" // NOLINT(build/include_order)
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#include <units/math.h>
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#include "gtest/gtest.h"
|
2014-06-02 17:34:10 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
#define EXPECT_NEAR_UNITS(val1, val2, eps) \
|
|
|
|
|
EXPECT_LE(units::math::abs(val1 - val2), eps)
|
2014-06-07 17:37:51 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
TEST(TimerTest, Wait) {
|
|
|
|
|
auto initialTime = frc::Timer::GetFPGATimestamp();
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
frc::Wait(500_ms);
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
auto finalTime = frc::Timer::GetFPGATimestamp();
|
2015-06-25 15:07:55 -04:00
|
|
|
|
2021-05-28 22:06:59 -07:00
|
|
|
EXPECT_NEAR_UNITS(500_ms, finalTime - initialTime, 1_ms);
|
2015-06-25 15:07:55 -04:00
|
|
|
}
|