blob: abcac1b04bed3dd5ef0e9f463c3fc3a4686e3d07 [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 "BuiltInAccelerometer.h" // NOLINT(build/include_order)
9
10#include "Timer.h"
11#include "gtest/gtest.h"
12
13using namespace frc;
14
15static constexpr double kAccelerationTolerance = 0.1;
16/**
17 * There's not much we can automatically test with the on-board accelerometer,
18 * but checking for gravity is probably good enough to tell that it's working.
19 */
20TEST(BuiltInAccelerometerTest, Accelerometer) {
21 BuiltInAccelerometer accelerometer;
22
23 /* The testbench sometimes shakes a little from a previous test. Give it
24 some time. */
25 Wait(1.0);
26
27 ASSERT_NEAR(0.0, accelerometer.GetX(), kAccelerationTolerance);
28 ASSERT_NEAR(1.0, accelerometer.GetY(), kAccelerationTolerance);
29 ASSERT_NEAR(0.0, accelerometer.GetZ(), kAccelerationTolerance);
30}