mirror of
https://github.com/nasa/trick.git
synced 2025-01-01 10:56:43 +00:00
18f0d7e871
Makes it easier to edit the files. So if we press 'end of line' we are really at the end of line.
53 lines
1.2 KiB
C++
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 );
|
|
|
|
}
|