Move test dir to root

This commit is contained in:
scawful
2025-01-19 19:09:39 -05:00
parent de75cc6850
commit e4cc3b977a
18 changed files with 25 additions and 16 deletions

View File

@@ -0,0 +1,33 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "app/rom.h"
#include "app/zelda3/dungeon/room.h"
namespace yaze {
namespace test {
class DungeonRoomTest : public ::testing::Test, public SharedRom {
protected:
void SetUp() override {
// Skip tests on Linux for automated github builds
#if defined(__linux__)
GTEST_SKIP();
#else
if (!rom()->LoadFromFile("./zelda3.sfc").ok()) {
GTEST_SKIP_("Failed to load test ROM");
}
#endif
}
void TearDown() override {}
};
TEST_F(DungeonRoomTest, SingleRoomLoadOk) {
zelda3::Room test_room(/*room_id=*/0);
test_room.LoadHeader();
// Do some assertions based on the output in ZS
test_room.LoadRoomFromROM();
}
} // namespace test
} // namespace yaze

View File

@@ -0,0 +1,54 @@
#include <gtest/gtest.h>
#include "app/editor/message/message_data.h"
#include "app/editor/message/message_editor.h"
#include "test/core/testing.h"
namespace yaze {
namespace test {
class MessageTest : public ::testing::Test, public SharedRom {
protected:
void SetUp() override {
#if defined(__linux__)
GTEST_SKIP();
#endif
}
void TearDown() override {}
editor::MessageEditor message_editor_;
std::vector<editor::DictionaryEntry> dictionary_;
};
TEST_F(MessageTest, LoadMessagesFromRomOk) {
EXPECT_OK(rom()->LoadFromFile("zelda3.sfc"));
EXPECT_OK(message_editor_.Initialize());
}
/**
* @test Verify that a single message can be loaded from the ROM.
*
* @details The message is loaded from the ROM and the message is parsed.
*
* Message #1 at address 0x0E000B
RawString:
[S:00][3][][:75][:44][CH2I]
Parsed:
[S:##]A
[3]give
[2]give >[CH2I]
Message ID: 2
Raw: [S:00][3][][:75][:44][CH2I]
Parsed: [S:00][3][][:75][:44][CH2I]
Raw Bytes: 7A 00 76 88 8A 75 88 44 68
Parsed Bytes: 7A 00 76 88 8A 75 88 44 68
*/
TEST_F(MessageTest, VerifySingleMessageFromRomOk) {
// TODO - Implement this test
}
} // namespace test
} // namespace yaze

View File

@@ -0,0 +1,47 @@
#include "app/zelda3/overworld/overworld.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "app/rom.h"
#include "app/zelda3/overworld/overworld.h"
#include "app/zelda3/overworld/overworld_map.h"
#include "test/core/testing.h"
namespace yaze {
namespace test {
class OverworldTest : public ::testing::Test, public SharedRom {
protected:
void SetUp() override {
// Skip tests on Linux for automated github builds
#if defined(__linux__)
GTEST_SKIP();
#endif
}
void TearDown() override {}
zelda3::Overworld overworld_{*rom()};
};
TEST_F(OverworldTest, OverworldLoadNoRomDataError) {
Rom rom;
EXPECT_THAT(overworld_.Load(rom),
StatusIs(absl::StatusCode::kInvalidArgument));
}
TEST_F(OverworldTest, OverworldLoadRomDataOk) {
/**
EXPECT_OK(rom()->LoadFromFile("zelda3.sfc"));
ASSERT_OK_AND_ASSIGN(auto gfx_data,
LoadAllGraphicsData(*rom(), true));
auto status = overworld_.Load(*rom());
EXPECT_TRUE(status.ok());
EXPECT_EQ(overworld_.overworld_maps().size(), zelda3::kNumOverworldMaps);
EXPECT_EQ(overworld_.tiles16().size(), zelda3::kNumTile16Individual);
*/
}
} // namespace test
} // namespace yaze

View File

@@ -0,0 +1,64 @@
#include "app/zelda3/sprite/sprite_builder.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace yaze {
namespace test {
using namespace yaze::zelda3;
class SpriteBuilderTest : public ::testing::Test {
protected:
void SetUp() override {
// Create a new sprite
SpriteBuilder sprite = SpriteBuilder::Create("Puffstool")
.SetProperty("NbrTiles", 2)
.SetProperty("Health", 10)
.SetProperty("Harmless", false);
// Create an anonymous global action for the sprite to run before each
// action
SpriteAction globalAction = SpriteAction::Create().AddInstruction(
SpriteInstruction::BehaveAsBarrier());
// Create an action for the SprAction::LocalJumpTable
SpriteAction walkAction =
SpriteAction::Create("Walk")
.AddInstruction(SpriteInstruction::PlayAnimation(0, 6, 10))
.AddInstruction(SpriteInstruction::ApplySpeedTowardsPlayer(2))
.AddInstruction(SpriteInstruction::MoveXyz())
.AddInstruction(SpriteInstruction::BounceFromTileCollision())
.AddCustomInstruction("JSL $0DBB7C"); // Custom ASM
// Link to the idle action. If the action does not exist, build will fail
walkAction.SetNextAction("IdleAction");
// Idle action which jumps to a fn. If the fn does not exist, build will
// fail
SpriteAction idleAction =
SpriteAction::Create("IdleAction")
.AddInstruction(SpriteInstruction::JumpToFunction("IdleFn"));
idleAction.SetNextAction("Walk");
// Build the function that the idle action jumps to
SpriteAction idleFunction = SpriteAction::Create("IdleFn").AddInstruction(
SpriteInstruction::MoveXyz());
// Add actions and functions to sprite
sprite.SetGlobalAction(globalAction);
sprite.AddAction(idleAction); // 0x00
sprite.AddAction(walkAction); // 0x01
sprite.AddFunction(idleFunction); // Local
}
void TearDown() override {}
SpriteBuilder sprite;
};
TEST_F(SpriteBuilderTest, BuildSpritePropertiesOk) {
EXPECT_THAT(sprite.BuildProperties(), testing::HasSubstr(R"(!SPRID = $00
!NbrTiles = $00
!Harmless = $00
)"));
}
} // namespace test
} // namespace yaze