Skip to content

Commit

Permalink
Merge pull request #119 from Axiom-Space/unit_test_conversion_warnings
Browse files Browse the repository at this point in the history
Fixed type conversion warnings in unit tests
  • Loading branch information
jasonlharvey authored Aug 30, 2024
2 parents 485b35e + 8262006 commit e47056e
Show file tree
Hide file tree
Showing 70 changed files with 989 additions and 986 deletions.
4 changes: 2 additions & 2 deletions aspects/electrical/Batt/test/UtGunnsElectBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void UtGunnsElectBattery::testNominalInitialization()
CPPUNIT_ASSERT(tMalfThermalRunawayFlag == tArticle->mMalfThermalRunawayFlag);
CPPUNIT_ASSERT(tMalfThermalRunawayDuration == tArticle->mMalfThermalRunawayDuration);
CPPUNIT_ASSERT(tMalfThermalRunawayInterval == tArticle->mMalfThermalRunawayInterval);
CPPUNIT_ASSERT(tNumCells == tArticle->mNumCells);
CPPUNIT_ASSERT(tNumCells == static_cast<int>(tArticle->mNumCells));
CPPUNIT_ASSERT(tCellsInParallel == tArticle->mCellsInParallel);
CPPUNIT_ASSERT(tInterconnectResistance == tArticle->mInterconnectResistance);
CPPUNIT_ASSERT(tSocVocTable == tArticle->mSocVocTable);
Expand Down Expand Up @@ -538,7 +538,7 @@ void UtGunnsElectBattery::testThermalRunaway()

