From 32a1b30ae85e6665c8241aedf0ea42f4eafc9bf6 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sun, 19 Oct 2025 00:20:44 -0500 Subject: [PATCH] feat(array): add TSFixedArray copy ctor --- storm/array/TSFixedArray.hpp | 7 +++++++ test/Array.cpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/storm/array/TSFixedArray.hpp b/storm/array/TSFixedArray.hpp index 37b8a7d..dd0c569 100644 --- a/storm/array/TSFixedArray.hpp +++ b/storm/array/TSFixedArray.hpp @@ -9,6 +9,7 @@ template class TSFixedArray : public TSBaseArray { public: TSFixedArray(); + TSFixedArray(const TSFixedArray& source); ~TSFixedArray(); TSFixedArray& operator=(const TSFixedArray& source); void Clear(); @@ -23,6 +24,12 @@ TSFixedArray::TSFixedArray() { this->Constructor(); } +template +TSFixedArray::TSFixedArray(const TSFixedArray& source) { + this->Constructor(); + this->Set(source.Count(), source.Ptr()); +} + template TSFixedArray::~TSFixedArray() { for (uint32_t i = 0; i < this->Count(); i++) { diff --git a/test/Array.cpp b/test/Array.cpp index 9a086c9..2106b90 100644 --- a/test/Array.cpp +++ b/test/Array.cpp @@ -33,6 +33,21 @@ TEST_CASE("TSFixedArray", "[array]") { REQUIRE(array.Count() == 0); REQUIRE(array.Ptr() == nullptr); } + + SECTION("constructs copy correctly") { + TSFixedArray array; + array.SetCount(3); + array[0] = 1; + array[1] = 2; + array[2] = 3; + + TSFixedArray arrayCopy(array); + + CHECK(arrayCopy.Count() == 3); + CHECK(arrayCopy[0] == 1); + CHECK(arrayCopy[1] == 2); + CHECK(arrayCopy[2] == 3); + } } TEST_CASE("TSFixedArray::Clear", "[array]") {