blob: 72d72d2b0d5740a5f476fc80900f6695b06fbf71 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#include "frc/Ultrasonic.h"
6#include "frc/simulation/UltrasonicSim.h"
7#include "gtest/gtest.h"
8
9namespace frc {
10
11TEST(UltrasonicTest, SimDevices) {
12 Ultrasonic ultrasonic{0, 1};
13 sim::UltrasonicSim sim{ultrasonic};
14
15 EXPECT_EQ(0, ultrasonic.GetRange().value());
16 EXPECT_TRUE(ultrasonic.IsRangeValid());
17
18 sim.SetRange(units::meter_t{35.04});
19 EXPECT_EQ(35.04, ultrasonic.GetRange().value());
20
21 sim.SetRangeValid(false);
22 EXPECT_FALSE(ultrasonic.IsRangeValid());
23 EXPECT_EQ(0, ultrasonic.GetRange().value());
24}
25
26} // namespace frc