/// @test malfunction restart, results after all cells have finished.
tArticle->setMalfThermalRunaway(true, 1.0, 1.0);
for (unsigned int i=0; i<11*tNumCells; ++i) {
for (int i=0; i<11*tNumCells; ++i) {
tArticle->step(dt);
tArticle->computeFlows(dt);
}
Expand Down
16 changes: 8 additions & 8 deletions aspects/electrical/Converter/test/UtConverterElect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ void UtConverterElect::setUp() {
tConverterOnConductance = 200;
tConverterOffConductance = 1.0e-6;
tStandbyPower = 105.0;
tOutVoltageUpperLimit = 140.0;
tOutCurrentUpperLimit = 125.0;
tOutVoltageNoiseScale = 2.80;
tOutCurrentNoiseScale = 3.75;
tOutVoltageUpperLimit = 140.0F;
tOutCurrentUpperLimit = 125.0F;
tOutVoltageNoiseScale = 2.80F;
tOutCurrentNoiseScale = 3.75F;
tTripPriority = 3;

// input data
Expand Down Expand Up @@ -119,10 +119,10 @@ void UtConverterElect::setUp() {
tTolerance = 1.0e-08;

// sensor config data
tOutVoltageSensorConfig = new SensorAnalogConfigData(0.0, tOutVoltageUpperLimit, 0.0, 0.0, 1.0, tOutVoltageNoiseScale,
0.001, 0, UnitConversion::NO_CONVERSION);
tOutCurrentSensorConfig = new SensorAnalogConfigData(-125.0, tOutCurrentUpperLimit, 0.0, 0.0, 1.0, tOutCurrentNoiseScale,
0.001, 0, UnitConversion::NO_CONVERSION);
tOutVoltageSensorConfig = new SensorAnalogConfigData(0.0F, tOutVoltageUpperLimit, 0.0F, 0.0F, 1.0F, tOutVoltageNoiseScale,
0.001F, 0, UnitConversion::NO_CONVERSION);
tOutCurrentSensorConfig = new SensorAnalogConfigData(-125.0F, tOutCurrentUpperLimit, 0.0F, 0.0F, 1.0F, tOutCurrentNoiseScale,
0.001F, 0, UnitConversion::NO_CONVERSION);

// sensor input data
tOutVoltageSensorInput = new SensorAnalogInputData(true, 0.0);
Expand Down
16 changes: 8 additions & 8 deletions aspects/electrical/Converter/test/UtConverterSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ void UtConverterSensors::setUp() {
mInOverVoltageTripActive = false;
mInOverVoltageTripActive = false;

mOutVoltageSensorConfig.mMaxRange = 250.0;
mOutVoltageSensorConfig.mNominalResolution = 0.01;
mOutVoltageSensorConfig.mNominalScale = 1.0;
mOutVoltageSensorConfig.mNominalNoiseScale = 0.555;
mOutVoltageSensorConfig.mMaxRange = 250.0F;
mOutVoltageSensorConfig.mNominalResolution = 0.01F;
mOutVoltageSensorConfig.mNominalScale = 1.0F;
mOutVoltageSensorConfig.mNominalNoiseScale = 0.555F;
mOutVoltageSensorConfig.mNoiseFunction = TsNoise::getNoise;

mOutCurrentSensorConfig.mMaxRange = 100.0;
mOutCurrentSensorConfig.mNominalResolution = 0.01;
mOutCurrentSensorConfig.mNominalScale = 1.0;
mOutCurrentSensorConfig.mNominalNoiseScale = 0.225;
mOutCurrentSensorConfig.mMaxRange = 100.0F;
mOutCurrentSensorConfig.mNominalResolution = 0.01F;
mOutCurrentSensorConfig.mNominalScale = 1.0F;
mOutCurrentSensorConfig.mNominalNoiseScale = 0.225F;
mOutCurrentSensorConfig.mNoiseFunction = TsNoise::getNoise;

mConfig = new ConverterSensorsConfigData(mStandbyPower,
Expand Down
46 changes: 23 additions & 23 deletions aspects/electrical/Converter/test/UtGunnsElectConverterInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void UtGunnsElectConverterInput::setUp()
&tSensorVin,
&tSensorIin,
tTripPriority,
tInUnderVoltageTrip,
tInOverVoltageTrip,
static_cast<float>(tInUnderVoltageTrip),
static_cast<float>(tInOverVoltageTrip),
tEfficiencyTable);

/// - Define the nominal input data.
Expand Down Expand Up @@ -149,26 +149,26 @@ void UtGunnsElectConverterInput::testConfig()
CPPUNIT_ASSERT(&tSensorVin == tConfigData->mInputVoltageSensor);
CPPUNIT_ASSERT(&tSensorIin == tConfigData->mInputCurrentSensor);
CPPUNIT_ASSERT(tTripPriority == tConfigData->mTripPriority);
CPPUNIT_ASSERT(tInUnderVoltageTrip == tConfigData->mInputUnderVoltageTripLimit);
CPPUNIT_ASSERT(tInOverVoltageTrip == tConfigData->mInputOverVoltageTripLimit);
CPPUNIT_ASSERT(tInUnderVoltageTrip == static_cast<double>(tConfigData->mInputUnderVoltageTripLimit));
CPPUNIT_ASSERT(tInOverVoltageTrip == static_cast<double>(tConfigData->mInputOverVoltageTripLimit));
CPPUNIT_ASSERT(tEfficiencyTable == tConfigData->mEfficiencyTable);

/// @test Configuration data default construction.
GunnsElectConverterInputConfigData defaultConfig;
CPPUNIT_ASSERT(0 == defaultConfig.mInputVoltageSensor);
CPPUNIT_ASSERT(0 == defaultConfig.mInputCurrentSensor);
CPPUNIT_ASSERT(0 == defaultConfig.mTripPriority);
CPPUNIT_ASSERT(0.0 == defaultConfig.mInputUnderVoltageTripLimit);
CPPUNIT_ASSERT(0.0 == defaultConfig.mInputOverVoltageTripLimit);
CPPUNIT_ASSERT(0 == defaultConfig.mEfficiencyTable);
CPPUNIT_ASSERT(0 == defaultConfig.mInputVoltageSensor);
CPPUNIT_ASSERT(0 == defaultConfig.mInputCurrentSensor);
CPPUNIT_ASSERT(0 == defaultConfig.mTripPriority);
CPPUNIT_ASSERT(0.0F == defaultConfig.mInputUnderVoltageTripLimit);
CPPUNIT_ASSERT(0.0F == defaultConfig.mInputOverVoltageTripLimit);
CPPUNIT_ASSERT(0 == defaultConfig.mEfficiencyTable);

/// @test Configuration data copy construction.
GunnsElectConverterInputConfigData copyConfig(*tConfigData);
CPPUNIT_ASSERT(&tSensorVin == copyConfig.mInputVoltageSensor);
CPPUNIT_ASSERT(&tSensorIin == copyConfig.mInputCurrentSensor);
CPPUNIT_ASSERT(tTripPriority == copyConfig.mTripPriority);
CPPUNIT_ASSERT(tInUnderVoltageTrip == copyConfig.mInputUnderVoltageTripLimit);
CPPUNIT_ASSERT(tInOverVoltageTrip == copyConfig.mInputOverVoltageTripLimit);
CPPUNIT_ASSERT(tInUnderVoltageTrip == static_cast<double>(copyConfig.mInputUnderVoltageTripLimit));
CPPUNIT_ASSERT(tInOverVoltageTrip == static_cast<double>(copyConfig.mInputOverVoltageTripLimit));
CPPUNIT_ASSERT(tEfficiencyTable == copyConfig.mEfficiencyTable);

UT_PASS;
Expand Down Expand Up @@ -273,8 +273,8 @@ void UtGunnsElectConverterInput::testNominalInitialization()
GunnsBasicLink::SolutionResult result;
CPPUNIT_ASSERT(false == tArticle->mInputUnderVoltageTrip.isTripped());
CPPUNIT_ASSERT(false == tArticle->mInputOverVoltageTrip.isTripped());
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, tInUnderVoltageTrip - 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, tInOverVoltageTrip + 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, static_cast<float>(tInUnderVoltageTrip - 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, static_cast<float>(tInOverVoltageTrip + 0.01), tTripPriority));

/// @test Nominal state data.
CPPUNIT_ASSERT(false == tArticle->mResetTrips);
Expand Down Expand Up @@ -309,9 +309,9 @@ void UtGunnsElectConverterInput::testInitializationErrors()
UT_RESULT;

/// @test Exception thrown for under-volt trip limit > over-volt limit.
tConfigData->mInputUnderVoltageTripLimit = tInOverVoltageTrip + 0.001;
tConfigData->mInputUnderVoltageTripLimit = static_cast<float>(tInOverVoltageTrip + 0.001);
CPPUNIT_ASSERT_THROW(tArticle->initialize(*tConfigData, *tInputData, tLinks, tPort0), TsInitializationException);
tConfigData->mInputUnderVoltageTripLimit = tInUnderVoltageTrip;
tConfigData->mInputUnderVoltageTripLimit = static_cast<float>(tInUnderVoltageTrip);

/// @test Exception not thrown for no efficiency table and zero reference power.
tConfigData->mEfficiencyTable = 0;
Expand All @@ -337,7 +337,7 @@ void UtGunnsElectConverterInput::testInitializationErrors()
tConfigData->mInputOverVoltageTripLimit = 0.0;
GunnsElectConverterInput article;
CPPUNIT_ASSERT_NO_THROW(article.initialize(*tConfigData, *tInputData, tLinks, tPort0));
tConfigData->mInputOverVoltageTripLimit = tInOverVoltageTrip;
tConfigData->mInputOverVoltageTripLimit = static_cast<float>(tInOverVoltageTrip);

/// @test Exception thrown for node list mismatch with output link.
GunnsBasicNode otherNodes[N_NODES];
Expand Down Expand Up @@ -407,8 +407,8 @@ void UtGunnsElectConverterInput::testStep()

/// @test Reset trips when commanded.
GunnsBasicLink::SolutionResult result;
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, tInUnderVoltageTrip - 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, tInOverVoltageTrip + 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, static_cast<float>(tInUnderVoltageTrip - 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, static_cast<float>(tInOverVoltageTrip + 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.isTripped());
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.isTripped());
tArticle->mResetTrips = true;
Expand Down Expand Up @@ -440,8 +440,8 @@ void UtGunnsElectConverterInput::testStep()
CPPUNIT_ASSERT(false == tArticle->mResetTrips);

/// @test Trips not reset when not commanded.
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, tInUnderVoltageTrip - 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, tInOverVoltageTrip + 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, static_cast<float>(tInUnderVoltageTrip - 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, static_cast<float>(tInOverVoltageTrip + 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.isTripped());
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.isTripped());
expectedW = 0.0;
Expand Down Expand Up @@ -643,13 +643,13 @@ void UtGunnsElectConverterInput::testComputeInputVoltage()

/// @test Over-volt tripped.
GunnsBasicLink::SolutionResult result;
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, tInOverVoltageTrip + 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputOverVoltageTrip.checkForTrip(result, static_cast<float>(tInOverVoltageTrip + 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->computeInputVoltage(actualV));
CPPUNIT_ASSERT(0.0 == actualV);
tArticle->mInputOverVoltageTrip.resetTrip();

/// @test Under-volt tripped.
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, tInUnderVoltageTrip - 0.01, tTripPriority));
CPPUNIT_ASSERT(true == tArticle->mInputUnderVoltageTrip.checkForTrip(result, static_cast<float>(tInUnderVoltageTrip - 0.01), tTripPriority));
CPPUNIT_ASSERT(true == tArticle->computeInputVoltage(actualV));
CPPUNIT_ASSERT(0.0 == actualV);
tArticle->mInputUnderVoltageTrip.resetTrip();
Expand Down
Loading

0 comments on commit e47056e

Please sign in to comment.