text: /*----------------------------------------------------------------------------*/
  /* Copyright (c) 2018-2020 FIRST. 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 "frc/simulation/BuiltInAccelerometerSim.h"  // NOLINT(build/include_order)
  
  #include <hal/Accelerometer.h>
  #include <hal/HAL.h>
  
  #include "gtest/gtest.h"
  
  using namespace frc::sim;
  
  TEST(AcclerometerSimTests, TestActiveCallback) {
    HAL_Initialize(500, 0);
  
    BuiltInAccelerometerSim sim;
  
    sim.ResetData();
  
    bool wasTriggered = false;
    bool lastValue = false;
  
    auto cb = sim.RegisterActiveCallback(
        [&](wpi::StringRef name, const HAL_Value* value) {
          wasTriggered = true;
          lastValue = value->data.v_boolean;
        },
        false);
  
    EXPECT_FALSE(wasTriggered);
  
    HAL_SetAccelerometerActive(true);
  
    EXPECT_TRUE(wasTriggered);
    EXPECT_TRUE(lastValue);
  }
  