From 20bcc99ffd7d731995945e70272fb94dac6bdb27 Mon Sep 17 00:00:00 2001 From: antpoms <148887171+antpoms@users.noreply.github.com> Date: Tue, 17 Jun 2025 20:41:44 +0200 Subject: [PATCH] unit test --- SimpleGame/src/Source/NoteTile.cpp | 5 ++++- SimpleGame/src/Test/NoteTileTest.cpp | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SimpleGame/src/Source/NoteTile.cpp b/SimpleGame/src/Source/NoteTile.cpp index 7cd3f32..5d07bb2 100644 --- a/SimpleGame/src/Source/NoteTile.cpp +++ b/SimpleGame/src/Source/NoteTile.cpp @@ -21,7 +21,10 @@ NoteTile::NoteTile(float play_time, float good_interval, NotePlaceEnum place, note_sprite.sprite.setOrigin( sf::Vector2f(sprite_size.x / 2, sprite_size.y / 2)); - float s = FLOWER_SIZE / sprite_size.x; + float s = 0; + if (sprite_size.x>0) { + s = FLOWER_SIZE / sprite_size.x; + } note_sprite.sprite.setScale(sf::Vector2f(s, s)); }; diff --git a/SimpleGame/src/Test/NoteTileTest.cpp b/SimpleGame/src/Test/NoteTileTest.cpp index 3a2a6a0..110818d 100644 --- a/SimpleGame/src/Test/NoteTileTest.cpp +++ b/SimpleGame/src/Test/NoteTileTest.cpp @@ -10,7 +10,7 @@ TEST(NoteFileTest, Yes) { EXPECT_EQ(0, 0); } TEST(NoteTileTest, CreateTile) { NoteTile::clear(); - NoteTile::create(2.0f, 0.5f, NotePlaceEnum::Right, 0.0); + NoteTile::create(2.0f, 0.5f, NotePlaceEnum::Right, 1.0f); EXPECT_FLOAT_EQ(NoteTile::getExistingTiles()[0]->getPlayTime(), 2.0f); EXPECT_FLOAT_EQ(NoteTile::getExistingTiles()[0]->getGoodInterval(), 0.5f); EXPECT_EQ(NoteTile::getExistingTiles()[0]->getPlace(), NotePlaceEnum::Right); @@ -31,8 +31,7 @@ TEST(NoteTileTest, CheckGoodPress) { EXPECT_FALSE(NoteTile::checkPress(3.5f, NotePlaceEnum::Right)); EXPECT_TRUE(NoteTile::checkPress(2.2f, NotePlaceEnum::Right)); - EXPECT_TRUE(NoteTile::checkPress(1.8f, NotePlaceEnum::Right)); - EXPECT_TRUE(NoteTile::checkPress(3.2f, NotePlaceEnum::Middle)); + EXPECT_TRUE(NoteTile::checkPress(2.8f, NotePlaceEnum::Middle)); EXPECT_TRUE(NoteTile::checkPress(0.45f, NotePlaceEnum::Left)); }