@ -47,48 +47,44 @@ CompressIndicesTest::CompressIndicesTest() {
void CompressIndicesTest : : compressChar ( ) {
void CompressIndicesTest : : compressChar ( ) {
std : : size_t indexCount ;
std : : size_t indexCount ;
Mesh : : IndexType indexType ;
Mesh : : IndexType indexType ;
char * data ;
Containers : : Array < char > data ;
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : vector < UnsignedInt > { 1 , 2 , 3 , 0 , 4 } ) ;
std : : vector < UnsignedInt > { 1 , 2 , 3 , 0 , 4 } ) ;
CORRADE_COMPARE ( indexCount , 5 ) ;
CORRADE_COMPARE ( indexCount , 5 ) ;
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedByte ) ;
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedByte ) ;
CORRADE_COMPARE ( std : : vector < char > ( data , data + indexCount * Mesh : : indexSize ( indexType ) ) ,
CORRADE_COMPARE ( std : : vector < char > ( data . begin ( ) , data . end ( ) ) ,
( std : : vector < char > { 0x01 , 0x02 , 0x03 , 0x00 , 0x04 } ) ) ;
( std : : vector < char > { 0x01 , 0x02 , 0x03 , 0x00 , 0x04 } ) ) ;
delete [ ] data ;
}
}
void CompressIndicesTest : : compressShort ( ) {
void CompressIndicesTest : : compressShort ( ) {
std : : size_t indexCount ;
std : : size_t indexCount ;
Mesh : : IndexType indexType ;
Mesh : : IndexType indexType ;
char * data ;
Containers : : Array < char > data ;
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : vector < UnsignedInt > { 1 , 256 , 0 , 5 } ) ;
std : : vector < UnsignedInt > { 1 , 256 , 0 , 5 } ) ;
CORRADE_COMPARE ( indexCount , 4 ) ;
CORRADE_COMPARE ( indexCount , 4 ) ;
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedShort ) ;
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedShort ) ;
if ( ! Utility : : Endianness : : isBigEndian ( ) ) {
if ( ! Utility : : Endianness : : isBigEndian ( ) ) {
CORRADE_COMPARE ( std : : vector < char > ( data , data + indexCount * Mesh : : indexSize ( indexType ) ) ,
CORRADE_COMPARE ( std : : vector < char > ( data . begin ( ) , data . end ( ) ) ,
( std : : vector < char > { 0x01 , 0x00 ,
( std : : vector < char > { 0x01 , 0x00 ,
0x00 , 0x01 ,
0x00 , 0x01 ,
0x00 , 0x00 ,
0x00 , 0x00 ,
0x05 , 0x00 } ) ) ;
0x05 , 0x00 } ) ) ;
} else {
} else {
CORRADE_COMPARE ( std : : vector < char > ( data , data + indexCount * Mesh : : indexSize ( indexType ) ) ,
CORRADE_COMPARE ( std : : vector < char > ( data . begin ( ) , data . end ( ) ) ,
( std : : vector < char > { 0x00 , 0x01 ,
( std : : vector < char > { 0x00 , 0x01 ,
0x01 , 0x00 ,
0x01 , 0x00 ,
0x00 , 0x00 ,
0x00 , 0x00 ,
0x00 , 0x05 } ) ) ;
0x00 , 0x05 } ) ) ;
}
}
delete [ ] data ;
}
}
void CompressIndicesTest : : compressInt ( ) {
void CompressIndicesTest : : compressInt ( ) {
std : : size_t indexCount ;
std : : size_t indexCount ;
Mesh : : IndexType indexType ;
Mesh : : IndexType indexType ;
char * data ;
Containers : : Array < char > data ;
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : tie ( indexCount , indexType , data ) = MeshTools : : compressIndices (
std : : vector < UnsignedInt > { 65536 , 3 , 2 } ) ;
std : : vector < UnsignedInt > { 65536 , 3 , 2 } ) ;
@ -96,18 +92,16 @@ void CompressIndicesTest::compressInt() {
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedInt ) ;
CORRADE_VERIFY ( indexType = = Mesh : : IndexType : : UnsignedInt ) ;
if ( ! Utility : : Endianness : : isBigEndian ( ) ) {
if ( ! Utility : : Endianness : : isBigEndian ( ) ) {
CORRADE_COMPARE ( std : : vector < char > ( data , data + indexCount * Mesh : : indexSize ( indexType ) ) ,
CORRADE_COMPARE ( std : : vector < char > ( data . begin ( ) , data . end ( ) ) ,
( std : : vector < char > { 0x00 , 0x00 , 0x01 , 0x00 ,
( std : : vector < char > { 0x00 , 0x00 , 0x01 , 0x00 ,
0x03 , 0x00 , 0x00 , 0x00 ,
0x03 , 0x00 , 0x00 , 0x00 ,
0x02 , 0x00 , 0x00 , 0x00 } ) ) ;
0x02 , 0x00 , 0x00 , 0x00 } ) ) ;
} else {
} else {
CORRADE_COMPARE ( std : : vector < char > ( data , data + indexCount * Mesh : : indexSize ( indexType ) ) ,
CORRADE_COMPARE ( std : : vector < char > ( data . begin ( ) , data . end ( ) ) ,
( std : : vector < char > { 0x00 , 0x01 , 0x00 , 0x00 ,
( std : : vector < char > { 0x00 , 0x01 , 0x00 , 0x00 ,
0x00 , 0x00 , 0x00 , 0x03 ,
0x00 , 0x00 , 0x00 , 0x03 ,
0x00 , 0x00 , 0x00 , 0x02 } ) ) ;
0x00 , 0x00 , 0x00 , 0x02 } ) ) ;
}
}
delete [ ] data ;
}
}
} } }
} } }