Skip to content

Commit

Permalink
FramePos: Ensure that all invalid frame positions are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Jul 3, 2021
1 parent a710a02 commit 5240074
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/frametest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,34 @@ TEST_F(FrameTest, TestFramePosFractional) {
EXPECT_TRUE(mixxx::audio::FramePos(128.5).isFractional());
EXPECT_TRUE(mixxx::audio::FramePos(135.67).isFractional());
}

TEST_F(FrameTest, TestFramePosEquality) {
EXPECT_EQ(mixxx::audio::FramePos(0), mixxx::audio::FramePos(0));
EXPECT_EQ(mixxx::audio::FramePos(-100), mixxx::audio::FramePos(-100));
EXPECT_EQ(mixxx::audio::FramePos(100), mixxx::audio::FramePos(100));
EXPECT_EQ(mixxx::audio::FramePos(50) * 2, mixxx::audio::FramePos(100));

EXPECT_NE(mixxx::audio::FramePos(100), mixxx::audio::FramePos(200));
EXPECT_NE(mixxx::audio::FramePos(100), mixxx::audio::FramePos());
EXPECT_NE(mixxx::audio::FramePos(0), mixxx::audio::FramePos());

// Check that invalid positions are equal to each other
EXPECT_EQ(mixxx::audio::FramePos(), mixxx::audio::kInvalidFramePos);
EXPECT_EQ(mixxx::audio::FramePos(), mixxx::audio::kInvalidFramePos / 2);
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(mixxx::audio::FramePos::kInvalidValue));
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::quiet_NaN()));
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
EXPECT_EQ(mixxx::audio::FramePos(),
mixxx::audio::FramePos(
-std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
EXPECT_EQ(mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::quiet_NaN()),
mixxx::audio::FramePos(std::numeric_limits<
mixxx::audio::FramePos::value_t>::infinity()));
}

0 comments on commit 5240074

Please sign in to comment.