Files
allwpilib/wpilibcIntegrationTests/src/DriverStationTest.cpp
Peter Johnson 59267da72b Namespace all wpilibc functions/classes into "frc" namespace. (#311)
Base.h provides a backwards compatibility shim (enabled unless
NAMESPACED_WPILIB is defined) that does a "using namespace frc".
However, as some header files do not include Base.h, this may
be a breaking change in some corner cases (with an easy fix).

Fixes #218.
2016-11-01 22:33:12 -07:00

36 lines
1.1 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "DriverStation.h" // NOLINT(build/include_order)
#include "TestBench.h"
#include "Utility.h"
#include "gtest/gtest.h"
using namespace frc;
constexpr double TIMER_TOLERANCE = 0.2;
constexpr int64_t TIMER_RUNTIME = 1000000; // 1 second
class DriverStationTest : public testing::Test {};
/**
* Test if the WaitForData function works
*/
TEST_F(DriverStationTest, WaitForData) {
uint64_t initialTime = GetFPGATime();
for (int i = 0; i < 50; i++) {
DriverStation::GetInstance().WaitForData();
}
uint64_t finalTime = GetFPGATime();
EXPECT_NEAR(TIMER_RUNTIME, finalTime - initialTime,
TIMER_TOLERANCE * TIMER_RUNTIME);
}