Add move assignment operator for SeArray.

This commit is contained in:
hashlag committed 2026-10-17 21:47:25 +03:00
1 parent 8401612e20
commit 5c7cf222bd
2 files changed
+37 -1

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ public:
SeArray(SeArray && other) = delete; SeArray(SeArray && other) = delete;
SeArray & operator=(const SeArray & other) = default; SeArray & operator=(const SeArray & other) = default;
SeArray & operator=(SeArray && other) = delete; SeArray & operator=(SeArray && other) = default;
~SeArray() ~SeArray()
{ {
+36
View File
@@ -3,6 +3,7 @@
#include <cstdint> #include <cstdint>
#include <iterator> #include <iterator>
#include <cstddef> #include <cstddef>
#include <utility>
#include "Service/SeArray.hpp" #include "Service/SeArray.hpp"
@@ -290,3 +291,38 @@ TEST(SeArrayTests, CopyAssignTest)
ASSERT_EQ(0, arr1[4]); ASSERT_EQ(0, arr1[4]);
} }
} }
TEST(SeArrayTests, MoveAssignTest)
{
{
SeArray<uint8_t, 2> arr1;
SeArray<uint8_t, 2> arr2;
arr2[0] = 0xaa;
arr2[1] = 0xbb;
arr1 = std::move(arr2);
ASSERT_EQ(0xaa, arr1[0]);
ASSERT_EQ(0xbb, arr1[1]);
}
{
SeArray<int32_t, 5> arr1;
arr1[0] = 0x33;
arr1[1] = 0x44;
arr1[2] = 0x55;
arr1[3] = 0x66;
arr1[4] = 0x77;
SeArray<int32_t, 5> arr2;
arr1 = std::move(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]);
}
}