Création Test

This commit is contained in:
Crizomb 2025-06-13 01:25:45 +02:00
parent 611ff37653
commit dd67b76d1f
6 changed files with 79 additions and 6 deletions

View file

@ -0,0 +1,26 @@
#
# Lines inspired by https://google.github.io/googletest/quickstart-cmake.html
#
# Note: include(GoogleTest)and enable_testing() already done in top CMakeLists.txt
add_executable(unitTests
NoteTileTest.cpp
../Include/NoteTile.hpp ../Source/NoteTile.cpp ../Source/NoteSprite.cpp
)
target_include_directories(unitTests
PRIVATE
../Include
)
target_link_libraries(unitTests GTest::gtest_main sfml-graphics)
if (WIN32)
target_link_libraries(unitTests wsock32.lib ws2_32.lib)
else() # We are under UNIX
target_link_options(unitTests PRIVATE -pthread)
endif()
# The next line enables CMakes test runner to discover the tests included in the binary,
# using the GoogleTest CMake module (which was included in root CMakeLists.txt).
include(GoogleTest)
gtest_discover_tests(unitTests)

View file

@ -0,0 +1,18 @@
#include <gtest/gtest.h>
#include "../Include/NoteTile.hpp"
#include "NoteSprite.hpp"
namespace NoteTile_test {
TEST(NoteFileTest, Yes) { EXPECT_EQ(0, 0); }
TEST(NoteFileTest, No) { EXPECT_EQ(0, 1); }
TEST(NoteTileTest, CreateTile) {
NoteTile::clear();
NoteTile::create(2.0f, 0.5f, NotePlaceEnum::Right);
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);
}
}; // namespace NoteTile_test