petriVM18
d9060734b0
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
|
|
|
|
#include <mission/utility/GlobalConfigHandler.h>
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
|
|
#include "../testEnvironment.h"
|
|
#include <objects/systemObjectList.h>
|
|
|
|
TEST_CASE("Configfile Handler", "[ConfigHandler]") {
|
|
|
|
sif::debug<<"Testcase config file handler"<<std::endl;
|
|
|
|
//Init handler
|
|
GlobalConfigHandler confighandler= GlobalConfigHandler(objects::CONFIG_TEST,"JSON.config");
|
|
REQUIRE(confighandler.initialize() == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
//Reset handler
|
|
REQUIRE(confighandler.resetConfigFileValues() == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
//Get and set double as well as int values
|
|
double doubleData=0.0;
|
|
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
|
|
REQUIRE(doubleData==5.0);
|
|
|
|
doubleData=55.9;
|
|
double doubleDataRead=0;
|
|
REQUIRE(confighandler.setConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleDataRead) == HasReturnvaluesIF::RETURN_OK);
|
|
REQUIRE(doubleDataRead==doubleData);
|
|
|
|
REQUIRE(confighandler.WriteConfigFile()==HasReturnvaluesIF::RETURN_OK);
|
|
|
|
int intData=0;
|
|
|
|
REQUIRE(confighandler.getConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
|
|
REQUIRE(intData==905);
|
|
|
|
intData=1337;
|
|
int intDataRead=0;
|
|
REQUIRE(confighandler.setConfigFileValue(PARAM1, intData) == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
REQUIRE(confighandler.getConfigFileValue(PARAM1, intDataRead) == HasReturnvaluesIF::RETURN_OK);
|
|
REQUIRE(intDataRead==intData);
|
|
|
|
REQUIRE(confighandler.WriteConfigFile()==HasReturnvaluesIF::RETURN_OK);
|
|
|
|
//Check file name
|
|
REQUIRE(confighandler.getConfigFileName()=="JSON.config");
|
|
|
|
//Reset and check if it worked
|
|
REQUIRE(confighandler.resetConfigFileValues() == HasReturnvaluesIF::RETURN_OK);
|
|
|
|
doubleData=0.0;
|
|
REQUIRE(confighandler.getConfigFileValue(PARAM0, doubleData) == HasReturnvaluesIF::RETURN_OK);
|
|
REQUIRE(doubleData==5.0);
|
|
|
|
}
|