summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/core/variant/test_array.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/core/variant/test_array.h b/tests/core/variant/test_array.h
index 04d5bb5107..ccb02ed5fa 100644
--- a/tests/core/variant/test_array.h
+++ b/tests/core/variant/test_array.h
@@ -253,6 +253,7 @@ TEST_CASE("[Array] slice()") {
array.push_back(2);
array.push_back(3);
array.push_back(4);
+ array.push_back(5);
Array slice0 = array.slice(0, 0);
CHECK(slice0.size() == 0);
@@ -263,42 +264,52 @@ TEST_CASE("[Array] slice()") {
CHECK(slice1[1] == Variant(2));
Array slice2 = array.slice(1, -1);
- CHECK(slice2.size() == 3);
+ CHECK(slice2.size() == 4);
CHECK(slice2[0] == Variant(1));
CHECK(slice2[1] == Variant(2));
CHECK(slice2[2] == Variant(3));
+ CHECK(slice2[3] == Variant(4));
Array slice3 = array.slice(3);
- CHECK(slice3.size() == 2);
+ CHECK(slice3.size() == 3);
CHECK(slice3[0] == Variant(3));
CHECK(slice3[1] == Variant(4));
+ CHECK(slice3[2] == Variant(5));
Array slice4 = array.slice(2, -2);
- CHECK(slice4.size() == 1);
+ CHECK(slice4.size() == 2);
CHECK(slice4[0] == Variant(2));
+ CHECK(slice4[1] == Variant(3));
Array slice5 = array.slice(-2);
CHECK(slice5.size() == 2);
- CHECK(slice5[0] == Variant(3));
- CHECK(slice5[1] == Variant(4));
+ CHECK(slice5[0] == Variant(4));
+ CHECK(slice5[1] == Variant(5));
Array slice6 = array.slice(2, 42);
- CHECK(slice6.size() == 3);
+ CHECK(slice6.size() == 4);
CHECK(slice6[0] == Variant(2));
CHECK(slice6[1] == Variant(3));
CHECK(slice6[2] == Variant(4));
+ CHECK(slice6[3] == Variant(5));
Array slice7 = array.slice(4, 0, -2);
CHECK(slice7.size() == 2);
CHECK(slice7[0] == Variant(4));
CHECK(slice7[1] == Variant(2));
- ERR_PRINT_OFF;
- Array slice8 = array.slice(4, 1);
- CHECK(slice8.size() == 0);
+ Array slice8 = array.slice(5, 0, -2);
+ CHECK(slice8.size() == 3);
+ CHECK(slice8[0] == Variant(5));
+ CHECK(slice8[1] == Variant(3));
+ CHECK(slice8[2] == Variant(1));
- Array slice9 = array.slice(3, -4);
+ ERR_PRINT_OFF;
+ Array slice9 = array.slice(4, 1);
CHECK(slice9.size() == 0);
+
+ Array slice10 = array.slice(3, -4);
+ CHECK(slice10.size() == 0);
ERR_PRINT_ON;
}