From 78ab3a8c27f3e18b9d21984e196de7a3815f71a5 Mon Sep 17 00:00:00 2001 From: hashlag Date: Sun, 26 Jul 2026 18:55:28 +0300 Subject: [PATCH] Add copy assignment operator for SeArray. --- Chaos/Service/SeArray.hpp | 2 +- ChaosTests/Service/SeArrayTests.cpp | 35 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Chaos/Service/SeArray.hpp b/Chaos/Service/SeArray.hpp index 986e04e..24c7875 100644 --- a/Chaos/Service/SeArray.hpp +++ b/Chaos/Service/SeArray.hpp @@ -21,7 +21,7 @@ public: SeArray(const SeArray & other) = delete; SeArray(SeArray && other) = delete; - SeArray & operator=(const SeArray & other) = delete; + SeArray & operator=(const SeArray & other) = default; SeArray & operator=(SeArray && other) = delete; ~SeArray() diff --git a/ChaosTests/Service/SeArrayTests.cpp b/ChaosTests/Service/SeArrayTests.cpp index 9c703e0..cd5400c 100644 --- a/ChaosTests/Service/SeArrayTests.cpp +++ b/ChaosTests/Service/SeArrayTests.cpp @@ -254,3 +254,38 @@ TEST(SeArrayTests, FillTest) ASSERT_EQ(-3, arr[i]); } } + +TEST(SeArrayTests, CopyAssignTest) +{ + { + SeArray arr1; + + SeArray arr2; + arr2[0] = 0xaa; + arr2[1] = 0xbb; + + arr1 = arr2; + + ASSERT_EQ(0xaa, arr1[0]); + ASSERT_EQ(0xbb, arr1[1]); + } + + { + SeArray arr1; + arr1[0] = 0x33; + arr1[1] = 0x44; + arr1[2] = 0x55; + arr1[3] = 0x66; + arr1[4] = 0x77; + + SeArray arr2; + + arr1 = arr2; + + ASSERT_EQ(0, arr1[0]); + ASSERT_EQ(0, arr1[1]); + ASSERT_EQ(0, arr1[2]); + ASSERT_EQ(0, arr1[3]); + ASSERT_EQ(0, arr1[4]); + } +}