corrections and tests
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
#include <bsp_q7s/memory/SdCardManager.h>
|
||||
#include "Q7STestTask.h"
|
||||
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
#include "test/DummyParameter.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <iostream>
|
||||
@ -16,16 +19,9 @@ Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) {
|
||||
|
||||
ReturnValue_t Q7STestTask::performOneShotAction() {
|
||||
//sdCardTests();
|
||||
testScratchApi();
|
||||
Stopwatch stopwatch;
|
||||
// for convenience
|
||||
using json = nlohmann::json;
|
||||
json helloTest;
|
||||
// add a number that is stored as double (note the implicit conversion of j to an object)
|
||||
helloTest["pi"] = 3.141;
|
||||
std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix();
|
||||
std::ofstream o("/mnt/sd0/pretty.json");
|
||||
o << std::setw(4) << helloTest << std::endl;
|
||||
//testScratchApi();
|
||||
//testJsonLibDirect();
|
||||
testDummyParams();
|
||||
return TestTask::performOneShotAction();
|
||||
}
|
||||
|
||||
@ -76,3 +72,42 @@ void Q7STestTask::testScratchApi() {
|
||||
sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void Q7STestTask::testJsonLibDirect() {
|
||||
Stopwatch stopwatch;
|
||||
// for convenience
|
||||
using json = nlohmann::json;
|
||||
json helloTest;
|
||||
// add a number that is stored as double (note the implicit conversion of j to an object)
|
||||
helloTest["pi"] = 3.141;
|
||||
std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix();
|
||||
std::string fileName = mntPrefix + "/pretty.json";
|
||||
std::ofstream o(fileName);
|
||||
o << std::setw(4) << helloTest << std::endl;
|
||||
}
|
||||
|
||||
void Q7STestTask::testDummyParams() {
|
||||
std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix();
|
||||
DummyParameter param(mntPrefix, "dummy_json.txt");
|
||||
param.printKeys();
|
||||
param.print();
|
||||
if(not param.getJsonFileExists()) {
|
||||
param.writeJsonFile();
|
||||
}
|
||||
|
||||
ReturnValue_t result = param.readJsonFile();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
||||
}
|
||||
|
||||
param.setValue(DummyParameter::DUMMY_KEY_PARAM_1, 3);
|
||||
param.setValue(DummyParameter::DUMMY_KEY_PARAM_2, "blirb");
|
||||
|
||||
param.writeJsonFile();
|
||||
param.print();
|
||||
|
||||
int test = param.getValue<int>(DummyParameter::DUMMY_KEY_PARAM_1);
|
||||
std::string test2 = param.getValue<std::string>(DummyParameter::DUMMY_KEY_PARAM_2);
|
||||
sif::info << "Test value (3 expected): " << test << std::endl;
|
||||
sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user