blob: 7cea63e635ac6ffbb884d05346a9f0538e1b6caa [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014-2017. 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 "DriverStation.h" // NOLINT(build/include_order)
9
10#include "TestBench.h"
11#include "Utility.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 = GetFPGATime();
26
27 for (int i = 0; i < 50; i++) {
28 DriverStation::GetInstance().WaitForData();
29 }
30
31 uint64_t finalTime = GetFPGATime();
32
33 EXPECT_NEAR(TIMER_RUNTIME, finalTime - initialTime,
34 TIMER_TOLERANCE * TIMER_RUNTIME);
35}