-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
#include <iostream>
#include <sstream>
#include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
#include <dali-test-suite-utils.h>
using namespace Dali;
}
-int UtcDaliMatrixCtor(void)
+int UtcDaliMatrixConstructor01P(void)
{
- // Test initialized startup
- Matrix m1;
-
- float r1[] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
- float r2[] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
- Matrix mr1(r1);
- Matrix mr2(r2);
-
- DALI_TEST_EQUALS(m1, mr1, 0.001f, TEST_LOCATION);
+ Matrix m2(false);
- // Test uninitialized startup
- // Stack construct a matrix to non zero, then stack construct another matrix over the top of it.
- float r3[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ bool initialised = true;
{
- Matrix m3(r3);
- }
- {
- Matrix m2(false);
-
- bool initialised = true;
+ float* els = m2.AsFloat();
+ for(size_t idx=0; idx<16; ++idx, ++els)
{
- float* els = m2.AsFloat();
- for(size_t idx=0; idx<16; ++idx, ++els)
- {
- if(*els != 0.0f)
- initialised = false;
- }
+ if(*els != 0.0f)
+ initialised = false;
}
-
- DALI_TEST_EQUALS(initialised, false, TEST_LOCATION);
}
- Matrix m4(true);
- DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION);
-
- m4 = m4;
- DALI_TEST_EQUALS(m4, mr1, 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(initialised, false, TEST_LOCATION);
- Matrix m5(false);
- m5.SetIdentity();
- Matrix m6 = m5;
- DALI_TEST_EQUALS(m6, mr2, 0.001f, TEST_LOCATION);
END_TEST;
}
-// OrthoNormalise fixes floating point errors from matrix rotations
-int UtcDaliMatrixOrthoNormalize0(void)
+int UtcDaliMatrixConstructor02P(void)
{
- Matrix m;
- m.SetIdentity();
+ float r[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ Matrix m(r);
- for (int i=0;i<1000;++i)
+ float* els = m.AsFloat();
+ float* init = r;
+ bool initialised = true;
+ for(size_t idx=0; idx<16; ++idx, ++els, ++init)
{
- float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
- axis.Normalize();
-
- m.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), Vector3::ZERO );
- m.OrthoNormalize();
+ if(*els != *init)
+ initialised = false;
}
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
- bool success = true;
- success &= fabsf(m.GetXAxis().Dot(m.GetYAxis())) < 0.001f;
- success &= fabsf(m.GetYAxis().Dot(m.GetXAxis())) < 0.001f;
- success &= fabsf(m.GetZAxis().Dot(m.GetYAxis())) < 0.001f;
-
- success &= fabsf(m.GetXAxis().Length() - 1.0f) < 0.001f;
- success &= fabsf(m.GetYAxis().Length() - 1.0f) < 0.001f;
- success &= fabsf(m.GetZAxis().Length() - 1.0f) < 0.001f;
-
- DALI_TEST_CHECK(success);
END_TEST;
}
-// OrthoNormalize is not flipping the axes and is maintaining the translation
-int UtcDaliMatrixOrthoNormalize1(void)
+int UtcDaliMatrixConstructor03P(void)
{
- for (int i=0;i<1000;++i)
- {
- float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
- axis.Normalize();
- Vector3 center(10.0f, 15.0f, 5.0f);
-
- Matrix m0;
- m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
+ float r[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
- Matrix m1(m0);
- m1.OrthoNormalize();
+ Matrix ma(r);
+ Matrix mb(ma);
- DALI_TEST_EQUALS(m0.GetXAxis(), m1.GetXAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetYAxis(), m1.GetYAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetZAxis(), m1.GetZAxis(), 0.001f, TEST_LOCATION);
- DALI_TEST_EQUALS(m0.GetTranslation(), m1.GetTranslation(), 0.001f, TEST_LOCATION);
+ float* els = ma.AsFloat();
+ float* init = mb.AsFloat();
+ bool initialised = true;
+ for(size_t idx=0; idx<16; ++idx, ++els, ++init)
+ {
+ if(*els != *init)
+ initialised = false;
}
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
+
END_TEST;
}
-// Invert works
-int UtcDaliMatrixInvert01(void)
+int UtcDaliMatrixConstructor04P(void)
{
- // We're going to invert a whole load of different matrices to make sure we don't
- // fail on particular orientations.
- for (int i=0;i<1000;++i)
- {
- float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
- axis.Normalize();
- Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
-
- Matrix m0;
- m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
-
- Matrix m1(m0);
- m1.Invert();
-
- Matrix m2( false );
- Matrix::Multiply( m2, m0, m1 );
+ Quaternion q(Quaternion::IDENTITY);
+ Matrix m(q);
+ DALI_TEST_EQUALS(Matrix(Matrix::IDENTITY), m, 0.001, TEST_LOCATION);
+ END_TEST;
+}
- DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+int UtcDaliMatrixAssignP(void)
+{
+ Matrix a(Matrix::IDENTITY);
+ Matrix b = a;
+ DALI_TEST_EQUALS(a, b, 0.001, TEST_LOCATION);
+ END_TEST;
+}
- m1.Invert(); // doube invert - should be back to m0
+int UtcDaliMatrixSetIdentityP(void)
+{
+ float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f,
+ 8.0f, 9.0f, 10.0f, 11.0f,
+ 12.0f, 13.0f, 14.0f, 15.0f };
+ Matrix m(els);
+ m.SetIdentity();
- DALI_TEST_EQUALS(m0, m1, 0.001f, TEST_LOCATION);
- }
+ DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
END_TEST;
}
-
-int UtcDaliMatrixInvert02(void)
+int UtcDaliMatrixSetIdentityAndScaleP(void)
{
- Matrix m1 = Matrix::IDENTITY;
- m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f));
- DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION);
+ float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f,
+ 8.0f, 9.0f, 10.0f, 11.0f,
+ 12.0f, 13.0f, 14.0f, 15.0f };
+ Matrix m(els);
+ m.SetIdentityAndScale(Vector3(4.0f, 4.0f, 4.0f));
+
+ float els2[] = { 4.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 4.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 4.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f };
+ Matrix r(els2);
+
+ DALI_TEST_EQUALS(m, r, 0.001f, TEST_LOCATION);
END_TEST;
}
-
-// Invert transform works
-int UtcDaliMatrixInvertTransform01(void)
+int UtcDaliMatrixInvertTransform01P(void)
{
for (int i=0;i<1000;++i)
{
float f = i;
- Vector4 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f), 0.0f);
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
axis.Normalize();
Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
Matrix m0;
m0.SetIdentity();
- m0.SetTransformComponents( Vector3::ONE, Quaternion(1.0f, axis), center );
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
Matrix m1;
m0.InvertTransform(m1);
END_TEST;
}
-
-// Invert transform works
-int UtcDaliMatrixInvertTransform02(void)
+int UtcDaliMatrixInvertTransform02P(void)
{
std::string exceptionString( "EqualsZero( mMatrix[3] ) && EqualsZero( mMatrix[7] ) && EqualsZero( mMatrix[11] ) && Equals( mMatrix[15], 1.0f" );
try
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
}
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
}
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
}
}
catch (Dali::DaliException& e)
{
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
+ DALI_TEST_PRINT_ASSERT( e );
DALI_TEST_ASSERT( e, exceptionString, TEST_LOCATION );
}
END_TEST;
}
-
-// GetXAxis
-int UtcDaliMatrixGetXAxis(void)
+int UtcDaliMatrixInvert01P(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ // We're going to invert a whole load of different matrices to make sure we don't
+ // fail on particular orientations.
+ for (int i=0;i<1000;++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
+ axis.Normalize();
+ Vector3 center(f, cosf(f) * 100.0f, cosf(f*0.5f) * 50.0f);
- DALI_TEST_CHECK(m.GetXAxis() == Vector3(0.0f, 1.0f, 2.0f));
- END_TEST;
-}
+ Matrix m0;
+ m0.SetIdentity();
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
-// GetYAxis
-int UtcDaliMatrixGetYAxis(void)
-{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ Matrix m1(m0);
+ m1.Invert();
- DALI_TEST_CHECK(m.GetYAxis() == Vector3(4.0f, 5.0f, 6.0f));
+ Matrix m2( false );
+ Matrix::Multiply( m2, m0, m1 );
+
+ DALI_TEST_EQUALS(m2, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+
+ m1.Invert(); // doube invert - should be back to m0
+
+ DALI_TEST_EQUALS(m0, m1, 0.001f, TEST_LOCATION);
+ }
END_TEST;
}
-// GetZAxis
-int UtcDaliMatrixGetZAxis(void)
+int UtcDaliMatrixInvert02P(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
-
- DALI_TEST_CHECK(m.GetZAxis() == Vector3(8.0f, 9.0f, 10.0f));
+ Matrix m1 = Matrix::IDENTITY;
+ m1.SetXAxis(Vector3(0.0f, 0.0f, 0.0f));
+ DALI_TEST_EQUALS(m1.Invert(), false, TEST_LOCATION);
END_TEST;
}
-// GetTranslation
-int UtcDaliMatrixGetTranslation(void)
+int UtcDaliMatrixTransposeP(void)
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f };
- Matrix m(els);
+ float floats[] =
+ { 0.0f, 1.0f, 2.0f, 3.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f,
+ 8.0f, 9.0f, 10.0f, 11.0f,
+ 12.0f, 13.0f, 14.0f, 15.0f
+ };
- DALI_TEST_EQUALS(m.GetTranslation(), Vector4(12.0f, 13.0f, 14.0f, 15.0f), TEST_LOCATION);
+ Matrix m(floats);
+ m.Transpose();
+
+ bool success = true;
+
+ for (int x=0;x<4;++x)
+ {
+ for (int y=0;y<4;++y)
+ {
+ success &= (m.AsFloat()[x+y*4] == floats[x*4+y]);
+ }
+ }
+
+ DALI_TEST_CHECK(success);
END_TEST;
}
-// GetTranslation
-int UtcDaliMatrixGetTranslation3(void)
+int UtcDaliMatrixGetXAxisP(void)
{
float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f, 7.0f,
12.0f, 13.0f, 14.0f, 15.0f };
Matrix m(els);
- DALI_TEST_EQUALS(m.GetTranslation3(), Vector3(12.0f, 13.0f, 14.0f), TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetXAxis() == Vector3(0.0f, 1.0f, 2.0f));
END_TEST;
}
-// SetIdentity
-int UtcDaliMatrixSetIdentity(void)
+int UtcDaliMatrixGetYAxisP(void)
{
float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f, 7.0f,
8.0f, 9.0f, 10.0f, 11.0f,
12.0f, 13.0f, 14.0f, 15.0f };
Matrix m(els);
- m.SetIdentity();
- DALI_TEST_EQUALS(m, Matrix::IDENTITY, 0.001f, TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetYAxis() == Vector3(4.0f, 5.0f, 6.0f));
END_TEST;
}
-
-int UtcDaliMatrixSetIdentityAndScale(void)
+int UtcDaliMatrixGetZAxisP(void)
{
float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f, 7.0f,
8.0f, 9.0f, 10.0f, 11.0f,
12.0f, 13.0f, 14.0f, 15.0f };
Matrix m(els);
- m.SetIdentityAndScale(Vector3(4.0f, 4.0f, 4.0f));
-
- float els2[] = { 4.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 4.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 4.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f };
- Matrix r(els2);
- DALI_TEST_EQUALS(m, r, 0.001f, TEST_LOCATION);
+ DALI_TEST_CHECK(m.GetZAxis() == Vector3(8.0f, 9.0f, 10.0f));
END_TEST;
}
-
-// SetXAxis
-int UtcDaliMatrixSetXAxis(void)
+int UtcDaliMatrixSetXAxisP(void)
{
Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
END_TEST;
}
-// SetYAxis
-int UtcDaliMatrixSetYAxis(void)
+int UtcDaliMatrixSetYAxisP(void)
{
Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
END_TEST;
}
-// SetZAxis
-int UtcDaliMatrixSetZAxis(void)
+int UtcDaliMatrixSetZAxisP(void)
{
Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
END_TEST;
}
-// SetTranslation
-int UtcDaliMatrixSetTranslation(void)
+int UtcDaliMatrixGetTranslationP(void)
+{
+ float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f,
+ 8.0f, 9.0f, 10.0f, 11.0f,
+ 12.0f, 13.0f, 14.0f, 15.0f };
+ Matrix m(els);
+
+ DALI_TEST_EQUALS(m.GetTranslation(), Vector4(12.0f, 13.0f, 14.0f, 15.0f), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixGetTranslation3P(void)
+{
+ float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
+ 4.0f, 5.0f, 6.0f, 7.0f,
+ 8.0f, 9.0f, 10.0f, 11.0f,
+ 12.0f, 13.0f, 14.0f, 15.0f };
+ Matrix m(els);
+
+ DALI_TEST_EQUALS(m.GetTranslation3(), Vector3(12.0f, 13.0f, 14.0f), TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliMatrixSetTranslationP(void)
{
Matrix m;
Vector4 v(2.0f, 3.0f, 4.0f, 5.0f);
END_TEST;
}
-// SetTranslation
-int UtcDaliMatrixSetTranslation3(void)
+int UtcDaliMatrixSetTranslation3P(void)
{
Matrix m;
Vector3 v(2.0f, 3.0f, 4.0f);
END_TEST;
}
+int UtcDaliMatrixOrthoNormalize0P(void)
+{
+ // OrthoNormalise fixes floating point errors from matrix rotations
+ Matrix m;
+ m.SetIdentity();
+
+ for (int i=0;i<1000;++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
+ axis.Normalize();
+ m.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), Vector3::ZERO );
+ m.OrthoNormalize();
+ }
-// Transpose
-int UtcDaliMatrixTranspose(void)
+ bool success = true;
+ success &= fabsf(m.GetXAxis().Dot(m.GetYAxis())) < 0.001f;
+ success &= fabsf(m.GetYAxis().Dot(m.GetXAxis())) < 0.001f;
+ success &= fabsf(m.GetZAxis().Dot(m.GetYAxis())) < 0.001f;
+
+ success &= fabsf(m.GetXAxis().Length() - 1.0f) < 0.001f;
+ success &= fabsf(m.GetYAxis().Length() - 1.0f) < 0.001f;
+ success &= fabsf(m.GetZAxis().Length() - 1.0f) < 0.001f;
+
+ DALI_TEST_CHECK(success);
+ END_TEST;
+}
+
+int UtcDaliMatrixOrthoNormalize1P(void)
{
- float floats[] =
- { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
- 8.0f, 9.0f, 10.0f, 11.0f,
- 12.0f, 13.0f, 14.0f, 15.0f
- };
+ // OrthoNormalize is not flipping the axes and is maintaining the translation
+ for (int i=0;i<1000;++i)
+ {
+ float f = i;
+ Vector3 axis(cosf(f*0.001f), cosf(f*0.02f), cosf(f*0.03f));
+ axis.Normalize();
+ Vector3 center(10.0f, 15.0f, 5.0f);
- Matrix m(floats);
- m.Transpose();
+ Matrix m0;
+ m0.SetIdentity();
+ m0.SetTransformComponents( Vector3::ONE, Quaternion(Radian(1.0f), axis), center );
- bool success = true;
+ Matrix m1(m0);
+ m1.OrthoNormalize();
- for (int x=0;x<4;++x)
+ DALI_TEST_EQUALS(m0.GetXAxis(), m1.GetXAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetYAxis(), m1.GetYAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetZAxis(), m1.GetZAxis(), 0.001f, TEST_LOCATION);
+ DALI_TEST_EQUALS(m0.GetTranslation(), m1.GetTranslation(), 0.001f, TEST_LOCATION);
+ }
+ END_TEST;
+}
+
+int UtcDaliMatrixConstAsFloatP(void)
+{
+ float r[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ const Matrix m(r);
+
+ const float* els = m.AsFloat();
+ const float* init = r;
+ bool initialised = true;
+ for(size_t idx=0; idx<16; ++idx, ++els, ++init)
{
- for (int y=0;y<4;++y)
- {
- success &= (m.AsFloat()[x+y*4] == floats[x*4+y]);
- }
+ if(*els != *init)
+ initialised = false;
}
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
+
- DALI_TEST_CHECK(success);
END_TEST;
}
-int UtcDaliMatrixOStreamOperator(void)
+int UtcDaliMatrixAsFloatP(void)
{
- std::ostringstream oss;
-
- Matrix matrix;
- matrix.SetIdentity();
+ float r[] = { 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 2.0f, 3.0f, 4.0f};
+ Matrix m(r);
- oss << matrix;
+ float* els = m.AsFloat();
+ float* init = r;
+ bool initialised = true;
+ for(size_t idx=0; idx<16; ++idx, ++els, ++init)
+ {
+ if(*els != *init)
+ initialised = false;
+ }
+ DALI_TEST_EQUALS(initialised, true, TEST_LOCATION);
- std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]";
- DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
END_TEST;
}
-int UtcDaliMatrixMultiply(void)
+int UtcDaliMatrixMultiplyP(void)
{
Matrix m1 = Matrix::IDENTITY;
END_TEST;
}
-int UtcDaliMatrixOperatorMultiply(void)
+int UtcDaliMatrixOperatorMultiply01P(void)
{
Vector4 v1(2.0f, 5.0f, 4.0f, 0.0f);
END_TEST;
}
-int UtcDaliMatrixOperatorMultiply02(void)
+int UtcDaliMatrixOperatorMultiply02P(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliMatrixOperatorEquals(void)
+int UtcDaliMatrixOperatorEqualsP(void)
{
Matrix m1 = Matrix::IDENTITY;
END_TEST;
}
-
-int UtcDaliMatrixOperatorNotEquals(void)
+int UtcDaliMatrixOperatorNotEqualsP(void)
{
Matrix m1 = Matrix::IDENTITY;
float els[] = {2.0f, 0.0f, 0.0f, 0.0f,
END_TEST;
}
-int UtcDaliMatrixGetTransformComponents01(void)
-{
- Matrix m2(Matrix::IDENTITY.AsFloat());
- Vector3 pos2;
- Vector3 scale2;
- Quaternion q2;
- m2.GetTransformComponents(pos2, q2, scale2);
- DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(Vector3(1.0f, 1.0f, 1.0f), scale2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliMatrixGetTransformComponents02(void)
-{
- // Create an arbitrary vector
- for( float x=-1.0f; x<=1.0f; x+=0.1f )
- {
- for( float y=-1.0f; y<1.0f; y+=0.1f )
- {
- for( float z=-1.0f; z<1.0f; z+=0.1f )
- {
- Vector3 vForward(x, y, z);
- vForward.Normalize();
-
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
- {
- Quaternion rotation1(Radian(Degree(angle)), vForward);
- Vector3 scale1(2.0f, 3.0f, 4.0f);
- Vector3 position1(1.0f, 2.0f, 3.0f);
-
- Matrix m1(false);
- m1.SetTransformComponents(scale1, rotation1, position1);
-
- Vector3 position2;
- Quaternion rotation2;
- Vector3 scale2;
- m1.GetTransformComponents(position2, rotation2, scale2);
-
- DALI_TEST_EQUALS(position1, position2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(scale1, scale2, 0.001, TEST_LOCATION);
- DALI_TEST_EQUALS(rotation1, rotation2, 0.001, TEST_LOCATION);
- }
- }
- }
- }
- END_TEST;
-}
-
-int UtcDaliMatrixSetTransformComponents01(void)
+int UtcDaliMatrixSetTransformComponents01P(void)
{
// Create an arbitrary vector
for( float x=-1.0f; x<=1.0f; x+=0.1f )
Matrix m1(rotation1);
Matrix result1(false);
- Vector4 vForward4(vForward.x, vForward.y, vForward.z, 0.0f);
- result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward4), Vector3::ZERO );
+ Vector3 vForward3(vForward.x, vForward.y, vForward.z);
+ result1.SetTransformComponents( Vector3::ONE, Quaternion(Radian(Degree(angle)), vForward3), Vector3::ZERO );
DALI_TEST_EQUALS(m1, result1, 0.001, TEST_LOCATION);
}
-int UtcDaliMatrixSetInverseTransformComponent01(void)
+int UtcDaliMatrixSetInverseTransformComponent01P(void)
{
// Create an arbitrary vector
for( float x=-1.0f; x<=1.0f; x+=0.1f )
END_TEST;
}
-int UtcDaliMatrixSetInverseTransformComponent02(void)
+int UtcDaliMatrixSetInverseTransformComponent02P(void)
{
// Create an arbitrary vector
for( float x=-1.0f; x<=1.0f; x+=0.1f )
}
END_TEST;
}
+
+int UtcDaliMatrixGetTransformComponents01P(void)
+{
+ Matrix m2(Matrix::IDENTITY.AsFloat());
+ Vector3 pos2;
+ Vector3 scale2;
+ Quaternion q2;
+ m2.GetTransformComponents(pos2, q2, scale2);
+ DALI_TEST_EQUALS(Vector3(0.0f, 0.0f, 0.0f), pos2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Vector3(1.0f, 1.0f, 1.0f), scale2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
+
+int UtcDaliMatrixGetTransformComponents02P(void)
+{
+ // Create an arbitrary vector
+ for( float x=-1.0f; x<=1.0f; x+=0.1f )
+ {
+ for( float y=-1.0f; y<1.0f; y+=0.1f )
+ {
+ for( float z=-1.0f; z<1.0f; z+=0.1f )
+ {
+ Vector3 vForward(x, y, z);
+ vForward.Normalize();
+
+ for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
+ {
+ Quaternion rotation1(Radian(Degree(angle)), vForward);
+ Vector3 scale1(2.0f, 3.0f, 4.0f);
+ Vector3 position1(1.0f, 2.0f, 3.0f);
+
+ Matrix m1(false);
+ m1.SetTransformComponents(scale1, rotation1, position1);
+
+ Vector3 position2;
+ Quaternion rotation2;
+ Vector3 scale2;
+ m1.GetTransformComponents(position2, rotation2, scale2);
+
+ DALI_TEST_EQUALS(position1, position2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(scale1, scale2, 0.001, TEST_LOCATION);
+ DALI_TEST_EQUALS(rotation1, rotation2, 0.001, TEST_LOCATION);
+ }
+ }
+ }
+ }
+ END_TEST;
+}
+
+
+int UtcDaliMatrixOStreamOperator(void)
+{
+ std::ostringstream oss;
+
+ Matrix matrix;
+ matrix.SetIdentity();
+
+ oss << matrix;
+
+ std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]";
+
+ DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
+ END_TEST;
+}