Merge remote-tracking branch 'origin/develop' into mueller/acs-ss-init
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
target_sources(${UNITTEST_NAME} PRIVATE
|
||||
testThermalController.cpp
|
||||
testAcsController.cpp
|
||||
)
|
||||
testConfigFileHandler.cpp
|
||||
)
|
||||
|
65
unittest/controller/testConfigFileHandler.cpp
Normal file
65
unittest/controller/testConfigFileHandler.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
|
||||
|
||||
#include <mission/utility/GlobalConfigHandler.h>
|
||||
#include <objects/systemObjectList.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "../testEnvironment.h"
|
||||
|
||||
TEST_CASE("Configfile Handler", "[ConfigHandler]") {
|
||||
sif::debug << "Testcase config file handler" << std::endl;
|
||||
// Init handler
|
||||
GlobalConfigHandler confighandler = GlobalConfigHandler(objects::GLOBAL_JSON_CFG, "JSON.config");
|
||||
REQUIRE(confighandler.initialize() == returnvalue::OK);
|
||||
|
||||
// Reset handler
|
||||
REQUIRE(confighandler.ResetConfigFile() == returnvalue::OK);
|
||||
|
||||
// Get and set double as well as int values
|
||||
double doubleData = 0.0;
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == returnvalue::OK);
|
||||
REQUIRE(doubleData == 5.0);
|
||||
|
||||
doubleData = 55.9;
|
||||
double doubleDataRead = 0;
|
||||
REQUIRE(confighandler.setConfigFileValue(PARAM0, doubleData) == returnvalue::OK);
|
||||
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleDataRead) == returnvalue::OK);
|
||||
REQUIRE(doubleDataRead == doubleData);
|
||||
|
||||
REQUIRE(confighandler.WriteConfigFile() == returnvalue::OK);
|
||||
|
||||
int intData = 0;
|
||||
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM1, intData) == returnvalue::OK);
|
||||
REQUIRE(intData == 905);
|
||||
|
||||
intData = 1337;
|
||||
int intDataRead = 0;
|
||||
REQUIRE(confighandler.setConfigFileValue(PARAM1, intData) == returnvalue::OK);
|
||||
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM1, intDataRead) == returnvalue::OK);
|
||||
REQUIRE(intDataRead == intData);
|
||||
|
||||
REQUIRE(confighandler.WriteConfigFile() == returnvalue::OK);
|
||||
|
||||
// Check file name
|
||||
REQUIRE(confighandler.getConfigFileName() == "JSON.config");
|
||||
|
||||
// Reset and check if it worked
|
||||
REQUIRE(confighandler.ResetConfigFile() == returnvalue::OK);
|
||||
|
||||
doubleData = 0.0;
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == returnvalue::OK);
|
||||
REQUIRE(doubleData == 5.0);
|
||||
|
||||
// Test invalid Parameter
|
||||
REQUIRE(confighandler.getConfigFileValue(PARAM2, doubleData) !=
|
||||
returnvalue::OK); // NVMParameterBase::KEY_NOT_EXISTS is private, why?
|
||||
REQUIRE(confighandler.setConfigFileValue(PARAM2, doubleData) != returnvalue::OK);
|
||||
std::filesystem::remove("JSON.config");
|
||||
}
|
@ -15,7 +15,7 @@ TEST_CASE("Thermal Controller", "[ThermalController]") {
|
||||
new TemperatureSensorsDummy();
|
||||
new SusDummy();
|
||||
|
||||
testEnvironment::initialize();
|
||||
//testEnvironment::initialize();
|
||||
|
||||
ThermalController controller(THERMAL_CONTROLLER_ID);
|
||||
ReturnValue_t result = controller.initialize();
|
||||
|
Reference in New Issue
Block a user