How can we mock (gmock) a WPI_TalonFX interface?
We are trying to take advantage of the testing capabilities of the build system.
In order to test on the desktop, we cannot directly use class like the WPI_FalconFX C++ class.
In order to mock the class we basically need an interface or implementation with a
default constructor (or other trivial constructor).
The class hierarchy for WPI_TalonFX is interestingly complex with many public virtual inheritance
classes. I narrowed the combination that devolves to no constructor and all interfaces to
class ITalonFX
: public virtual ctre::phoenix::motorcontrol::IMotorController
, public virtual ctre::phoenix::motorcontrol::IMotorControllerEnhanced
, public virtual frc::SpeedController
, public frc::SendableBase
{
}
But I cannot assign to an instance of this class:
WPI_TalonFX realTalon{0};
ITalonFX* talonPtr{&realTalon};
error: cannot convert 'WPI_TalonFX* {aka ctre::phoenix::motorcontrol::can::WPI_TalonFX*}' to 'ITalonFX*' in initialization
Is there a magic incantation that will allow me to create a gmock instance for WPI_TalonFX?
Thanks!