blob: df8eef3418863235791138eec26ce2c5ed013bba [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
3/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/DriverStation.h" // NOLINT(build/include_order)
9
10#include "TestBench.h"
11#include "frc/RobotController.h"
12#include "gtest/gtest.h"
13
14using namespace frc;
15
16constexpr double TIMER_TOLERANCE = 0.2;
17constexpr int64_t TIMER_RUNTIME = 1000000; // 1 second
18
19class DriverStationTest : public testing::Test {};
20
21/**
22 * Test if the WaitForData function works
23 */
24TEST_F(DriverStationTest, WaitForData) {
25 uint64_t initialTime = RobotController::GetFPGATime();
26
27 for (int i = 0; i < 50; i++) {
28 DriverStation::GetInstance().WaitForData();
29 }
30
31 uint64_t finalTime = RobotController::GetFPGATime();
32
33 EXPECT_NEAR(TIMER_RUNTIME, finalTime - initialTime,
34 TIMER_TOLERANCE * TIMER_RUNTIME);
35}