Exploring raycasters and possibly make a little "doom like" game based on it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
raycaster/tests/lel.cpp

45 lines
1.4 KiB

#include "lel.hpp"
#include <catch2/catch_test_macros.hpp>
#include <fmt/core.h>
#include <string>
#include "ansi_parser.hpp"
#include <codecvt>
#include <iostream>
#include <vector>
TEST_CASE("test basic ops", "[lel]") {
LELParser parser(0, 0, 500, 500);
std::vector<std::string> labels{
"label_1", "label3", "text1", "people",
"label2", "_", "message", "buttons"};
bool good = parser.parse(
"[ label_1 | label3 | test1]"
"[ *(300,300)text1 | (150)people | test2]"
"[ >label2 | _ | test3]"
"[ message | buttons | test4]");
REQUIRE(good);
REQUIRE(parser.rows == 4);
REQUIRE(parser.columns == 3);
REQUIRE(parser.cells.size() == 12);
REQUIRE(parser.cells.at("label2").left == false);
REQUIRE(parser.cells.at("text1").expand == true);
REQUIRE(parser.cells.at("text1").w == 300);
REQUIRE(parser.cells.at("text1").h == 300);
REQUIRE(parser.cells.at("people").expand == false);
REQUIRE(parser.cells.at("message").expand == false);
for(auto name : labels) {
auto& cell = parser.cells.at(name);
fmt::println("name={}; col/row={},{}; x/y={},{} w/h={},{}; left={}, top={}, expand={}",
name, cell.col, cell.row, cell.x, cell.y, cell.w, cell.h, cell.left, cell.top, cell.expand);
REQUIRE(cell.w > 0);
REQUIRE(cell.h > 0);
REQUIRE(cell.row < parser.rows);
REQUIRE(cell.col < parser.columns);
}
}