throw 0; _var = new int(0); } ~T1(){ delete _var; } }; const T1 OriginalArray[15]; const T1 SecondArray[3]; TEST_CASE("Array of custom type should remain same if inserted in the middle with safe", "[Array][SpliceSafe]") { T1CallsToException = ~0; Array<T1> instance(OriginalArray, 15); int capacity = instance.Capacity(); int size = instance.Size(); try{ T1CallsToException = 1; instance.SpliceSafe(10, 0, SecondArray, 1); REQUIRE(false); } catch(...){ REQUIRE(true); } REQUIRE(instance.Size() == size); REQUIRE(instance.Capacity() == capacity); } TEST_CASE("Array of custom type should remain same if inserted in the end with safe", "[Array][SpliceSafe]") {
#define CATCH_CONFIG_MAIN #include "../../libs/catch.h" #include "../../Templates.h" using namespace Templates; int array[] = {1, 3, 5, 7, 9}; TEST_CASE("Should create empty Array", "[Array][Creation]") { Array<int> instance; REQUIRE(instance.Capacity() > 0); REQUIRE(instance.IsEmpty()); } TEST_CASE("Should create Array with capacity", "[Array][Creation]"){ Array<int> instance(4); REQUIRE(instance.Capacity() == 4); REQUIRE(instance.IsEmpty()); } TEST_CASE("Should create Array with more capacity", "[Array][Creation]"){ Array<int> instance(25); REQUIRE(instance.Capacity() == 25); } TEST_CASE("Should create Array with negative capacity", "[Array][Creation]"){ Array<int> instance(-5); REQUIRE(instance.Capacity() > 0); } TEST_CASE("Should create Array with default capacity if zero capacity passed", "[Array][Creation]"){