[nostalgia/studio] Cleanup JSON test

This commit is contained in:
Gary Talent 2021-03-24 00:55:37 -05:00
parent 084cee44fa
commit 403d124e99

View File

@ -11,8 +11,6 @@
#include "json_read.hpp" #include "json_read.hpp"
#include "json_write.hpp" #include "json_write.hpp"
using namespace std;
using namespace ox;
using namespace nostalgia::studio; using namespace nostalgia::studio;
struct TestStructNest { struct TestStructNest {
@ -23,14 +21,13 @@ struct TestStructNest {
}; };
template<typename T> template<typename T>
Error model(T *io, TestStructNest *obj) { ox::Error model(T *io, TestStructNest *obj) {
auto err = OxError(0);
oxReturnError(io->setTypeInfo("TestStructNest", 4)); oxReturnError(io->setTypeInfo("TestStructNest", 4));
oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Bool", &obj->Bool));
oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->field("Int", &obj->Int));
oxReturnError(io->field("Double", &obj->Double)); oxReturnError(io->field("Double", &obj->Double));
oxReturnError(io->field("String", &obj->String)); oxReturnError(io->field("String", &obj->String));
return err; return OxError(0);
} }
struct TestStruct { struct TestStruct {
@ -42,15 +39,14 @@ struct TestStruct {
}; };
template<typename T> template<typename T>
Error model(T *io, TestStruct *obj) { ox::Error model(T *io, TestStruct *obj) {
auto err = OxError(0);
oxReturnError(io->setTypeInfo("TestStruct", 5)); oxReturnError(io->setTypeInfo("TestStruct", 5));
oxReturnError(io->field("Bool", &obj->Bool)); oxReturnError(io->field("Bool", &obj->Bool));
oxReturnError(io->field("Int", &obj->Int)); oxReturnError(io->field("Int", &obj->Int));
oxReturnError(io->field("Double", &obj->Double)); oxReturnError(io->field("Double", &obj->Double));
oxReturnError(io->field("String", &obj->String)); oxReturnError(io->field("String", &obj->String));
oxReturnError(io->field("Struct", &obj->Struct)); oxReturnError(io->field("Struct", &obj->Struct));
return err; return OxError(0);
} }
int main() { int main() {
@ -72,10 +68,10 @@ int main() {
oxReturnError(writeJson(&json, &ts)); oxReturnError(writeJson(&json, &ts));
oxReturnError(readJson(json, &tsOut)); oxReturnError(readJson(json, &tsOut));
cout << tsOut.Bool << endl; std::cout << tsOut.Bool << '\n';
cout << tsOut.Int << endl; std::cout << tsOut.Int << '\n';
cout << tsOut.Double << endl; std::cout << tsOut.Double << '\n';
cout << tsOut.String.toStdString() << endl; std::cout << tsOut.String.toStdString() << '\n';
oxAssert(tsOut.Bool, "Arg 1 failed"); oxAssert(tsOut.Bool, "Arg 1 failed");
oxAssert(tsOut.Int == 42, "Arg 2 failed"); oxAssert(tsOut.Int == 42, "Arg 2 failed");