LEL is working at a basic grid level, able to render boxes where I want.
This commit is contained in:
parent
846b7aaf16
commit
872cedc8e1
8 changed files with 127 additions and 99 deletions
|
@ -5,23 +5,41 @@
|
|||
#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 ]"
|
||||
"[ (300,300)text1 | (150)people ]"
|
||||
"[ >label2 | _ ]"
|
||||
"[ message | buttons ]");
|
||||
"[ label_1 | label3 | test1]"
|
||||
"[ *(300,300)text1 | (150)people | test2]"
|
||||
"[ >label2 | _ | test3]"
|
||||
"[ message | buttons | test4]");
|
||||
|
||||
REQUIRE(good);
|
||||
|
||||
REQUIRE(parser.row_count == 4);
|
||||
REQUIRE(parser.max_columns == 2);
|
||||
REQUIRE(parser.cells.size() == 8);
|
||||
REQUIRE(parser.rows == 4);
|
||||
REQUIRE(parser.columns == 3);
|
||||
REQUIRE(parser.cells.size() == 12);
|
||||
REQUIRE(parser.cells.at("label2").left == false);
|
||||
REQUIRE(parser.cells.at("label3").expand == true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue