diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-26 17:45:11 +0400 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-26 20:15:04 +0000 |
commit | 4ed795df247c5859089e3a6b6ca7c24e8c973a31 (patch) | |
tree | 969acbb9d7ac42fc6f196e69523d9e692edce834 /tests | |
parent | d07166af645fa65cb7e9f571dbc34eb946463627 (diff) | |
download | qtbase-4ed795df247c5859089e3a6b6ca7c24e8c973a31.tar.gz |
Use C++ <cmath> instead of <math.h> in math3d autotests
Change-Id: I2e13ec190ec42ac7732ce9ed3ca5567f637beb1e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 6 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp | 7 | ||||
-rw-r--r-- | tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp | 6 |
3 files changed, 10 insertions, 9 deletions
diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index a9d8e60046..e7659a25bd 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -2279,9 +2279,9 @@ void tst_QMatrixNxN::rotate4x4_data() float y = 2.0f; float z = -6.0f; float angle = -45.0f; - float c = qCos(angle * M_PI / 180.0f); - float s = qSin(angle * M_PI / 180.0f); - float len = sqrtf(x * x + y * y + z * z); + float c = std::cos(angle * M_PI / 180.0f); + float s = std::sin(angle * M_PI / 180.0f); + float len = std::sqrt(x * x + y * y + z * z); float xu = x / len; float yu = y / len; float zu = z / len; diff --git a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp index a4defcc7f2..ed93ff24b0 100644 --- a/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp +++ b/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp @@ -237,7 +237,7 @@ void tst_QQuaternion::length_data() QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 0.0f << 1.0f; QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 0.0f << 1.0f; QTest::newRow("-1w") << 0.0f << 0.0f << 0.0f << -1.0f << 1.0f; - QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << sqrtf(16.0f); + QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << std::sqrt(16.0f); } void tst_QQuaternion::length() { @@ -710,8 +710,9 @@ void tst_QQuaternion::fromAxisAndAngle() // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56 // to calculate the answer we expect to get. QVector3D vector = QVector3D(x1, y1, z1).normalized(); - float sin_a = sinf((angle * M_PI / 180.0) / 2.0); - float cos_a = cosf((angle * M_PI / 180.0) / 2.0); + const float a = (angle * M_PI / 180.0) / 2.0; + const float sin_a = std::sin(a); + const float cos_a = std::cos(a); QQuaternion result(cos_a, (vector.x() * sin_a), (vector.y() * sin_a), diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index 6d4d6f9754..d2e0bbe375 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -667,7 +667,7 @@ void tst_QVectorND::length2_data() QTest::newRow("1y") << 0.0f << 1.0f << 1.0f; QTest::newRow("-1x") << -1.0f << 0.0f << 1.0f; QTest::newRow("-1y") << 0.0f << -1.0f << 1.0f; - QTest::newRow("two") << 2.0f << -2.0f << sqrtf(8.0f); + QTest::newRow("two") << 2.0f << -2.0f << std::sqrt(8.0f); } void tst_QVectorND::length2() { @@ -695,7 +695,7 @@ void tst_QVectorND::length3_data() QTest::newRow("-1x") << -1.0f << 0.0f << 0.0f << 1.0f; QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 1.0f; QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 1.0f; - QTest::newRow("two") << 2.0f << -2.0f << 2.0f << sqrtf(12.0f); + QTest::newRow("two") << 2.0f << -2.0f << 2.0f << std::sqrt(12.0f); } void tst_QVectorND::length3() { @@ -727,7 +727,7 @@ void tst_QVectorND::length4_data() QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 0.0f << 1.0f; QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 0.0f << 1.0f; QTest::newRow("-1w") << 0.0f << 0.0f << 0.0f << -1.0f << 1.0f; - QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << sqrtf(16.0f); + QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << std::sqrt(16.0f); } void tst_QVectorND::length4() { |