/* * Copyright 2015 - 2025 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 #include struct TestStruct: public ox::SignalHandler { int value = 0; ox::Error method(int i) noexcept { value = i; return ox::Error(0); } }; std::map> tests = { { "test1", [] { ox::Signal signal; signal.connect([](int i) -> ox::Error { return ox::Error(i != 5); }); TestStruct ts; signal.connect(&ts, &TestStruct::method); OX_RETURN_ERROR(signal.emitCheckError(5)); OX_RETURN_ERROR(ox::Error(ts.value != 5)); return ox::Error(0); } }, }; 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; }