I am trying to convert my JSON object to a string in test case 1 and 4. When test case 4 is removed, the code works properly, like the output shows up. But when I include test case 4, the code won't run. VS Code says segmentation error. I tried doing j.get<decltype(s)>()
for both and the code would compile, but the output won't show up. Any solutions?
#include "records_manager_test.hpp"
#include "records_manager.hpp"
#include "nlohmann/json.hpp"
using json = nlohmann::json;
bool RecordsManagerTest::test1(){ //To test JSON
json j = {
{"1", {
{"CategoryID",67},
{"PatientID",90},
{"Name","Foo"},
{"Address","Bar"},
{"DOB","100980"}
}},
{"2",{
{"CategoryID", 6},
{"PatientID", 9},
{"Name", "Ryan"},
{"Address", "161 University Ave"},
{"DOB", "180998"}
}}
};
string s = j.dump(4); //Stringfying JSON
RecordsManager test(s);
if(test.insertRecord(89,89,"Eric","161 University Avenue","010195"));
{
test.printAsJSON();
return true;
}
}
bool RecordsManagerTest::test2(){ // To test insert of record
RecordsManager test;
if(test.insertRecord(88,89,"Eric","161 University Avenue","040485")){
if(test.insertRecord(88,90,"Ryan","161 University Avenue","160695")){
return true;
}
}
return false;
}
bool RecordsManagerTest::test3(){ //To test removal of record
RecordsManager test;
test.insertRecord(88,89,"Eric","dfdf","46465");
test.insertRecord(88,90,"Eric","dfdf","46465");
if(test.removeRecord(89,89))
{
test.printAsJSON();
return true;
}
return false;
}
bool RecordsManagerTest::test4(){ //To test JSON
json j = {
{"1", {
{"CategoryID",67},
{"PatientID",90},
{"Name","Foo"},
{"Address","Bar"},
{"DOB","100980"}
}},
{"2",{
{"CategoryID", 6},
{"PatientID", 9},
{"Name", "Ryan"},
{"Address", "161 University Ave"},
{"DOB", "180998"}
}}
};
//Stringfying JSON
string s1 = j.dump(4);
RecordsManager test(s1);
if(test.insertRecord(89,89,"Eric","161 University Avenue","010195"));
{
test.printAsJSON();
return true;
}
}