trick/trick_sims/SIM_wheelbot/models/Battery/test/DCBatteryTest.cpp
Michael Vetter 18f0d7e871 Remove trailing whitespaces
Makes it easier to edit the files. So if we press 'end of line' we are
really at the end of line.
2016-11-08 10:25:07 +01:00

53 lines
1.2 KiB
C++

#include <gtest/gtest.h>
#define private public
#include "DCBattery.hh"
TEST( BatteryTest , one ) {
// Attempt to create an Battery
DCBattery * battery;
battery = new DCBattery(9.0, 2.0);
EXPECT_NE( (void*)0, battery);
//delete battery;
}
TEST( BatteryTest , two ) {
// Test Ideal Voltage
DCBattery battery(9.0, 2.0);
EXPECT_DOUBLE_EQ( 9.0, battery.idealVoltage );
}
TEST( BatteryTest , three ) {
// Test Internal Resistance
DCBattery battery(9.0, 2.0);
EXPECT_DOUBLE_EQ( 2, battery.internalResistance );
}
TEST( BatteryTest , four ) {
// Test Actual Voltage doesnt go below zero
DCBattery battery(9.0, 2.0);
battery.setCurrent(6.0);
battery.update ();
EXPECT_DOUBLE_EQ( 0.0, battery.actualVoltage );
}
TEST( BatteryTest , five ) {
// Test Actual Voltage under normal load
DCBattery battery(9.0, 2.0);
battery.setCurrent(4.0);
battery.update ();
EXPECT_DOUBLE_EQ( 1.0, battery.actualVoltage );
}
TEST( BatteryTest , six ) {
// Test Actual Voltage doesnt go above Ideal Voltage
DCBattery battery(9.0, 2.0);
battery.setCurrent(-4.0);
battery.update ();
EXPECT_DOUBLE_EQ( 9.0, battery.actualVoltage );
}