chore: Refactor yaze_test and test_editor for improved organization and readability

This commit is contained in:
scawful
2024-08-25 11:02:37 -04:00
parent c62b2c0913
commit b4f07563a8
4 changed files with 23 additions and 7 deletions

View File

@@ -1,5 +1,7 @@
#include "test/integration/test_editor.h"
#include <SDL.h>
#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

View File

@@ -2,7 +2,6 @@
#include "yaze.h"
#include <SDL.h>
#include <gtest/gtest.h>
#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);
}

View File

@@ -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) {

View File

@@ -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.