From b4f07563a8d9a7ce2daa4881f1ab0ed049d3d39c Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 25 Aug 2024 11:02:37 -0400 Subject: [PATCH] chore: Refactor yaze_test and test_editor for improved organization and readability --- src/test/integration/test_editor.cc | 3 +++ src/test/yaze_test.cc | 14 +++++++++++--- src/yaze.cc | 11 ++++++++--- src/yaze.h | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/test/integration/test_editor.cc b/src/test/integration/test_editor.cc index 8c466445..da19d975 100644 --- a/src/test/integration/test_editor.cc +++ b/src/test/integration/test_editor.cc @@ -1,5 +1,7 @@ #include "test/integration/test_editor.h" +#include + #include "app/core/controller.h" #include "app/core/platform/renderer.h" #include "app/gui/style.h" @@ -91,6 +93,7 @@ int RunIntegrationTest() { ImGuiTestEngine_Stop(engine); controller.OnExit(); + return EXIT_SUCCESS; } } // namespace integration diff --git a/src/test/yaze_test.cc b/src/test/yaze_test.cc index 6af9636a..2d5459fb 100644 --- a/src/test/yaze_test.cc +++ b/src/test/yaze_test.cc @@ -2,7 +2,6 @@ #include "yaze.h" -#include #include #include "absl/debugging/failure_signal_handler.h" @@ -12,9 +11,18 @@ namespace yaze { namespace test { -TEST(YazeTest, InitializeAndCleanup) { +TEST(YazeTest, LoadAndUnloadRom) { yaze_flags flags; - yaze_init(&flags); + flags.rom_filename = "zelda3.sfc"; + const int init = yaze_init(&flags); + ASSERT_EQ(init, 0); + yaze_cleanup(&flags); +} + +TEST(YazeTest, NoFilename) { + yaze_flags flags; + const int init = yaze_init(&flags); + ASSERT_EQ(init, -1); yaze_cleanup(&flags); } diff --git a/src/yaze.cc b/src/yaze.cc index 36b394da..7f23f262 100644 --- a/src/yaze.cc +++ b/src/yaze.cc @@ -17,16 +17,21 @@ void yaze_check_version(const char* version) { return; } -void yaze_init(yaze_flags* flags) { +int yaze_init(yaze_flags* flags) { if (flags == nullptr) { - return; + return -1; } if (flags->rom_filename == nullptr) { - return; + return -1; } flags->rom = yaze_load_rom(flags->rom_filename); + if (flags->rom == nullptr) { + return -1; + } + + return 0; } void yaze_cleanup(yaze_flags* flags) { diff --git a/src/yaze.h b/src/yaze.h index 34a53c10..c85a8225 100644 --- a/src/yaze.h +++ b/src/yaze.h @@ -62,7 +62,7 @@ void yaze_check_version(const char* version); * * @param flags Flags to initialize the library. */ -void yaze_init(yaze_flags*); +int yaze_init(yaze_flags*); /** * @brief Clean up the Yaze library.