本文整理汇总了C++中Array::Capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::Capacity方法的具体用法?C++ Array::Capacity怎么用?C++ Array::Capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::Capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
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]") {
示例2: REQUIRE
#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]"){