[ox] Rename BString to IString
This commit is contained in:
32
deps/ox/src/ox/mc/test/tests.cpp
vendored
32
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -27,7 +27,7 @@ struct TestStructNest {
|
||||
static constexpr auto TypeVersion = 1;
|
||||
bool Bool = false;
|
||||
uint32_t Int = 0;
|
||||
ox::BString<32> BString = "";
|
||||
ox::IString<32> IString = "";
|
||||
};
|
||||
|
||||
struct TestStruct {
|
||||
@ -46,7 +46,7 @@ struct TestStruct {
|
||||
int unionIdx = 1;
|
||||
TestUnion Union;
|
||||
ox::String String;
|
||||
ox::BString<32> BString = "";
|
||||
ox::IString<32> IString = "";
|
||||
uint32_t List[4] = {0, 0, 0, 0};
|
||||
ox::Vector<uint32_t> Vector = {1, 2, 3, 4, 5};
|
||||
ox::Vector<uint32_t> Vector2 = {1, 2, 3, 4, 5};
|
||||
@ -72,7 +72,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestUnion> auto *obj) noexcep
|
||||
oxModelBegin(TestStructNest)
|
||||
oxModelField(Bool)
|
||||
oxModelField(Int)
|
||||
oxModelField(BString)
|
||||
oxModelField(IString)
|
||||
oxModelEnd()
|
||||
|
||||
template<typename T>
|
||||
@ -95,7 +95,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStruct> auto *obj) noexce
|
||||
oxReturnError(io->field("Union", ox::UnionView{&obj->Union, obj->unionIdx}));
|
||||
}
|
||||
oxReturnError(io->field("String", &obj->String));
|
||||
oxReturnError(io->field("BString", &obj->BString));
|
||||
oxReturnError(io->field("IString", &obj->IString));
|
||||
oxReturnError(io->field("List", obj->List, 4));
|
||||
oxReturnError(io->field("Vector", &obj->Vector));
|
||||
oxReturnError(io->field("Vector2", &obj->Vector2));
|
||||
@ -127,7 +127,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
TestStruct testIn, testOut;
|
||||
testIn.Bool = true;
|
||||
testIn.Int = 42;
|
||||
testIn.BString = "Test String 1";
|
||||
testIn.IString = "Test String 1";
|
||||
testIn.String = "Test String 2";
|
||||
testIn.Vector = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, };
|
||||
testIn.Vector2 = {};
|
||||
@ -137,7 +137,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
testIn.List[3] = 4;
|
||||
testIn.Struct.Bool = true;
|
||||
testIn.Struct.Int = 300;
|
||||
testIn.Struct.BString = "Test String 3";
|
||||
testIn.Struct.IString = "Test String 3";
|
||||
testIn.unionIdx = 1;
|
||||
testIn.Union.Int = 93;
|
||||
// run tests
|
||||
@ -157,7 +157,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
oxAssert(testIn.Int8 == testOut.Int8, "Int8 value mismatch");
|
||||
oxAssert(testIn.Union.Int == testOut.Union.Int, "Union.Int value mismatch");
|
||||
oxAssert(testIn.String == testOut.String, "String value mismatch");
|
||||
oxAssert(testIn.BString == testOut.BString, "BString value mismatch");
|
||||
oxAssert(testIn.IString == testOut.IString, "IString value mismatch");
|
||||
oxAssert(testIn.List[0] == testOut.List[0], "List[0] value mismatch");
|
||||
oxAssert(testIn.List[1] == testOut.List[1], "List[1] value mismatch");
|
||||
oxAssert(testIn.List[2] == testOut.List[2], "List[2] value mismatch");
|
||||
@ -171,9 +171,9 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
oxAssert(testIn.Map["aoeu"] == testOut.Map["aoeu"], "Map[\"aoeu\"] value mismatch");
|
||||
oxAssert(testIn.EmptyStruct.Bool == testOut.EmptyStruct.Bool, "EmptyStruct.Bool value mismatch");
|
||||
oxAssert(testIn.EmptyStruct.Int == testOut.EmptyStruct.Int, "EmptyStruct.Int value mismatch");
|
||||
oxAssert(testIn.EmptyStruct.BString == testOut.EmptyStruct.BString, "EmptyStruct.BString value mismatch");
|
||||
oxAssert(testIn.EmptyStruct.IString == testOut.EmptyStruct.IString, "EmptyStruct.IString value mismatch");
|
||||
oxAssert(testIn.Struct.Int == testOut.Struct.Int, "Struct.Int value mismatch");
|
||||
oxAssert(testIn.Struct.BString == testOut.Struct.BString, "Struct.BString value mismatch");
|
||||
oxAssert(testIn.Struct.IString == testOut.Struct.IString, "Struct.IString value mismatch");
|
||||
oxAssert(testIn.Struct.Bool == testOut.Struct.Bool, "Struct.Bool value mismatch");
|
||||
return OxError(0);
|
||||
}
|
||||
@ -303,14 +303,14 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
TestStruct testIn;
|
||||
testIn.Bool = true;
|
||||
testIn.Int = 42;
|
||||
testIn.BString = "Test String 1";
|
||||
testIn.IString = "Test String 1";
|
||||
testIn.List[0] = 1;
|
||||
testIn.List[1] = 2;
|
||||
testIn.List[2] = 3;
|
||||
testIn.List[3] = 4;
|
||||
testIn.Struct.Bool = true;
|
||||
testIn.Struct.Int = 300;
|
||||
testIn.Struct.BString = "Test String 2";
|
||||
testIn.Struct.IString = "Test String 2";
|
||||
testIn.unionIdx = 1;
|
||||
testIn.Union.Int = 93;
|
||||
oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), testIn), "Data generation failed");
|
||||
@ -322,7 +322,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
oxAssert(ox::readMC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed");
|
||||
oxAssert(testOut.at("Int").unwrap()->get<int>() == testIn.Int, "testOut.Int failed");
|
||||
oxAssert(testOut.at("Bool").unwrap()->get<bool>() == testIn.Bool, "testOut.Bool failed");
|
||||
oxAssert(testOut.at("BString").unwrap()->get<ox::String>() == testIn.BString.c_str(), "testOut.String failed");
|
||||
oxAssert(testOut.at("IString").unwrap()->get<ox::String>() == testIn.IString.c_str(), "testOut.String failed");
|
||||
oxAssert(testOut.at("String").unwrap()->get<ox::String>() == testIn.String, "testOut.String failed");
|
||||
auto &testOutStruct = testOut.at("Struct").unwrap()->get<ox::ModelObject>();
|
||||
auto &testOutUnion = testOut.at("Union").unwrap()->get<ox::ModelUnion>();
|
||||
@ -333,14 +333,14 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed");
|
||||
oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed");
|
||||
oxAssert(testOutStruct.at("Bool").unwrap()->get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool failed");
|
||||
oxAssert(testOutStruct.at("BString").unwrap()->get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString failed");
|
||||
oxAssert(testOutStruct.at("IString").unwrap()->get<ox::String>() == testIn.Struct.IString.c_str(), "testOut.Struct.IString failed");
|
||||
oxAssert(testOut.at("unionIdx").unwrap()->get<int>() == testIn.unionIdx, "testOut.unionIdx failed");
|
||||
oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong");
|
||||
oxAssert(testOutUnion.at("Int").unwrap()->get<uint32_t>() == testIn.Union.Int, "testOut.Union.Int failed");
|
||||
oxAssert(testOutList[0].get<uint32_t>() == testIn.List[0], "testOut.List[0] failed");
|
||||
oxAssert(testOutList[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] failed");
|
||||
oxAssert(testOutStructCopy.at("Bool").unwrap()->get<bool>() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed");
|
||||
oxAssert(testOutStructCopy.at("BString").unwrap()->get<ox::String>() == testIn.Struct.BString.c_str(), "testOut.Struct.BString (copy) failed");
|
||||
oxAssert(testOutStructCopy.at("IString").unwrap()->get<ox::String>() == testIn.Struct.IString.c_str(), "testOut.Struct.IString (copy) failed");
|
||||
oxAssert(testOutListCopy[0].get<uint32_t>() == testIn.List[0], "testOut.Struct.List[0] (copy) failed");
|
||||
oxAssert(testOutListCopy[1].get<uint32_t>() == testIn.List[1], "testOut.Struct.List[1] (copy) failed");
|
||||
return OxError(0);
|
||||
@ -357,14 +357,14 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
TestStruct testIn, testOut;
|
||||
testIn.Bool = true;
|
||||
testIn.Int = 42;
|
||||
testIn.BString = "Test String 1";
|
||||
testIn.IString = "Test String 1";
|
||||
testIn.List[0] = 1;
|
||||
testIn.List[1] = 2;
|
||||
testIn.List[2] = 3;
|
||||
testIn.List[3] = 4;
|
||||
testIn.Struct.Bool = false;
|
||||
testIn.Struct.Int = 300;
|
||||
testIn.Struct.BString = "Test String 2";
|
||||
testIn.Struct.IString = "Test String 2";
|
||||
oxAssert(ox::writeMC(dataBuff, dataBuffLen, testIn), "Data generation failed");
|
||||
ox::TypeStore typeStore;
|
||||
const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn);
|
||||
|
Reference in New Issue
Block a user