Files
allwpilib/wpilibc/src/test/native/cpp/simulation/DutyCycleEncoderSimTest.cpp

38 lines
949 B
C++
Raw Normal View History

2021-08-05 22:04:51 -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 "frc/simulation/DutyCycleEncoderSim.h" // NOLINT(build/include_order)
#include <gtest/gtest.h>
2021-08-05 22:04:51 -04:00
#include <hal/HAL.h>
#include "callback_helpers/TestCallbackHelpers.h"
#include "frc/DutyCycleEncoder.h"
namespace frc::sim {
TEST(DutyCycleEncoderSimTest, Set) {
HAL_Initialize(500, 0);
DutyCycleEncoder enc{0, 10, 0};
2021-08-05 22:04:51 -04:00
DutyCycleEncoderSim sim(enc);
constexpr double kTestValue{5.67};
2021-08-05 22:04:51 -04:00
sim.Set(kTestValue);
EXPECT_EQ(kTestValue, enc.Get());
}
TEST(DutyCycleEncoderSimTest, SetIsConnected) {
HAL_Initialize(500, 0);
DutyCycleEncoder enc{0};
DutyCycleEncoderSim sim(enc);
sim.SetConnected(true);
EXPECT_TRUE(enc.IsConnected());
sim.SetConnected(false);
EXPECT_FALSE(enc.IsConnected());
}
2021-08-05 22:04:51 -04:00
} // namespace frc::sim