From 369a13af88766e97c25afc7f90ecb82034b325fb Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Mon, 9 Sep 2024 05:40:11 +0200 Subject: [PATCH] Avoid rounding differences in test --- .../tests/playback/playbackmodel_tests.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engraving/tests/playback/playbackmodel_tests.cpp b/src/engraving/tests/playback/playbackmodel_tests.cpp index ad947a8c3ef36..72181bb6c5d4e 100644 --- a/src/engraving/tests/playback/playbackmodel_tests.cpp +++ b/src/engraving/tests/playback/playbackmodel_tests.cpp @@ -581,20 +581,20 @@ TEST_F(Engraving_PlaybackModelTests, Dynamics) EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION), forte); // Gradually grow louder than forte after that - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 1 / 24), 5770); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 2 / 24), + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 1) / 480.0 * QUARTER_NOTE_DURATION), 5770); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 2) / 480.0 * QUARTER_NOTE_DURATION), forte + (fortePlusSomething - forte) * 2 / 24); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 3 / 24), 5812); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 7 / 24), 5895); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 15 / 24), + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 3) / 480.0 * QUARTER_NOTE_DURATION), 5812); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 7) / 480.0 * QUARTER_NOTE_DURATION), 5895); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 15) / 480.0 * QUARTER_NOTE_DURATION), forte + (fortePlusSomething - forte) * 15 / 24); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 21 / 24), + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 21) / 480.0 * QUARTER_NOTE_DURATION), forte + (fortePlusSomething - forte) * 21 / 24); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 22 / 24), 6208); - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION) * 23 / 24), 6229); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 22) / 480.0 * QUARTER_NOTE_DURATION), 6208); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + int(1919 / 24.f * 23) / 480.0 * QUARTER_NOTE_DURATION), 6229); // Reach forte plus something, just before the start of the next measure - EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + (4 * QUARTER_NOTE_DURATION - EPSILON_DURATION)), fortePlusSomething); + EXPECT_EQ(dynamicLevelMap.at(12 * QUARTER_NOTE_DURATION + 1919 / 480.0 * QUARTER_NOTE_DURATION), fortePlusSomething); // Finally, jump to pianissimo EXPECT_EQ(dynamicLevelMap.at(16 * QUARTER_NOTE_DURATION), pianissimo);