diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/AudioTest.cpp | 9 | ||||
-rw-r--r-- | src/test/InputTest.cpp | 30 | ||||
-rw-r--r-- | src/test/Vector2Test.cpp | 10 |
3 files changed, 42 insertions, 7 deletions
diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp index 3844c73..e548221 100644 --- a/src/test/AudioTest.cpp +++ b/src/test/AudioTest.cpp @@ -60,6 +60,8 @@ TEST_F(AudioTest, Play) { InSequence seq; EXPECT_CALL(context, play(_)).Times(0); + EXPECT_CALL(context, set_loop(_, _)).Times(0); + EXPECT_CALL(context, set_volume(_, _)).Times(0); component.play(); } @@ -67,6 +69,8 @@ TEST_F(AudioTest, Play) { InSequence seq; EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); system.fixed_update(); } } @@ -146,6 +150,9 @@ TEST_F(AudioTest, PlayOnActive) { InSequence seq; EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); + component.active = true; system.fixed_update(); } @@ -156,6 +163,8 @@ TEST_F(AudioTest, PlayImmediately) { component.play(); EXPECT_CALL(context, play(_)).Times(1); + EXPECT_CALL(context, set_volume(_, _)).Times(1); + EXPECT_CALL(context, set_loop(_, _)).Times(1); system.fixed_update(); } diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index 9a541a0..a1fe59a 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -216,7 +216,8 @@ TEST_F(InputTest, testButtonClick) { EXPECT_EQ(event.metadata.game_object_id, button_obj.id); return false; }); - auto & button = button_obj.add_component<Button>(vec2 {100, 100}, vec2 {0, 0}); + auto & button + = button_obj.add_component<Button>(vec2 {100, 100}, Button::Data {}, vec2 {0, 0}); bool hover = false; button.active = true; @@ -238,9 +239,14 @@ TEST_F(InputTest, buttonPositionCamera) { EXPECT_EQ(event.metadata.game_object_id, button_obj.id); return false; }); - auto & button = button_obj.add_component<Button>(vec2 {10, 10}, vec2 {0, 0}); + auto & button = button_obj.add_component<Button>( + vec2 {10, 10}, + Button::Data { + .world_space = false, + }, + vec2 {0, 0} + ); - button.world_space = false; bool hover = false; button.active = true; this->simulate_mouse_click(999, 999, SDL_BUTTON_LEFT); @@ -261,8 +267,13 @@ TEST_F(InputTest, buttonPositionWorld) { EXPECT_EQ(event.metadata.game_object_id, button_obj.id); return false; }); - auto & button = button_obj.add_component<Button>(vec2 {10, 10}, vec2 {0, 0}); - button.world_space = true; + auto & button = button_obj.add_component<Button>( + vec2 {10, 10}, + Button::Data { + .world_space = true, + }, + vec2 {0, 0} + ); bool hover = false; button.active = true; this->simulate_mouse_click(999, 999, SDL_BUTTON_LEFT); @@ -288,8 +299,13 @@ TEST_F(InputTest, testButtonHover) { EXPECT_EQ(event.metadata.game_object_id, button_obj.id); return false; }); - auto & button = button_obj.add_component<Button>(vec2 {100, 100}, vec2 {0, 0}); - button.active = true; + auto & button = button_obj.add_component<Button>( + vec2 {100, 100}, + Button::Data { + .world_space = true, + }, + vec2 {0, 0} + ); // Mouse on button SDL_Event hover_event; SDL_zero(hover_event); diff --git a/src/test/Vector2Test.cpp b/src/test/Vector2Test.cpp index 1e21af9..b17f95a 100644 --- a/src/test/Vector2Test.cpp +++ b/src/test/Vector2Test.cpp @@ -1,6 +1,7 @@ #include <gtest/gtest.h> #include <crepe/api/Vector2.h> +#include <crepe/types.h> using namespace crepe; @@ -530,3 +531,12 @@ TEST_F(Vector2Test, Perpendicular) { EXPECT_FLOAT_EQ(result4.x, -4.0f); EXPECT_FLOAT_EQ(result4.y, 3.0f); } + +TEST_F(Vector2Test, Rotate) { + vec2 foo {0, 1}; + + foo = foo.rotate(90); + const float GOOD_ENOUGH = 0.001; + EXPECT_NEAR(foo.x, 1, GOOD_ENOUGH); + EXPECT_NEAR(foo.y, 0, GOOD_ENOUGH); +} |