blob: f8bee87a84535004b65ccbcbea5ee14a96d302af [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
Brian Silverman1a675112016-02-20 20:42:49 -05002/* Copyright (c) FIRST 2014-2016. All Rights Reserved. */
Brian Silverman26e4e522015-12-17 01:56:40 -05003/* 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>
9#include <Timer.h>
10#include "gtest/gtest.h"
11
12static constexpr double kAccelerationTolerance = 0.1;
13/**
14 * There's not much we can automatically test with the on-board accelerometer,
15 * but checking for gravity is probably good enough to tell that it's working.
16 */
17TEST(BuiltInAccelerometerTest, Accelerometer) {
18 BuiltInAccelerometer accelerometer;
19
20 /* The testbench sometimes shakes a little from a previous test. Give it
21 some time. */
22 Wait(1.0);
23
24 ASSERT_NEAR(0.0, accelerometer.GetX(), kAccelerationTolerance);
25 ASSERT_NEAR(1.0, accelerometer.GetY(), kAccelerationTolerance);
26 ASSERT_NEAR(0.0, accelerometer.GetZ(), kAccelerationTolerance);
27}