/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
int UtcDaliMatrixConstructor01P(void)
{
- Matrix m2(false);
+ // State of memory cannot be guaranteed, so use
+ // a buffer in a known state to check for changes
+ char buffer[sizeof(Matrix)];
- bool initialised = true;
+ memset(buffer, 1, sizeof(Matrix));
+
+ Matrix* m2 = new(&buffer) Matrix(false);
+ bool initialisation_occured = false;
{
- float* els = m2.AsFloat();
+ float* els = m2->AsFloat();
for(size_t idx=0; idx<16; ++idx, ++els)
{
- if(*els != 0.0f)
- initialised = false;
+ if(*els == 0.0f)
+ initialisation_occured = true;
}
}
- DALI_TEST_EQUALS(initialised, false, TEST_LOCATION);
+ DALI_TEST_EQUALS(initialisation_occured, false, TEST_LOCATION);
END_TEST;
}
END_TEST;
}
+int UtcDaliMatrixAssign02P(void)
+{
+ Matrix a(Matrix::IDENTITY);
+ a = a; // self assign does the do nothing branch
+ DALI_TEST_EQUALS(Matrix(Matrix::IDENTITY), a, 0.001, TEST_LOCATION);
+ END_TEST;
+}
+
int UtcDaliMatrixSetIdentityP(void)
{
float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
END_TEST;
}
-int UtcDaliMatrixInvertTransform01P(void)
+int UtcDaliMatrixInvertTransformP(void)
{
for (int i=0;i<1000;++i)
{
END_TEST;
}
-int UtcDaliMatrixInvertTransform02P(void)
+int UtcDaliMatrixInvertTransformN(void)
{
std::string exceptionString( "EqualsZero( mMatrix[3] ) && EqualsZero( mMatrix[7] ) && EqualsZero( mMatrix[11] ) && Equals( mMatrix[15], 1.0f" );
try
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
+ float els[] = { 0.0f, 1.0f, 2.0f, 0.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 };
try
{
- float els[] = { 0.0f, 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f, 7.0f,
+ float els[] = { 0.0f, 1.0f, 2.0f, 0.0f,
+ 4.0f, 5.0f, 6.0f, 0.0f,
8.0f, 9.0f, 10.0f, 11.0f,
12.0f, 13.0f, 14.0f, 15.0f };
Matrix m(els);
try
{
- 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,
+ float els[] = { 0.0f, 1.0f, 2.0f, 0.0f,
+ 4.0f, 5.0f, 6.0f, 0.0f,
+ 8.0f, 9.0f, 10.0f, 0.0f,
12.0f, 13.0f, 14.0f, 15.0f };
Matrix m(els);
END_TEST;
}
-
int UtcDaliMatrixSetInverseTransformComponent01P(void)
{
// Create an arbitrary vector
Vector3 vForward(x, y, z);
vForward.Normalize();
- for( float angle = 5.0f; angle <= 360.0f; angle += 15.0f)
{
- Quaternion rotation1(Radian(Degree(angle)), vForward);
+ Quaternion rotation1(Quaternion::IDENTITY); // test no rotation branch
Vector3 scale1(2.0f, 3.0f, 4.0f);
Vector3 position1(1.0f, 2.0f, 3.0f);
END_TEST;
}
+int UtcDaliMatrixGetTransformComponents03P(void)
+{
+ Matrix m2; // zero branch
+ 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(0.0f, 0.0f, 0.0f), scale2, 0.001, TEST_LOCATION);
+ // DALI_TEST_EQUALS(Quaternion(), q2, 0.001, TEST_LOCATION);
+ END_TEST;
+}
int UtcDaliMatrixOStreamOperator(void)
{
oss << matrix;
- std::string expectedOutput = "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]";
+ 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;