本文整理汇总了C++中DynamicArray::getLength方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::getLength方法的具体用法?C++ DynamicArray::getLength怎么用?C++ DynamicArray::getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::getLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST( DynamicArray, equalOperator ){
DynamicArray<string> arrayEqOp = testArrayOne;
EXPECT_EQ( testArrayOne.getLength(), arrayEqOp.getLength() );
for( int i = 0; i < testArrayOne.getLength(); ++i ){
EXPECT_TRUE( testArrayOne[i] == arrayEqOp[i] );
}
}
示例2: arrayPushFront
TEST( DynamicArray, pushFront ){
DynamicArray<string> arrayPushFront( &testAlloc );
for(size_t i = 0; i < testArrayOne.getLength(); ++i){
arrayPushFront.pushFront( testArrayOne[i] );
EXPECT_EQ( testArrayOne[i], arrayPushFront[0] );
}
EXPECT_EQ( testArrayOne.getLength(), arrayPushFront.getLength() );
}
示例3: arrayInsertAt
TEST( DynamicArray, insertAt ){
DynamicArray<string> arrayInsertAt(&testAlloc);
string temp = "hello";
for ( int i = 0; i < 5; ++i )
{
arrayInsertAt.push(temp);
}
for( size_t i = 0; i < testArrayOne.getLength(); ++i){
arrayInsertAt.insertAt( i + 2, testArrayOne[i] );
}
EXPECT_EQ( arrayInsertAt.getLength(), 1005 );
for( size_t i = 0; i < testArrayOne.getLength(); ++i ){
EXPECT_EQ(arrayInsertAt[i + 2], testArrayOne[i]);
}
}
示例4: pointerArray
TEST(DynamicArray, pointerArray){
StevensDev::sgdm::DefaultAllocator<string*> strPtrAlloc;
DynamicArray<string*> pointerArray(&strPtrAlloc);
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string(i) );
pointerArray.push( strPtr );
EXPECT_EQ( *(pointerArray[i]), *strPtr );
delete strPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string(i) );
string* frontPtr = pointerArray.popFront();
EXPECT_EQ( *strPtr, *frontPtr );
delete strPtr;
delete frontPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
pointerArray.pushFront(strPtr);
EXPECT_EQ( *(pointerArray[0]), *strPtr );
delete strPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
string* frontPtr = pointerArray.pop();
EXPECT_EQ(*strPtr, *frontPtr);
delete strPtr;
delete frontPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
pointerArray.push( strPtr);
delete strPtr;
}
string* temp = pointerArray.removeAt( 20 );
EXPECT_EQ( "20", *temp );
EXPECT_EQ( 99, pointerArray.getLength() );
delete temp;
string* tempToInsert = new string( "hello, world" );
pointerArray.insertAt( 30, tempToInsert );
EXPECT_EQ( *tempToInsert, *(pointerArray[30]) );
delete tempToInsert;
DynamicArray<string*> cpArray = pointerArray;
for(size_t i = 0; i < pointerArray.getLength(); ++i)
EXPECT_EQ( *(cpArray[i]), *(pointerArray[i]) );
cpArray.clear();
EXPECT_EQ( 0, cpArray.getLength() );
}