From 25c629f5706d0d85b80891fca3a1782f1a5efb53 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 17 Jul 2019 21:25:33 -0500 Subject: [PATCH] [ox/ptrarith] Expand tests --- deps/ox/src/ox/ptrarith/test/tests.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/deps/ox/src/ox/ptrarith/test/tests.cpp b/deps/ox/src/ox/ptrarith/test/tests.cpp index 991187a8..e15546c5 100644 --- a/deps/ox/src/ox/ptrarith/test/tests.cpp +++ b/deps/ox/src/ox/ptrarith/test/tests.cpp @@ -28,7 +28,6 @@ using namespace ox; template struct __attribute__((packed)) NodeType: public ox::ptrarith::Item { public: - int i = 0; size_t fullSize() const { return this->size() + sizeof(*this); } @@ -42,8 +41,17 @@ map tests = { using BuffPtr_t = uint32_t; std::vector buff(5 * ox::units::MB); auto buffer = new (buff.data()) ox::ptrarith::NodeBuffer>(buff.size()); - auto a1 = buffer->malloc(50); - auto a2 = buffer->malloc(50); + using String = BString<6>; + auto a1 = buffer->malloc(sizeof(String)); + auto a2 = buffer->malloc(sizeof(String)); + oxAssert(a1.valid(), "Allocation 1 failed."); + oxAssert(a2.valid(), "Allocation 2 failed."); + auto &s1 = *new (buffer->dataOf(a1)) String("asdf"); + auto &s2 = *new (buffer->dataOf(a2)) String("aoeu"); + oxTrace("test") << "s1: " << s1.c_str(); + oxTrace("test") << "s2: " << s2.c_str(); + oxAssert(s1 == "asdf", "Allocation 1 not as expected."); + oxAssert(s2 == "aoeu", "Allocation 2 not as expected."); oxAssert(buffer->free(a1), "Free failed."); oxAssert(buffer->free(a2), "Free failed."); oxAssert(buffer->setSize(buffer->size() - buffer->available()), "Resize failed.");