From 2b3f1aa0d5408a6c202200d657505e709b6e9724 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 17 Sep 2014 14:42:56 +0000 Subject: [PATCH] build: reactivate array::Insert. --- src/lol/base/array.h | 7 +++---- src/t/base/array.cpp | 33 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/lol/base/array.h b/src/lol/base/array.h index 08deb893..c3a3ba90 100644 --- a/src/lol/base/array.h +++ b/src/lol/base/array.h @@ -481,11 +481,11 @@ public: } ++this->m_count; } - /* + inline void Insert(ptrdiff_t pos, T... args) { - //ASSERT(pos >= 0); - //ASSERT(pos <= this->m_count); + ASSERT(pos >= 0); + ASSERT(pos <= this->m_count); if (this->m_count >= this->m_reserved) this->Grow(); @@ -498,7 +498,6 @@ public: new (&this->m_data[pos]) tuple({ args... }); ++this->m_count; } - */ }; template diff --git a/src/t/base/array.cpp b/src/t/base/array.cpp index 0c9d44b0..813c6803 100644 --- a/src/t/base/array.cpp +++ b/src/t/base/array.cpp @@ -188,33 +188,28 @@ lolunit_declare_fixture(ArrayTest) lolunit_assert_equal(7, a[2]); lolunit_assert_equal(2, a[3]); lolunit_assert_equal(6, a[4]); + } - /* - array b; - b.Insert(0, 5, 6, 7); + lolunit_declare_test(ArrayInsertTuple) + { + array b; + b.Insert(0, 5, 6.f, "lol"); lolunit_assert_equal(5, b[0].m1); - lolunit_assert_equal(6, b[0].m2); - lolunit_assert_equal(7, b[0].m3); + lolunit_assert_equal(6.f, b[0].m2); - b.Insert(1, 8, 9, 6); + b.Insert(1, 8, 9.f, "hi there"); lolunit_assert_equal(5, b[0].m1); - lolunit_assert_equal(6, b[0].m2); - lolunit_assert_equal(7, b[0].m3); + lolunit_assert_equal(6.f, b[0].m2); lolunit_assert_equal(8, b[1].m1); - lolunit_assert_equal(9, b[1].m2); - lolunit_assert_equal(6, b[1].m3); + lolunit_assert_equal(9.f, b[1].m2); - b.Insert(1, 4, 5, 3); + b.Insert(1, 4, 5.f, "anyone home?"); lolunit_assert_equal(5, b[0].m1); - lolunit_assert_equal(6, b[0].m2); - lolunit_assert_equal(7, b[0].m3); - lolunit_assert_equal(4, b[2].m1); - lolunit_assert_equal(5, b[2].m2); - lolunit_assert_equal(3, b[2].m3); + lolunit_assert_equal(6.f, b[0].m2); + lolunit_assert_equal(4, b[1].m1); + lolunit_assert_equal(5.f, b[1].m2); lolunit_assert_equal(8, b[2].m1); - lolunit_assert_equal(9, b[2].m2); - lolunit_assert_equal(6, b[2].m3); - */ + lolunit_assert_equal(9.f, b[2].m2); } lolunit_declare_test(ArrayConcat)