Files
allwpilib/wpilibc/src/test/native/cpp/UltrasonicTest.cpp
Tyler Veness 181723e573 Replace .to<double>() and .template to<double>() with .value() (#3667)
It's a less verbose way to do the same thing.
2021-10-25 08:58:12 -07:00

27 lines
740 B
C++

// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/Ultrasonic.h"
#include "frc/simulation/UltrasonicSim.h"
#include "gtest/gtest.h"
namespace frc {
TEST(UltrasonicTest, SimDevices) {
Ultrasonic ultrasonic{0, 1};
sim::UltrasonicSim sim{ultrasonic};
EXPECT_EQ(0, ultrasonic.GetRange().value());
EXPECT_TRUE(ultrasonic.IsRangeValid());
sim.SetRange(units::meter_t{35.04});
EXPECT_EQ(35.04, ultrasonic.GetRange().value());
sim.SetRangeValid(false);
EXPECT_FALSE(ultrasonic.IsRangeValid());
EXPECT_EQ(0, ultrasonic.GetRange().value());
}
} // namespace frc