ChaiScript/unittests/vector_erase_at.chai
2021-07-08 18:55:36 +02:00

25 lines
430 B
ChaiScript

auto x = [1, 2, 3]
x.erase_at(1)
assert_equal([1,3], x);
try {
// We expect this to throw because of erasing an out of bounds index
x.erase_at(2)
assert_true(false)
} catch (e) {
assert_true(true)
}
try {
// We expect this to throw because of erasing an out of bounds index
x.erase_at(-1)
assert_true(false)
} catch (e) {
assert_true(true)
}
x.erase_at(0)
assert_equal([3], x)
x.erase_at(0)
assert_equal([], x)