From ebf6afd2d7a949ad435e06d51356b1bc2ecb6fa0 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 15 May 2021 01:41:50 -0500 Subject: [PATCH] [ox/std] Cleanup tests (synced from 56269004d73484ee9ab67541e3908df093878ffa) --- src/ox/std/test/tests.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ox/std/test/tests.cpp b/src/ox/std/test/tests.cpp index 40af256dd..be6238aa0 100644 --- a/src/ox/std/test/tests.cpp +++ b/src/ox/std/test/tests.cpp @@ -17,10 +17,12 @@ std::map> tests = { { "malloc", [] { - ox::Vector buff(ox::units::MB); + ox::Buffer buff(ox::units::MB); ox::heapmgr::initHeap(&buff[0], &buff[buff.size()-1]); - oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken"); - oxAssert(ox::heapmgr::malloc(5) != nullptr, "malloc is broken"); + auto a1 = ox::bit_cast(ox::heapmgr::malloc(5)); + auto a2 = ox::bit_cast(ox::heapmgr::malloc(5)); + oxAssert(a1 >= &buff.front().value && a1 < &buff.back().value, "malloc is broken"); + oxAssert(a2 >= &buff.front().value && a2 < &buff.back().value && a2 > a1 + 5, "malloc is broken"); return OxError(0); } }, @@ -89,12 +91,13 @@ std::map> tests = { oxAssert(v.size() == 0, "Initial Vector size not 0"); auto insertTest = [&v](int val, [[maybe_unused]] std::size_t size) { v.push_back(val); - oxAssert(v.size() == size, "Vector size incorrect"); - oxAssert(v[v.size() - 1] == val, "Vector value wrong"); + oxReturnError(OxError(v.size() != size, "Vector size incorrect")); + oxReturnError(OxError(v[v.size() - 1] != val, "Vector value wrong")); + return OxError(0); }; - insertTest(42, 1); - insertTest(100, 2); - insertTest(102, 3); + oxAssert(insertTest(42, 1), "Vector insertion failed"); + oxAssert(insertTest(100, 2), "Vector insertion failed"); + oxAssert(insertTest(102, 3), "Vector insertion failed"); return OxError(0); } },