raycaster/tests/textures.cpp
2026-06-17 00:32:31 -04:00

54 lines
1.4 KiB
C++

#include <fuc2/testing.hpp>
#include <fmt/core.h>
#include <string>
#include "graphics/textures.hpp"
#include "constants.hpp"
#include "game/components.hpp"
using namespace fmt;
using namespace fuc2;
namespace textures_tests {
void test_test_texture_management() {
components::init();
textures::init();
auto spider = textures::get_sprite("hairy_spider");
CHECK(spider.sprite != nullptr);
CHECK(spider.texture != nullptr);
CHECK(spider.frame_size.x == TEXTURE_WIDTH);
CHECK(spider.frame_size.y == TEXTURE_HEIGHT);
auto image = textures::load_image("assets/sprites/hairy_spider.png");
size_t floor_tile = textures::get_id("floor_tile");
size_t gray_stone = textures::get_id("gray_stone_floor_light");
auto floor_ptr = textures::get_surface(floor_tile);
CHECK(floor_ptr != nullptr);
auto gray_stone_ptr = textures::get_surface(gray_stone);
CHECK(gray_stone_ptr != nullptr);
auto& light = textures::get_ambient_light();
CHECK(light.size() > 0);
CHECK(light[floor_tile] == 0);
CHECK(light[gray_stone] > 0);
auto& tiles = textures::get_map_tile_set();
CHECK(tiles.size() > 0);
CHECK(tiles[floor_tile] > 0);
CHECK(tiles[gray_stone] > 0);
auto ceiling = textures::get_ceiling(floor_tile);
CHECK(ceiling != nullptr);
}
fuc2::Set TESTS{
.name="textures",
.tests={
TEST(test_test_texture_management),
}
};
}