Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2017-12-29 17:05:03 +0300
committerMikkel Krautz <mikkel@krautz.dk>2017-12-31 15:19:59 +0300
commit6ca110a2226b0559fca85d22f287ec8a14eee1d1 (patch)
tree532597d26dbbd36f446bddcb41c6be179ffaf03e /src/tests
parenta221fedfd3ebc4e722077f56e057c11260839e44 (diff)
src/tests: add TestStdAbs test.
This adds a 'just-in-case' test for correct runtime behavior of std::abs's float overload.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/TestStdAbs/TestStdAbs.cpp31
-rw-r--r--src/tests/TestStdAbs/TestStdAbs.pro9
-rw-r--r--src/tests/tests.pro3
3 files changed, 42 insertions, 1 deletions
diff --git a/src/tests/TestStdAbs/TestStdAbs.cpp b/src/tests/TestStdAbs/TestStdAbs.cpp
new file mode 100644
index 000000000..ae06787a9
--- /dev/null
+++ b/src/tests/TestStdAbs/TestStdAbs.cpp
@@ -0,0 +1,31 @@
+// Copyright 2005-2017 The Mumble Developers. All rights reserved.
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file at the root of the
+// Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+#include <QtCore>
+#include <QtTest>
+
+#include <cmath>
+
+/// Test the std::abs works with floats.
+/// In fixing mumble-voip/mumble#3281, I
+/// stumbled upon http://eigen.tuxfamily.org/bz/show_bug.cgi?id=619.
+/// It seems that, on some platforms, std::abs
+/// might not call through to the correct libc
+/// function.
+/// Test that it works for us.
+class TestStdAbs : public QObject {
+ Q_OBJECT
+ private slots:
+ void floatWorks();
+};
+
+void TestStdAbs::floatWorks() {
+ const float in = -1.5;
+ float out = std::abs(in);
+ QVERIFY(out > 1.2 && out < 1.8);
+}
+
+QTEST_MAIN(TestStdAbs)
+#include "TestStdAbs.moc"
diff --git a/src/tests/TestStdAbs/TestStdAbs.pro b/src/tests/TestStdAbs/TestStdAbs.pro
new file mode 100644
index 000000000..6fbff2969
--- /dev/null
+++ b/src/tests/TestStdAbs/TestStdAbs.pro
@@ -0,0 +1,9 @@
+# Copyright 2005-2017 The Mumble Developers. All rights reserved.
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file at the root of the
+# Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+include(../test.pri)
+
+TARGET = TestStdAbs
+SOURCES = TestStdAbs.cpp
diff --git a/src/tests/tests.pro b/src/tests/tests.pro
index ee778fb1b..1b55d0ae7 100644
--- a/src/tests/tests.pro
+++ b/src/tests/tests.pro
@@ -18,4 +18,5 @@ SUBDIRS += \
TestServerResolver \
TestSelfSignedCertificate \
TestSSLLocks \
- TestFFDHE
+ TestFFDHE \
+ TestStdAbs