Example #1
0
TEST_F( TArrayTest, resizeTest ) {
    TArray<float> arrayInstance;
	EXPECT_EQ( 0, arrayInstance.size() );

	arrayInstance.resize( 5 );
	EXPECT_EQ( 5, arrayInstance.size() );
}
Example #2
0
TEST_F( TArrayTest, resize_with_init_Test ) {
    TArray<float> arrayInstance;
    EXPECT_EQ( 0, arrayInstance.capacity() );

    arrayInstance.resize( 10, 1.0f );
    EXPECT_EQ( 10, arrayInstance.size() );
    for ( size_t i = 0; i < 10; i++ ) {
        EXPECT_FLOAT_EQ( 1.0f, arrayInstance[ i ] );
    }
}
Example #3
0
// will load an entire file into the stringstream str. Returns false if failed.
bool LoadFileIntoMemory( TArray<char> &pFileContent,
        std::string const &FileName, uint *pFileLength )
{
    // read the entire file into an stringstream object.
    std::ifstream
        File( FileName.c_str() );
    std::size_t
        FileLength;
    if ( false == File.good() )
        return false;
    File.seekg( 0, std::ios::end );
    FileLength = File.tellg();
    if ( 0 != pFileLength )
        *pFileLength = FileLength;
    pFileContent.resize(2 + FileLength);
    memset( &pFileContent[0], 0, 2 + FileLength );
    File.seekg( 0, std::ios::beg );
    File.read( &pFileContent[0], FileLength );
    return true;
};