From b61f81abf05a9ced36c9bd1235f71555e55a8e6a Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Mon, 4 Dec 2023 00:22:00 -0600 Subject: [PATCH] [ox] Make tests more consistent --- deps/ox/src/ox/claw/test/tests.cpp | 24 +++--- deps/ox/src/ox/event/test/tests.cpp | 16 ++-- deps/ox/src/ox/fs/test/tests.cpp | 51 +++++++------ deps/ox/src/ox/mc/test/tests.cpp | 29 ++++---- deps/ox/src/ox/model/test/tests.cpp | 25 ++++--- deps/ox/src/ox/oc/test/tests.cpp | 110 ++++++++++++++-------------- deps/ox/src/ox/std/test/tests.cpp | 53 +++++++------- 7 files changed, 157 insertions(+), 151 deletions(-) diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index a76303c0..a9fb8887 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -8,11 +8,7 @@ #undef NDEBUG -#include -#include #include -#include -#include #include #include #include @@ -107,7 +103,7 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) { return OxError(0); } -static std::map tests = { +static std::map tests = { { { "ClawHeaderReader", @@ -192,14 +188,14 @@ static std::map tests = { }; int main(int argc, const char **args) { - int retval = -1; - if (argc > 0) { - auto testName = args[1]; - if (tests.find(testName) != tests.end()) { - retval = static_cast(tests[testName]()); - } else { - retval = 1; - } + if (argc < 2) { + oxError("Must specify test to run"); } - return retval; + 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; } diff --git a/deps/ox/src/ox/event/test/tests.cpp b/deps/ox/src/ox/event/test/tests.cpp index 8fd6eff9..b04d02bc 100644 --- a/deps/ox/src/ox/event/test/tests.cpp +++ b/deps/ox/src/ox/event/test/tests.cpp @@ -21,7 +21,7 @@ struct TestStruct: public ox::SignalHandler { } }; -std::map> tests = { +std::map> tests = { { "test1", [] { @@ -39,12 +39,14 @@ std::map> tests = { }; int main(int argc, const char **args) { - if (argc > 1) { - auto testName = args[1]; - if (tests.find(testName) != tests.end()) { - oxAssert(tests[testName](), "Test returned Error"); - return 0; - } + if (argc < 2) { + oxError("Must specify test to run"); + } + 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; } diff --git a/deps/ox/src/ox/fs/test/tests.cpp b/deps/ox/src/ox/fs/test/tests.cpp index 085d5579..ba2f8eb7 100644 --- a/deps/ox/src/ox/fs/test/tests.cpp +++ b/deps/ox/src/ox/fs/test/tests.cpp @@ -26,11 +26,11 @@ struct OX_PACKED NodeType: public ox::ptrarith::Item { } }; -const std::map> tests = { +const std::map> tests = { { { "PtrArith::setSize", - [](std::string_view) { + [](ox::StringView) { using BuffPtr_t = uint32_t; ox::Vector buff(5 * ox::units::MB); auto buffer = new (buff.data()) ox::ptrarith::NodeBuffer>(buff.size()); @@ -57,7 +57,7 @@ const std::map> tes }, { "PathIterator::next1", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("/usr/share/charset.gbag"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -69,7 +69,7 @@ const std::map> tes }, { "PathIterator::next2", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("/usr/share/"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -80,7 +80,7 @@ const std::map> tes }, { "PathIterator::next3", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("/"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -90,7 +90,7 @@ const std::map> tes }, { "PathIterator::next4", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("usr/share/charset.gbag"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -102,7 +102,7 @@ const std::map> tes }, { "PathIterator::next5", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("usr/share/"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -113,7 +113,7 @@ const std::map> tes }, { "PathIterator::dirPath", - [] (std::string_view) { + [] (ox::StringView) { auto const path = ox::String("/usr/share/charset.gbag"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -123,7 +123,7 @@ const std::map> tes }, { "PathIterator::fileName", - [](std::string_view) { + [](ox::StringView) { auto const path = ox::String("/usr/share/charset.gbag"); ox::PathIterator it(path.c_str(), path.len()); auto buff = static_cast(ox_alloca(path.len() + 1)); @@ -133,7 +133,7 @@ const std::map> tes }, { "PathIterator::hasNext", - [](std::string_view) { + [](ox::StringView) { const auto path = "/file1"; ox::PathIterator it(path, ox_strlen(path)); oxAssert(it.hasNext(), "PathIterator shows incorrect hasNext"); @@ -143,7 +143,7 @@ const std::map> tes }, { "Ptr::subPtr", - [](std::string_view) { + [](ox::StringView) { constexpr auto buffLen = 5000; ox::ptrarith::Ptr p(ox_alloca(buffLen), buffLen, 500, 500); oxAssert(p.valid(), "Ptr::subPtr: Ptr p is invalid."); @@ -155,7 +155,7 @@ const std::map> tes }, { "NodeBuffer::insert", - [](std::string_view) { + [](ox::StringView) { constexpr auto buffLen = 5000; auto list = new (ox_alloca(buffLen)) ox::ptrarith::NodeBuffer>(buffLen); oxAssert(list->malloc(50).value.valid(), "NodeBuffer::insert: malloc 1 failed"); @@ -168,7 +168,7 @@ const std::map> tes }, { "FileStore::readWrite", - [](std::string_view) { + [](ox::StringView) { constexpr auto buffLen = 5000; constexpr auto str1 = "Hello, World!"; constexpr auto str1Len = ox_strlen(str1) + 1; @@ -189,7 +189,7 @@ const std::map> tes }, { "Directory", - [](std::string_view) { + [](ox::StringView) { ox::Vector fsBuff(5000); oxAssert(ox::FileStore32::format(fsBuff.data(), fsBuff.size()), "FS format failed"); ox::FileStore32 fileStore(fsBuff.data(), fsBuff.size()); @@ -216,7 +216,7 @@ const std::map> tes }, { "FileSystem", - [](std::string_view) { + [](ox::StringView) { ox::Vector fsBuff(5000); oxTrace("ox.fs.test.FileSystem") << "format"; oxAssert(ox::FileSystem32::format(fsBuff.data(), fsBuff.size()), "FileSystem format failed"); @@ -237,16 +237,15 @@ const std::map> tes }; int main(int argc, const char **args) { - int retval = -1; - if (argc > 1) { - std::string_view testName = args[1]; - std::string_view testArg; - if (args[2]) { - testArg = args[2]; - } - if (tests.find(testName) != tests.end()) { - retval = static_cast(tests.at(testName)(testArg)); - } + if (argc < 3) { + oxError("Must specify test to run and test argument"); } - return retval; + ox::StringView const testName = args[1]; + ox::StringView const testArg = args[2] ? args[2] : nullptr; + auto const func = tests.find(testName); + if (func != tests.end()) { + oxAssert(func->second(testArg), "Test returned Error"); + return 0; + } + return -1; } diff --git a/deps/ox/src/ox/mc/test/tests.cpp b/deps/ox/src/ox/mc/test/tests.cpp index 1c9b1128..95b34842 100644 --- a/deps/ox/src/ox/mc/test/tests.cpp +++ b/deps/ox/src/ox/mc/test/tests.cpp @@ -105,10 +105,10 @@ constexpr ox::Error model(T *io, ox::CommonPtrWith auto *obj) noexce return OxError(0); } -std::map tests = { +std::map 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 tests = { }, { - ox::String("MetalClawReader"), + "MetalClawReader", [] { // setup for tests TestStruct testIn, testOut; @@ -180,7 +180,7 @@ std::map tests = { }, { - ox::String("encodeInteger"), + "encodeInteger", [] { using ox::MaxValue; using ox::mc::McInt; @@ -251,7 +251,7 @@ std::map tests = { }, { - ox::String("decodeInteger"), + "decodeInteger", [] { using ox::MaxValue; using ox::mc::McInt; @@ -293,7 +293,7 @@ std::map tests = { { - ox::String("MetalClawModelValue"), + "MetalClawModelValue", [] { static constexpr size_t dataBuffLen = ox::units::MB; ox::Buffer dataBuff(dataBuffLen); @@ -345,7 +345,7 @@ std::map tests = { }, { - ox::String("MetalClawDef"), + "MetalClawDef", [] { //constexpr size_t descBuffLen = 1024; //uint8_t descBuff[descBuffLen]; @@ -460,11 +460,14 @@ std::map 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; } diff --git a/deps/ox/src/ox/model/test/tests.cpp b/deps/ox/src/ox/model/test/tests.cpp index 3fd45519..539a8f1e 100644 --- a/deps/ox/src/ox/model/test/tests.cpp +++ b/deps/ox/src/ox/model/test/tests.cpp @@ -32,10 +32,10 @@ constexpr auto getModelTypeVersion(TestType2*) noexcept { return 2; } -std::map tests = { +std::map tests = { { { - ox::String("ModelValue"), + "ModelValue", [] { ox::ModelValue v; oxReturnError(v.setType()); @@ -47,16 +47,18 @@ std::map tests = { return ox::Error{}; } }, + { - ox::String("getModelTypeName"), + "getModelTypeName", [] { oxAssert(ox::getModelTypeName() == TestType::TypeName, "getModelTypeName call failed"); oxAssert(ox::getModelTypeName() == ox::StringView("net.drinkingtea.model.test.TestType2"), "getModelTypeName call failed"); return ox::Error{}; } }, + { - ox::String("getModelTypeVersion"), + "getModelTypeVersion", [] { oxAssert(ox::getModelTypeVersion() == TestType::TypeVersion, "getModelTypeVersion call failed"); oxAssert(ox::getModelTypeVersion() == 2, "getModelTypeVersion call failed"); @@ -67,11 +69,14 @@ std::map 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; } diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index 89374fad..79a88d3a 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -124,7 +124,7 @@ constexpr TestStruct &TestStruct::operator=(TestStruct &&other) noexcept { return *this; } -const std::map tests = { +const std::map tests = { { { "OrganicClawWriter", @@ -189,53 +189,53 @@ const std::map tests = { }, { - "OrganicClawModelValue", - [] { - ox::Buffer dataBuff; - TestStruct testIn; - testIn.Bool = true; - testIn.Int = 42; - testIn.String = "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.String = "Test String 2"; - testIn.unionIdx = 1; - testIn.Union.Int = 93; - oxAssert(ox::writeOC(testIn).moveTo(&dataBuff), "Data generation failed"); - ox::TypeStore typeStore; - auto type = ox::buildTypeDef(&typeStore, &testIn); - oxAssert(type.error, "Descriptor write failed"); - ox::ModelObject testOut; - oxReturnError(testOut.setType(type.value)); - oxAssert(ox::readOC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed"); - oxAssert(testOut.get("Int").unwrap()->get() == testIn.Int, "testOut.Int failed"); - oxAssert(testOut.get("Bool").unwrap()->get() == testIn.Bool, "testOut.Bool failed"); - oxAssert(testOut.get("String").unwrap()->get() == testIn.String, "testOut.String failed"); - auto &testOutStruct = testOut.get("Struct").unwrap()->get(); - auto &testOutUnion = testOut.get("Union").unwrap()->get(); - auto &testOutList = testOut.get("List").unwrap()->get(); - auto testOutStructCopy = testOut.get("Struct").unwrap()->get(); - auto testOutUnionCopy = testOut.get("Union").unwrap()->get(); - auto testOutListCopy = testOut.get("List").unwrap()->get(); - oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed"); - oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed"); - oxAssert(testOutStruct.get("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool failed"); - oxAssert(testOutStruct.get("String").unwrap()->get() == testIn.Struct.String.c_str(), "testOut.Struct.String failed"); - oxAssert(testOut.get("unionIdx").unwrap()->get() == testIn.unionIdx, "testOut.unionIdx failed"); - oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong"); - oxAssert(testOutUnion.get("Int").unwrap()->get() == testIn.Union.Int, "testOut.Union.Int failed"); - oxAssert(testOutList[0].get() == testIn.List[0], "testOut.List[0] failed"); - oxAssert(testOutList[1].get() == testIn.List[1], "testOut.Struct.List[1] failed"); - oxAssert(testOutStructCopy.get("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed"); - oxAssert(testOutStructCopy.get("String").unwrap()->get() == testIn.Struct.String.c_str(), "testOut.Struct.String (copy) failed"); - oxAssert(testOutListCopy[0].get() == testIn.List[0], "testOut.Struct.List[0] (copy) failed"); - oxAssert(testOutListCopy[1].get() == testIn.List[1], "testOut.Struct.List[1] (copy) failed"); - return OxError(0); - } + "OrganicClawModelValue", + [] { + ox::Buffer dataBuff; + TestStruct testIn; + testIn.Bool = true; + testIn.Int = 42; + testIn.String = "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.String = "Test String 2"; + testIn.unionIdx = 1; + testIn.Union.Int = 93; + oxAssert(ox::writeOC(testIn).moveTo(&dataBuff), "Data generation failed"); + ox::TypeStore typeStore; + auto type = ox::buildTypeDef(&typeStore, &testIn); + oxAssert(type.error, "Descriptor write failed"); + ox::ModelObject testOut; + oxReturnError(testOut.setType(type.value)); + oxAssert(ox::readOC(dataBuff.data(), dataBuff.size(), &testOut), "Data read failed"); + oxAssert(testOut.get("Int").unwrap()->get() == testIn.Int, "testOut.Int failed"); + oxAssert(testOut.get("Bool").unwrap()->get() == testIn.Bool, "testOut.Bool failed"); + oxAssert(testOut.get("String").unwrap()->get() == testIn.String, "testOut.String failed"); + auto &testOutStruct = testOut.get("Struct").unwrap()->get(); + auto &testOutUnion = testOut.get("Union").unwrap()->get(); + auto &testOutList = testOut.get("List").unwrap()->get(); + auto testOutStructCopy = testOut.get("Struct").unwrap()->get(); + auto testOutUnionCopy = testOut.get("Union").unwrap()->get(); + auto testOutListCopy = testOut.get("List").unwrap()->get(); + oxAssert(testOutStruct.typeName() == TestStructNest::TypeName, "ModelObject TypeName failed"); + oxAssert(testOutStruct.typeVersion() == TestStructNest::TypeVersion, "ModelObject TypeVersion failed"); + oxAssert(testOutStruct.get("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool failed"); + oxAssert(testOutStruct.get("String").unwrap()->get() == testIn.Struct.String.c_str(), "testOut.Struct.String failed"); + oxAssert(testOut.get("unionIdx").unwrap()->get() == testIn.unionIdx, "testOut.unionIdx failed"); + oxAssert(testOutUnion.unionIdx() == testIn.unionIdx, "testOut.Union idx wrong"); + oxAssert(testOutUnion.get("Int").unwrap()->get() == testIn.Union.Int, "testOut.Union.Int failed"); + oxAssert(testOutList[0].get() == testIn.List[0], "testOut.List[0] failed"); + oxAssert(testOutList[1].get() == testIn.List[1], "testOut.Struct.List[1] failed"); + oxAssert(testOutStructCopy.get("Bool").unwrap()->get() == testIn.Struct.Bool, "testOut.Struct.Bool (copy) failed"); + oxAssert(testOutStructCopy.get("String").unwrap()->get() == testIn.Struct.String.c_str(), "testOut.Struct.String (copy) failed"); + oxAssert(testOutListCopy[0].get() == testIn.List[0], "testOut.Struct.List[0] (copy) failed"); + oxAssert(testOutListCopy[1].get() == testIn.List[1], "testOut.Struct.List[1] (copy) failed"); + return OxError(0); + } }, { @@ -354,13 +354,11 @@ int main(int argc, const char **args) { if (argc < 2) { oxError("Must specify test to run"); } - const auto testName = args[1]; - ox::Error(*test)(); - try { - test = tests.at(testName); - } catch (const std::out_of_range&) { - oxErrorf("Test {} not found", testName); - return 1; + auto const testName = args[1]; + auto const func = tests.find(testName); + if (func != tests.end()) { + oxAssert(func->second(), "Test returned Error"); + return 0; } - return static_cast(test()); + return -1; } diff --git a/deps/ox/src/ox/std/test/tests.cpp b/deps/ox/src/ox/std/test/tests.cpp index a31d860e..a394fef8 100644 --- a/deps/ox/src/ox/std/test/tests.cpp +++ b/deps/ox/src/ox/std/test/tests.cpp @@ -12,9 +12,9 @@ #include #include -static std::map tests = { +static std::map tests = { { - ox::String("malloc"), + "malloc", [] { ox::Buffer buff(ox::units::MB); ox::heapmgr::initHeap(&buff[0], &buff[buff.size()-1]); @@ -26,7 +26,7 @@ static std::map tests = { } }, { - ox::String("itoa"), + "itoa", []() { ox::Array buff; ox::CharBuffWriter bw(buff); @@ -42,31 +42,31 @@ static std::map tests = { } }, { - ox::String("ABCDEFG != HIJKLMN"), + "ABCDEFG != HIJKLMN", []() { return OxError(ox_memcmp("ABCDEFG", "HIJKLMN", 7) >= 0); } }, { - ox::String("HIJKLMN != ABCDEFG"), + "HIJKLMN != ABCDEFG", []() { return OxError(ox_memcmp("HIJKLMN", "ABCDEFG", 7) <= 0); } }, { - ox::String("ABCDEFG == ABCDEFG"), + "ABCDEFG == ABCDEFG", []() { return OxError(ox_memcmp("ABCDEFG", "ABCDEFG", 7) != 0); } }, { - ox::String("ABCDEFGHI == ABCDEFG"), + "ABCDEFGHI == ABCDEFG", []() { return OxError(ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0); } }, { - ox::String("BString"), + "BString", []() { ox::BString<5> s; s += "A"; @@ -82,7 +82,7 @@ static std::map tests = { } }, { - ox::String("String"), + "String", []() { ox::String s; s += "A"; @@ -113,10 +113,11 @@ static std::map tests = { } }, { - ox::String("Vector"), + "Vector", [] { ox::Vector v; oxAssert(v.size() == 0, "Initial Vector size not 0"); + oxAssert(v.empty(), "Vector::empty() is broken"); auto insertTest = [&v](int val, [[maybe_unused]] std::size_t size) { v.push_back(val); oxReturnError(OxError(v.size() != size, "Vector size incorrect")); @@ -130,7 +131,7 @@ static std::map tests = { } }, { - ox::String("HashMap"), + "HashMap", [] { ox::HashMap si; si["asdf"] = 42; @@ -146,7 +147,7 @@ static std::map tests = { } }, { - ox::String("Serialize-Int"), + "Serialize-Int", [] { using BA = ox::Array; const auto actual = ox::serialize(256).unwrap(); @@ -163,7 +164,7 @@ static std::map tests = { } }, { - ox::String("BufferWriter"), + "BufferWriter", [] { ox::Buffer b; ox::BufferWriter w(&b); @@ -172,7 +173,7 @@ static std::map tests = { oxAssert(w.write("aoeu", 4), "write failed"); oxExpect(b.size(), 8u); oxExpect(ox::StringView(b.data(), b.size()), "asdfaoeu"); - ox::StringView qwerty = "qwerty"; + ox::StringView constexpr qwerty = "qwerty"; oxAssert(w.write(qwerty.data(), qwerty.bytes()), "write failed"); oxExpect(b.size(), 14u); oxExpect(ox::StringView(b.data(), b.size()), "asdfaoeuqwerty"); @@ -180,7 +181,7 @@ static std::map tests = { } }, { - ox::String("FromHex"), + "FromHex", [] { oxExpect(ox::detail::fromHex("01").unwrap(), 0x01); oxExpect(ox::detail::fromHex("02").unwrap(), 0x02); @@ -203,7 +204,7 @@ static std::map tests = { } }, { - ox::String("ToHex"), + "ToHex", [] { oxExpect(ox::detail::toHex(0x01), "01"); oxExpect(ox::detail::toHex(0x02), "02"); @@ -223,7 +224,7 @@ static std::map tests = { } }, { - ox::String("UUID"), + "UUID", [] { constexpr ox::StringView uuidStr = "8d814442-f46e-4cc3-8edc-ca3c01cc86db"; oxRequire(uuid, ox::UUID::fromString(uuidStr)); @@ -234,7 +235,7 @@ static std::map tests = { } }, { - ox::String("UUID::generate"), + "UUID::generate", [] { ox::UUID::seedGenerator({1234, 4321}); oxExpect(ox::UUID::generate().unwrap().toString(), "5c3f4b5e-ccbf-4727-7f03-3053dedc8827"); @@ -244,7 +245,7 @@ static std::map tests = { } }, { - ox::String("StringSplit"), + "StringSplit", [] { ox::StringView sv = "ab.cd"; auto list = ox::split(sv, "."); @@ -313,12 +314,14 @@ static std::map tests = { }; int main(int argc, const char **args) { - if (argc > 1) { - auto testName = ox::String(args[1]); - if (tests.find(testName) != tests.end()) { - oxAssert(tests[testName](), "Test returned Error"); - return 0; - } + if (argc < 2) { + oxError("Must specify test to run"); + } + 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; }