stuff-from-scratch/test/compiler/TestLexer.cpp

20 lines
516 B
C++
Raw Normal View History

2022-12-06 18:02:43 +00:00
#include "Lexer.h"
#include "TestFramework.h"
#include "TestUtils.h"
#include <iostream>
TEST_CASE(TestLexer_MatchPattern, "[compiler]")
{
2023-12-21 09:18:44 +00:00
String input = "[I'm inside the tag](I'm inside the brackets), followed by more text.";
String pattern = "[@](@)";
2022-12-06 18:02:43 +00:00
2023-12-21 09:18:44 +00:00
Vector<String> hits;
2022-12-06 18:02:43 +00:00
const auto matched = Lexer::matchPattern(pattern, input, '@', hits);
REQUIRE(matched);
REQUIRE(hits.size() == 2);
REQUIRE(hits[0] == "I'm inside the tag");
REQUIRE(hits[1] == "I'm inside the brackets");
}