File: test_image.cpp

package info (click to toggle)
libtcod 1.24.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,728 kB
  • sloc: ansic: 46,186; cpp: 13,523; python: 4,814; makefile: 44; sh: 25
file content (21 lines) | stat: -rw-r--r-- 480 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <catch2/catch_all.hpp>

#include "libtcod/image.hpp"

TEST_CASE("TCODImage") {
  auto img = TCODImage{};
  img = TCODImage{3, 2};
  REQUIRE(img.get_data());
  REQUIRE(img.getPixel(0, 0) == TCODColor{0, 0, 0});
  img.clear({0, 0, 0});
  img.putPixel(0, 0, {1, 2, 3});
  REQUIRE(img.getPixel(0, 0) == TCODColor{1, 2, 3});
  {
    int w{};
    int h{};
    img.getSize(&w, &h);
    REQUIRE(w == 3);
    REQUIRE(h == 2);
    REQUIRE(img.getSize() == std::array{w, h});
  }
}