[ox/std] Cleanup tests
This commit is contained in:
parent
9c08ab458a
commit
29a4bb920a
21
deps/ox/src/ox/std/test/tests.cpp
vendored
21
deps/ox/src/ox/std/test/tests.cpp
vendored
@ -6,12 +6,14 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#undef NDEBUG
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <ox/std/std.hpp>
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
std::map<std::string, std::function<int()>> tests = {
|
std::map<std::string, std::function<ox::Error()>> tests = {
|
||||||
{
|
{
|
||||||
"malloc",
|
"malloc",
|
||||||
[] {
|
[] {
|
||||||
@ -19,31 +21,31 @@ std::map<std::string, std::function<int()>> tests = {
|
|||||||
ox::heapmgr::initHeap(&buff.front(), &buff.back());
|
ox::heapmgr::initHeap(&buff.front(), &buff.back());
|
||||||
oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken");
|
oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken");
|
||||||
oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken");
|
oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken");
|
||||||
return 0;
|
return OxError(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ABCDEFG != HIJKLMN",
|
"ABCDEFG != HIJKLMN",
|
||||||
[]() {
|
[]() {
|
||||||
return ox_memcmp("ABCDEFG", "HIJKLMN", 7) >= 0;
|
return OxError(ox_memcmp("ABCDEFG", "HIJKLMN", 7) >= 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"HIJKLMN != ABCDEFG",
|
"HIJKLMN != ABCDEFG",
|
||||||
[]() {
|
[]() {
|
||||||
return ox_memcmp("HIJKLMN", "ABCDEFG", 7) <= 0;
|
return OxError(ox_memcmp("HIJKLMN", "ABCDEFG", 7) <= 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ABCDEFG == ABCDEFG",
|
"ABCDEFG == ABCDEFG",
|
||||||
[]() {
|
[]() {
|
||||||
return ox_memcmp("ABCDEFG", "ABCDEFG", 7) != 0;
|
return OxError(ox_memcmp("ABCDEFG", "ABCDEFG", 7) != 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ABCDEFGHI == ABCDEFG",
|
"ABCDEFGHI == ABCDEFG",
|
||||||
[]() {
|
[]() {
|
||||||
return ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0;
|
return OxError(ox_memcmp("ABCDEFGHI", "ABCDEFG", 7) != 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -89,7 +91,7 @@ std::map<std::string, std::function<int()>> tests = {
|
|||||||
insertTest(42, 1);
|
insertTest(42, 1);
|
||||||
insertTest(100, 2);
|
insertTest(100, 2);
|
||||||
insertTest(102, 3);
|
insertTest(102, 3);
|
||||||
return 0;
|
return OxError(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -100,7 +102,7 @@ std::map<std::string, std::function<int()>> tests = {
|
|||||||
v["aoeu"] = 100;
|
v["aoeu"] = 100;
|
||||||
oxAssert(v["asdf"] == 42, "asdf != 42");
|
oxAssert(v["asdf"] == 42, "asdf != 42");
|
||||||
oxAssert(v["aoeu"] == 100, "aoeu != 100");
|
oxAssert(v["aoeu"] == 100, "aoeu != 100");
|
||||||
return 0;
|
return OxError(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -109,7 +111,8 @@ int main(int argc, const char **args) {
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
auto testName = args[1];
|
auto testName = args[1];
|
||||||
if (tests.find(testName) != tests.end()) {
|
if (tests.find(testName) != tests.end()) {
|
||||||
return tests[testName]();
|
oxAssert(tests[testName](), "Test returned Error");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user