LCOV - code coverage report
Current view: top level - test/lexicalAnalysis - test_location.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 36 36
Test Date: 2025-04-18 15:53:49 Functions: 100.0 % 1 1

            Line data    Source code
       1              : #include <catch2/catch_test_macros.hpp>
       2              : #include "../inc/lexicalAnalysis/location.h"
       3              : 
       4           36 : TEST_CASE("Pruebas de la clase Location", "[location]") {
       5           36 :     using nicole::Location;
       6           36 :     using std::filesystem::path;
       7              : 
       8           36 :     SECTION("Constructor y métodos de acceso") {
       9            9 :         const Location loc{"archivo.cpp", 5, 15};
      10            9 :         REQUIRE(loc.file() == path{"archivo.cpp"});
      11            9 :         REQUIRE(loc.row() == 5);
      12            9 :         REQUIRE(loc.col() == 15);
      13            9 :     }
      14              : 
      15           36 :     SECTION("Valores límite para fila y columna") {
      16            9 :         const Location loc{"archivo.cpp", 0, 0};
      17            9 :         REQUIRE(loc.row() == 0);
      18            9 :         REQUIRE(loc.col() == 0);
      19              : 
      20            9 :         const Location locMax{"archivo.cpp", std::numeric_limits<std::size_t>::max(), std::numeric_limits<std::size_t>::max()};
      21            9 :         REQUIRE(locMax.row() == std::numeric_limits<std::size_t>::max());
      22            9 :         REQUIRE(locMax.col() == std::numeric_limits<std::size_t>::max());
      23            9 :     }
      24              : 
      25           36 :     SECTION("Comparación de ubicaciones") {
      26            9 :         const Location loc1{"archivo.cpp", 5, 15};
      27            9 :         const Location loc2{"archivo.cpp", 5, 15};
      28            9 :         const Location loc3{"archivo.cpp", 6, 10};
      29              : 
      30            9 :         REQUIRE(loc1.file() == loc2.file());
      31            9 :         REQUIRE(loc1.row() == loc2.row());
      32            9 :         REQUIRE(loc1.col() == loc2.col());
      33              : 
      34            9 :         REQUIRE(loc1.file() == loc3.file());
      35            9 :         REQUIRE(loc1.row() != loc3.row());
      36            9 :         REQUIRE(loc1.col() != loc3.col());
      37            9 :     }
      38              : 
      39           36 :     SECTION("Ubicaciones en diferentes archivos") {
      40            9 :         const Location loc1{"archivo1.cpp", 5, 15};
      41            9 :         const Location loc2{"archivo2.cpp", 5, 15};
      42              : 
      43            9 :         REQUIRE(loc1.file() != loc2.file());
      44            9 :         REQUIRE(loc1.row() == loc2.row());
      45            9 :         REQUIRE(loc1.col() == loc2.col());
      46            9 :     }
      47           36 : }
        

Generated by: LCOV version 2.0-1