chore: Refactor yaze_test and test_editor for improved organization and readability
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "test/integration/test_editor.h"
|
#include "test/integration/test_editor.h"
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "app/core/controller.h"
|
#include "app/core/controller.h"
|
||||||
#include "app/core/platform/renderer.h"
|
#include "app/core/platform/renderer.h"
|
||||||
#include "app/gui/style.h"
|
#include "app/gui/style.h"
|
||||||
@@ -91,6 +93,7 @@ int RunIntegrationTest() {
|
|||||||
|
|
||||||
ImGuiTestEngine_Stop(engine);
|
ImGuiTestEngine_Stop(engine);
|
||||||
controller.OnExit();
|
controller.OnExit();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace integration
|
} // namespace integration
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "yaze.h"
|
#include "yaze.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "absl/debugging/failure_signal_handler.h"
|
#include "absl/debugging/failure_signal_handler.h"
|
||||||
@@ -12,9 +11,18 @@
|
|||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
TEST(YazeTest, InitializeAndCleanup) {
|
TEST(YazeTest, LoadAndUnloadRom) {
|
||||||
yaze_flags flags;
|
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);
|
yaze_cleanup(&flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
src/yaze.cc
11
src/yaze.cc
@@ -17,16 +17,21 @@ void yaze_check_version(const char* version) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yaze_init(yaze_flags* flags) {
|
int yaze_init(yaze_flags* flags) {
|
||||||
if (flags == nullptr) {
|
if (flags == nullptr) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags->rom_filename == nullptr) {
|
if (flags->rom_filename == nullptr) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags->rom = yaze_load_rom(flags->rom_filename);
|
flags->rom = yaze_load_rom(flags->rom_filename);
|
||||||
|
if (flags->rom == nullptr) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void yaze_cleanup(yaze_flags* flags) {
|
void yaze_cleanup(yaze_flags* flags) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void yaze_check_version(const char* version);
|
|||||||
*
|
*
|
||||||
* @param flags Flags to initialize the library.
|
* @param flags Flags to initialize the library.
|
||||||
*/
|
*/
|
||||||
void yaze_init(yaze_flags*);
|
int yaze_init(yaze_flags*);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clean up the Yaze library.
|
* @brief Clean up the Yaze library.
|
||||||
|
|||||||
Reference in New Issue
Block a user