Skip to content

Commit 500a224

Browse files
committed
Merge pull request #105428 from mason1920/array-insert-test
Test for insertion at array's size
2 parents 485406b + 692a244 commit 500a224

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/core/variant/test_array.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ TEST_CASE("[Array] resize(), insert(), and erase()") {
126126
CHECK(int(arr[0]) == 2);
127127
arr.erase(2);
128128
CHECK(int(arr[0]) == 1);
129-
130-
// Negative index on insert.
131-
CHECK(arr.size() == 3);
129+
arr.resize(0);
130+
CHECK(arr.size() == 0);
131+
arr.insert(0, 8);
132+
CHECK(arr.size() == 1);
133+
arr.insert(1, 16);
134+
CHECK(int(arr[1]) == 16);
132135
arr.insert(-1, 3);
133-
CHECK(int(arr[2]) == 3);
134-
CHECK(arr.size() == 4);
136+
CHECK(int(arr[1]) == 3);
135137
}
136138

137139
TEST_CASE("[Array] front() and back()") {

0 commit comments

Comments
 (0)