/* * Copyright 2015 - 2022 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #undef NDEBUG #include #include #include struct TestType { static constexpr auto TypeName = "net.drinkingtea.model.test.TestType"; static constexpr auto TypeVersion = 1; }; oxModelBegin(TestType) oxModelEnd() struct TestType2 { }; template constexpr auto getModelTypeName(TestType2*) noexcept { return "net.drinkingtea.model.test.TestType2"; } constexpr auto getModelTypeVersion(TestType2*) noexcept { return 2; } std::map tests = { { { "ModelValue", [] { ox::ModelValue v; oxReturnError(v.setType()); //v.m_type = ox::ModelValue::getType(); if (v.type() != ox::ModelValue::Type::SignedInteger32) { return OxError(1, "type is wrong"); } oxReturnError(v.set(5)); return ox::Error{}; } }, { "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{}; } }, { "getModelTypeVersion", [] { oxAssert(ox::getModelTypeVersion() == TestType::TypeVersion, "getModelTypeVersion call failed"); oxAssert(ox::getModelTypeVersion() == 2, "getModelTypeVersion call failed"); return ox::Error{}; } }, } }; int main(int argc, const char **args) { 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; }