blob: d6563e06078af2cbd4e0c7edc6e8984b96dbb54f [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014. 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>
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}