summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-10-23 22:47:58 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-10-24 14:17:25 +0200
commitbf0b8507a62dd93a0c6b084d6a0a34a823ee7489 (patch)
treef123e32aeb4c6470b1244e4ad63333fa8a130ce4
parent5d3c4670d6060ccb31da465a5cab7651803ac365 (diff)
Fix float conversion warnings
-rw-r--r--src/test/enginesynctest.cpp67
1 files changed, 34 insertions, 33 deletions
diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp
index 39a25a6c77..9c3f5d4e3a 100644
--- a/src/test/enginesynctest.cpp
+++ b/src/test/enginesynctest.cpp
@@ -17,6 +17,7 @@
namespace {
constexpr double kMaxFloatingPointErrorLowPrecision = 0.005;
constexpr double kMaxFloatingPointErrorHighPrecision = 0.0000000000000005;
+constexpr double kMaxBeatDistanceEpsilon = 1e-9;
}
/// Tests for Master Sync.
@@ -1384,25 +1385,25 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeNoQuant) {
for (int i = 0; i < 50; ++i) {
ProcessBuffer();
// Keep messing with the rate
- float rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
+ double rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), rate);
// Buffers should be in sync.
- ASSERT_FLOAT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ ASSERT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
// Make sure we're actually going somewhere!
- EXPECT_GT(ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get(),
+ EXPECT_GT(
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
0);
// Buffers should be in sync.
- EXPECT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ EXPECT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
TEST_F(EngineSyncTest, ZeroLatencyRateChangeQuant) {
@@ -1435,25 +1436,25 @@ TEST_F(EngineSyncTest, ZeroLatencyRateChangeQuant) {
for (int i = 0; i < 50; ++i) {
ProcessBuffer();
// Keep messing with the rate
- float rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
+ double rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), rate);
// Buffers should be in sync.
- ASSERT_FLOAT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ ASSERT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
// Make sure we're actually going somewhere!
- EXPECT_GT(ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get(),
+ EXPECT_GT(
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
0);
// Buffers should be in sync.
- EXPECT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ EXPECT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
TEST_F(EngineSyncTest, ZeroLatencyRateDiffQuant) {
@@ -1485,25 +1486,25 @@ TEST_F(EngineSyncTest, ZeroLatencyRateDiffQuant) {
for (int i = 0; i < 50; ++i) {
ProcessBuffer();
// Keep messing with the rate
- float rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
+ double rate = i % 2 == 0 ? i / 10.0 : i / -10.0;
ControlObject::set(ConfigKey(m_sGroup2, "rate_ratio"), rate);
// Buffers should be in sync.
- ASSERT_FLOAT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ ASSERT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
// Make sure we're actually going somewhere!
- EXPECT_GT(ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get(),
+ EXPECT_GT(
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
0);
// Buffers should be in sync.
- EXPECT_EQ(ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))
- ->get(),
- ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))
- ->get());
+ EXPECT_NEAR(
+ ControlObject::getControl(ConfigKey(m_sGroup2, "beat_distance"))->get(),
+ ControlObject::getControl(ConfigKey(m_sGroup1, "beat_distance"))->get(),
+ kMaxBeatDistanceEpsilon);
}
// In this test, we set play *first* and then turn on master sync.