Browse Source

Test invalid index

Kajetan Johannes Hammerle 2 months ago
parent
commit
62fb3363c9
1 changed files with 6 additions and 0 deletions
  1. 6 0
      test/modules/ArrayListTests.cpp

+ 6 - 0
test/modules/ArrayListTests.cpp

@@ -136,6 +136,12 @@ static void testRemove() {
     CORE_TEST_EQUAL(2, list[0]);
     CORE_TEST_EQUAL(3, list[1]);
     CORE_TEST_EQUAL(2, list.getLength());
+    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(4));
+    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(-1));
+    CORE_TEST_EQUAL(Core::Error::INVALID_INDEX, list.removeBySwap(-5));
+    CORE_TEST_EQUAL(2, list[0]);
+    CORE_TEST_EQUAL(3, list[1]);
+    CORE_TEST_EQUAL(2, list.getLength());
     CORE_TEST_ERROR(list.removeBySwap(1));
     CORE_TEST_EQUAL(2, list[0]);
     CORE_TEST_EQUAL(1, list.getLength());