diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-12-07 14:00:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-07 14:00:59 +0100 |
commit | 46d384060ef20672e23b3c1ffe947ff7898ecf75 (patch) | |
tree | 3d93fe69a70c24618074e4eb329eff4bf0fd8aca /tests/core/variant | |
parent | a33b85c122fd18534ce556ae02bc87c36817a5b3 (diff) | |
parent | dd30253cdcf9b43e401cb3ba6b973f8890551a81 (diff) |
Merge pull request #35901 from nathanfranke/pool-byte-array-subarray-exclusive
Diffstat (limited to 'tests/core/variant')
-rw-r--r-- | tests/core/variant/test_array.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/core/variant/test_array.h b/tests/core/variant/test_array.h index e2e84f2962..d02b3d0e39 100644 --- a/tests/core/variant/test_array.h +++ b/tests/core/variant/test_array.h @@ -246,6 +246,37 @@ TEST_CASE("[Array] max() and min()") { CHECK(min == 2); } +TEST_CASE("[Array] slice()") { + Array array; + array.push_back(0); + array.push_back(1); + array.push_back(2); + array.push_back(3); + array.push_back(4); + + Array slice1 = array.slice(1, 3); + CHECK(slice1.size() == 2); + CHECK(slice1[0] == Variant(1)); + CHECK(slice1[1] == Variant(2)); + + Array slice2 = array.slice(1, -1); + 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, -1); + CHECK(slice3.size() == 2); + CHECK(slice3[0] == Variant(3)); + CHECK(slice3[1] == Variant(4)); + + Array slice4 = array.slice(2, -2); + CHECK(slice4.size() == 2); + CHECK(slice4[0] == Variant(2)); + CHECK(slice4[1] == Variant(3)); +} + TEST_CASE("[Array] Duplicate array") { // a = [1, [2, 2], {3: 3}] Array a = build_array(1, build_array(2, 2), build_dictionary(3, 3)); |