add constructor for array with iterators or pointers

This commit is contained in:
ohyzha
2024-12-19 13:27:10 +02:00
parent 2334d48856
commit b3ba4509d7
2 changed files with 36 additions and 0 deletions

View File

@@ -237,4 +237,26 @@ TEST_CASE("Swap method", "[Array]")
arr1.Swap(arr2);
REQUIRE(arr1[0] == 4);
REQUIRE(arr2[0] == 1);
}
TEST_CASE("Iterator constructor", "[Array]")
{
{
char data[] = "Hello world";
Array<char> arr(data, data + sizeof(data));
REQUIRE(arr.Data() != data);
for (int i = 0; i < sizeof(data); i++)
{
REQUIRE(data[i] == arr[i]);
}
}
{
Array<int> arr = { 1, 2, 3, 4, 5 };
Array<double> arr2(arr.begin(), arr.end());
for (int i = 0; i < arr.Size(); i++)
{
REQUIRE(arr[i] == arr2[i]);
}
}
}