[ox] Make tests more consistent
This commit is contained in:
29
deps/ox/src/ox/mc/test/tests.cpp
vendored
29
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -105,10 +105,10 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith<TestStruct> auto *obj) noexce
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
std::map<ox::String, ox::Error(*)()> tests = {
|
||||
std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
{
|
||||
{
|
||||
ox::String("MetalClawWriter"),
|
||||
"MetalClawWriter",
|
||||
[] {
|
||||
// This test doesn't confirm much, but it does show that the writer
|
||||
// doesn't segfault
|
||||
@ -121,7 +121,7 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
},
|
||||
|
||||
{
|
||||
ox::String("MetalClawReader"),
|
||||
"MetalClawReader",
|
||||
[] {
|
||||
// setup for tests
|
||||
TestStruct testIn, testOut;
|
||||
@ -180,7 +180,7 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
},
|
||||
|
||||
{
|
||||
ox::String("encodeInteger"),
|
||||
"encodeInteger",
|
||||
[] {
|
||||
using ox::MaxValue;
|
||||
using ox::mc::McInt;
|
||||
@ -251,7 +251,7 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
},
|
||||
|
||||
{
|
||||
ox::String("decodeInteger"),
|
||||
"decodeInteger",
|
||||
[] {
|
||||
using ox::MaxValue;
|
||||
using ox::mc::McInt;
|
||||
@ -293,7 +293,7 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
|
||||
|
||||
{
|
||||
ox::String("MetalClawModelValue"),
|
||||
"MetalClawModelValue",
|
||||
[] {
|
||||
static constexpr size_t dataBuffLen = ox::units::MB;
|
||||
ox::Buffer dataBuff(dataBuffLen);
|
||||
@ -345,7 +345,7 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
},
|
||||
|
||||
{
|
||||
ox::String("MetalClawDef"),
|
||||
"MetalClawDef",
|
||||
[] {
|
||||
//constexpr size_t descBuffLen = 1024;
|
||||
//uint8_t descBuff[descBuffLen];
|
||||
@ -460,11 +460,14 @@ std::map<ox::String, ox::Error(*)()> tests = {
|
||||
};
|
||||
|
||||
int main(int argc, const char **args) {
|
||||
if (argc > 0) {
|
||||
auto testName = ox::String(args[1]);
|
||||
if (tests.find(testName) != tests.end()) {
|
||||
oxAssert(tests[testName](), "Test failed...");
|
||||
}
|
||||
if (argc < 2) {
|
||||
oxError("Must specify test to run");
|
||||
}
|
||||
return 0;
|
||||
auto const testName = args[1];
|
||||
auto const func = tests.find(testName);
|
||||
if (func != tests.end()) {
|
||||
oxAssert(func->second(), "Test returned Error");
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user