Line data Source code
1 : #include "../inc/lexicalAnalysis/nicoleSintax.h"
2 : #include <catch2/catch_test_macros.hpp>
3 :
4 : TEST_CASE("NicoleSintax crea un Lexer con las categorías correctas",
5 9 : "[NicoleSintax]") {
6 : // Crear una instancia de NicoleSintax
7 9 : nicole::NicoleSintax sintax;
8 :
9 : // Crear el Lexer utilizando NicoleSintax
10 9 : nicole::Lexer lexer = sintax.createLexer();
11 :
12 : // Obtener las categorías del Lexer
13 9 : std::vector<nicole::Category> categories = lexer.categories();
14 :
15 : // Verificar que las categorías no estén vacías
16 9 : REQUIRE_FALSE(categories.empty());
17 :
18 : // Opcional: Verificar algunas categorías específicas
19 9 : bool foundSpaceCategory = false;
20 9 : bool foundCommentCategory = false;
21 :
22 801 : for (const auto &category : categories) {
23 801 : if (category.type() == nicole::TokenType::SPACE) {
24 9 : foundSpaceCategory = true;
25 9 : REQUIRE(category.rawPattern() == "\\s+");
26 9 : REQUIRE(category.skip() == true);
27 792 : } else if (category.type() == nicole::TokenType::COMMENT) {
28 9 : foundCommentCategory = true;
29 9 : REQUIRE(category.rawPattern() == "\\/\\*(.|\\n)*?\\*\\/");
30 9 : REQUIRE(category.skip() == true);
31 9 : }
32 : // Puedes agregar más verificaciones para otras categorías según sea
33 : // necesario
34 801 : }
35 :
36 9 : REQUIRE(foundSpaceCategory);
37 9 : REQUIRE(foundCommentCategory);
38 9 : }
|