#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "textures.hpp"
#include "levelmanager.hpp"

using namespace fmt;

TEST_CASE("test texture management", "[textures]") {
  textures::init();
  auto spider = textures::get("hairy_spider");
  REQUIRE(spider.sprite != nullptr);
  REQUIRE(spider.texture != nullptr);

  auto image = textures::load_image("assets/hairy_spider-256.png");

  auto img_ptr = textures::get_surface(0);
  REQUIRE(img_ptr != nullptr);

  auto floor_ptr = textures::get_floor();
  REQUIRE(floor_ptr != nullptr);

  auto ceiling_ptr = textures::get_ceiling();
  REQUIRE(ceiling_ptr != nullptr);

  LevelManager levels;
  GameLevel level = levels.current();
  auto& tiles = level.map->tiles();
  auto map = textures::convert_char_to_texture(tiles.$tile_ids);
  REQUIRE(matrix::width(map) == matrix::width(tiles.$tile_ids));
  REQUIRE(matrix::height(map) == matrix::height(tiles.$tile_ids));
}
