@ -66,6 +66,8 @@ struct MatrixTest: TestSuite::Tester {
void constructNoInit ( ) ;
void constructOneValue ( ) ;
void constructOneComponent ( ) ;
void constructArray ( ) ;
void constructArrayRvalue ( ) ;
void constructConversion ( ) ;
void constructFromDifferentSize ( ) ;
void constructCopy ( ) ;
@ -110,6 +112,8 @@ MatrixTest::MatrixTest() {
& MatrixTest : : constructNoInit ,
& MatrixTest : : constructOneValue ,
& MatrixTest : : constructOneComponent ,
& MatrixTest : : constructArray ,
& MatrixTest : : constructArrayRvalue ,
& MatrixTest : : constructConversion ,
& MatrixTest : : constructFromDifferentSize ,
& MatrixTest : : constructCopy ,
@ -237,6 +241,110 @@ void MatrixTest::constructOneComponent() {
CORRADE_VERIFY ( std : : is_nothrow_constructible < Matrix1x1 , Vector1 > : : value ) ;
}
void MatrixTest : : constructArray ( ) {
float data [ 4 ] [ 4 ] {
{ 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f }
} ;
Matrix4x4 a { data } ;
CORRADE_COMPARE ( a , ( Matrix4x4 { Vector4 { 3.0f , 5.0f , 8.0f , - 3.0f } ,
Vector4 { 4.5f , 4.0f , 7.0f , 2.0f } ,
Vector4 { 1.0f , 2.0f , 3.0f , - 1.0f } ,
Vector4 { 7.9f , - 1.0f , 8.0f , - 1.5f } } ) ) ;
constexpr float cdata [ 4 ] [ 4 ] {
{ 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f }
} ;
constexpr Matrix4x4 ca { cdata } ;
CORRADE_COMPARE ( ca , ( Matrix4x4 { Vector4 { 3.0f , 5.0f , 8.0f , - 3.0f } ,
Vector4 { 4.5f , 4.0f , 7.0f , 2.0f } ,
Vector4 { 1.0f , 2.0f , 3.0f , - 1.0f } ,
Vector4 { 7.9f , - 1.0f , 8.0f , - 1.5f } } ) ) ;
/* Implicit conversion is not allowed */
CORRADE_VERIFY ( ! std : : is_convertible < float [ 4 ] [ 4 ] , Matrix4x4 > : : value ) ;
CORRADE_VERIFY ( std : : is_nothrow_constructible < Matrix4x4 , float [ 4 ] [ 4 ] > : : value ) ;
/* See RectangularMatrixTest::constructArray() for details */
#if 0
float data43 [ 4 ] [ 3 ] {
{ 3.0f , 5.0f , 8.0f } ,
{ 4.5f , 4.0f , 7.0f } ,
{ 1.0f , 2.0f , 3.0f } ,
{ 7.9f , - 1.0f , 8.0f }
} ;
float data45 [ 4 ] [ 5 ] {
{ 3.0f , 5.0f , 8.0f , - 3.0f , 0.3f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f , 0.3f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f , 0.3f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f , 0.3f }
} ;
float data14 [ 1 ] [ 4 ] {
{ 3.0f , 5.0f , 8.0f , - 3.0f } ,
} ;
float data54 [ 5 ] [ 4 ] {
{ 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 3.0f , 7.0f , 0.0f , 1.0f }
} ;
Matrix4x4 b { data43 } ;
Matrix4x4 c { data45 } ;
Matrix4x4 d { data14 } ;
Matrix4x4 e { data54 } ;
# endif
}
void MatrixTest : : constructArrayRvalue ( ) {
/* This, the extra {} to supply an array, avoids the need to have to
explicitly type out Vector for every column */
Matrix4x4 a { { { 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f } } } ;
CORRADE_COMPARE ( a , ( Matrix4x4 { Vector4 { 3.0f , 5.0f , 8.0f , - 3.0f } ,
Vector4 { 4.5f , 4.0f , 7.0f , 2.0f } ,
Vector4 { 1.0f , 2.0f , 3.0f , - 1.0f } ,
Vector4 { 7.9f , - 1.0f , 8.0f , - 1.5f } } ) ) ;
constexpr Matrix4x4 ca { { { 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f } } } ;
CORRADE_COMPARE ( ca , ( Matrix4x4 { Vector4 { 3.0f , 5.0f , 8.0f , - 3.0f } ,
Vector4 { 4.5f , 4.0f , 7.0f , 2.0f } ,
Vector4 { 1.0f , 2.0f , 3.0f , - 1.0f } ,
Vector4 { 7.9f , - 1.0f , 8.0f , - 1.5f } } ) ) ;
/* See RectangularMatrixTest::constructArrayRvalue() for details */
#if 0
Matrix4x4 c { { { 3.0f , 5.0f , 8.0f , - 3.0f , 0.3f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f , 0.3f } ,
{ 1.0f , 2.0f , 3.0f , - 1.0f , 0.3f } ,
{ 7.9f , - 1.0f , 8.0f , - 1.5f , 0.3f } } } ;
Matrix4x4 e { { { 3.0f , 5.0f , 8.0f , - 3.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 4.5f , 4.0f , 7.0f , 2.0f } ,
{ 3.0f , 7.0f , 0.0f , 1.0f } } } ;
# endif
#if 0 || (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ < 5)
CORRADE_WARN ( " Creating a Matrix from a smaller array isn't an error on GCC 4.8. " ) ;
Matrix4x4 b { { { 3.0f , 5.0f , 8.0f } ,
{ 4.5f , 4.0f , 7.0f } ,
{ 1.0f , 2.0f , 3.0f } ,
{ 7.9f , - 1.0f , 8.0f } } } ;
Matrix4x4 d { { { 3.0f , 5.0f , 8.0f , - 3.0f } } } ;
# endif
}
void MatrixTest : : constructConversion ( ) {
constexpr Matrix4x4 a ( Vector4 ( 3.0f , 5.0f , 8.0f , - 3.0f ) ,
Vector4 ( 4.5f , 4.0f , 7.0f , 2.0f ) ,