2024-05-24 15:55:30 -04:00
|
|
|
// 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 <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include "frc/SharpIR.h"
|
|
|
|
|
#include "frc/simulation/SharpIRSim.h"
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
|
|
|
|
TEST(SharpIRTest, SimDevices) {
|
|
|
|
|
SharpIR s = SharpIR::GP2Y0A02YK0F(1);
|
|
|
|
|
SharpIRSim sim(s);
|
|
|
|
|
|
2025-02-10 07:23:04 -08:00
|
|
|
EXPECT_EQ(0.2, s.GetRange().value());
|
2024-05-24 15:55:30 -04:00
|
|
|
|
2025-02-10 07:23:04 -08:00
|
|
|
sim.SetRange(30_cm);
|
|
|
|
|
EXPECT_EQ(0.3, s.GetRange().value());
|
2024-05-24 15:55:30 -04:00
|
|
|
|
2025-02-10 07:23:04 -08:00
|
|
|
sim.SetRange(300_cm);
|
|
|
|
|
EXPECT_EQ(1.5, s.GetRange().value());
|
2024-05-24 15:55:30 -04:00
|
|
|
}
|