Added testing with Catch2
Some checks failed
ci/woodpecker/push/workflow Pipeline failed

This commit is contained in:
2025-09-30 21:46:26 +03:00
committed by Emin Arslan
parent 34d35d6039
commit 8fc3e82173
3 changed files with 47 additions and 4 deletions

21
src/tests/test.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include <catch2/catch_test_macros.hpp>
#include <lex.hpp>
using namespace std;
TEST_CASE("Lexer lexes doubles correctly", "[Lexer]") {
SECTION("double and negative syntax") {
Lexer l("(1.0 0.1 -.1 -1. . - -. .-)");
REQUIRE(l.next() == Token({OpenParen}));
REQUIRE(l.next() == Token({Double, 1.0}));
REQUIRE(l.next() == Token({Double, 0.1}));
REQUIRE(l.next() == Token({Double, -0.1}));
REQUIRE(l.next() == Token({Double, -1.0}));
REQUIRE(l.next() == Token({Symbol, "."}));
REQUIRE(l.next() == Token({Symbol, "-"}));
REQUIRE(l.next() == Token({Symbol, "-."}));
REQUIRE(l.next() == Token({Symbol, ".-"}));
REQUIRE(l.next() == Token({CloseParen}));
}
}