<commit_before>#include <boost/test/unit_test.hpp>
#include <envire_maps/MultilayerGridMap.hpp>

using namespace envire::maps;

Vector2ui num_cells(100, 100);
Vector2d resolution(0.2, 0.5);

// the grid center is 20m x 50m
double offsetX = 10;
double offsetY = 25;

BOOST_AUTO_TEST_CASE(test_mlgridmap_default_constructor)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap();   

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), Vector2ui(0, 0));
    BOOST_CHECK_EQUAL(grid_map->getResolution(), Vector2d(0, 0));    
    BOOST_CHECK_EQUAL(grid_map->getSize(), Vector2d(0, 0));     

    BOOST_CHECK_EQUAL(grid_map->getOffset().matrix().isApprox(base::Transform3d::Identity().matrix()), true); 

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_mlgridmap_constructor)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    Eigen::Vector3d translation = Eigen::Vector3d::Random(3);
    grid_map->getOffset().translate(translation);

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), num_cells);
    BOOST_CHECK_EQUAL(grid_map->getResolution(), resolution);    
    BOOST_CHECK_EQUAL(grid_map->getSize(), Vector2d(20, 50));     

    BOOST_CHECK_EQUAL(grid_map->getOffset().translation().isApprox(translation), true); 

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_mlgridmap_share_properties)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    grid_map->getId() = "first";

    Eigen::Vector3d translation = Eigen::Vector3d::Random(3);
    grid_map->getOffset().translate(translation);

    // the underlying layers should share the properties with MultilayerGridMap
    grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity());

    GridMap<double> &grid = grid_map->getLayer<double>("double_grid");

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), grid.getNumCells());
    BOOST_CHECK_EQUAL(grid_map->getResolution(), grid.getResolution());       
    BOOST_CHECK_EQUAL(grid_map->getId(), grid.getId());      
    BOOST_CHECK_EQUAL(grid_map->getOffset().matrix().isApprox(grid.getOffset().matrix()), true);     

    // change of the properties should apply to MultilayerGridMap
    // and its underlying layers
    grid_map->getId() = "grid_map";

    BOOST_CHECK_EQUAL(grid_map->getId(), "grid_map");    
    BOOST_CHECK_EQUAL(grid.getId(), "grid_map"); 

    grid.getId() = "grid";
    BOOST_CHECK_EQUAL(grid_map->getId(), "grid");    
    BOOST_CHECK_EQUAL(grid.getId(), "grid");     

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_gridmap_has)
{   
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);
     
    // check if the not existed grid exists: false
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), false);

    // check if the existed grid exists: true
    grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity());
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), true);

    GridMap<double> &grid = grid_map->getLayer<double>("double_grid");

    // check if the existence of the grid after it was removed
    grid_map->removeLayer("double_grid"); 
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), false);  

    delete grid_map;
}

BOOST_AUTO_TEST_CASE(test_gridmap_add)
{   
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    // add grid that does not exist until now: OK
    BOOST_CHECK_NO_THROW(grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity())); 

    // add grid with the key existed already and of the same type: THROW
    BOOST_CHECK_THROW(grid_map->addLayer<double>("double_grid",  std::numeric_limits<double>::infinity()), std::exception);

    // add grid with the key existed already but of the different type: THROW
    BOOST_CHECK_THROW(grid_map->addLayer<int>("double_grid",  std::numeric_limits<int>::infinity()), std::exception);
<commit_msg>test: remove warning<commit_after>#include <boost/test/unit_test.hpp>
#include <envire_maps/MultilayerGridMap.hpp>

using namespace envire::maps;

Vector2ui num_cells(100, 100);
Vector2d resolution(0.2, 0.5);

// the grid center is 20m x 50m
double offsetX = 10;
double offsetY = 25;

BOOST_AUTO_TEST_CASE(test_mlgridmap_default_constructor)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap();   

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), Vector2ui(0, 0));
    BOOST_CHECK_EQUAL(grid_map->getResolution(), Vector2d(0, 0));    
    BOOST_CHECK_EQUAL(grid_map->getSize(), Vector2d(0, 0));     

    BOOST_CHECK_EQUAL(grid_map->getOffset().matrix().isApprox(base::Transform3d::Identity().matrix()), true); 

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_mlgridmap_constructor)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    Eigen::Vector3d translation = Eigen::Vector3d::Random(3);
    grid_map->getOffset().translate(translation);

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), num_cells);
    BOOST_CHECK_EQUAL(grid_map->getResolution(), resolution);    
    BOOST_CHECK_EQUAL(grid_map->getSize(), Vector2d(20, 50));     

    BOOST_CHECK_EQUAL(grid_map->getOffset().translation().isApprox(translation), true); 

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_mlgridmap_share_properties)
{
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    grid_map->getId() = "first";

    Eigen::Vector3d translation = Eigen::Vector3d::Random(3);
    grid_map->getOffset().translate(translation);

    // the underlying layers should share the properties with MultilayerGridMap
    grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity());

    GridMap<double> &grid = grid_map->getLayer<double>("double_grid");

    BOOST_CHECK_EQUAL(grid_map->getNumCells(), grid.getNumCells());
    BOOST_CHECK_EQUAL(grid_map->getResolution(), grid.getResolution());       
    BOOST_CHECK_EQUAL(grid_map->getId(), grid.getId());      
    BOOST_CHECK_EQUAL(grid_map->getOffset().matrix().isApprox(grid.getOffset().matrix()), true);     

    // change of the properties should apply to MultilayerGridMap
    // and its underlying layers
    grid_map->getId() = "grid_map";

    BOOST_CHECK_EQUAL(grid_map->getId(), "grid_map");    
    BOOST_CHECK_EQUAL(grid.getId(), "grid_map"); 

    grid.getId() = "grid";
    BOOST_CHECK_EQUAL(grid_map->getId(), "grid");    
    BOOST_CHECK_EQUAL(grid.getId(), "grid");     

    delete grid_map;        
}

BOOST_AUTO_TEST_CASE(test_gridmap_has)
{   
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);
     
    // check if the not existed grid exists: false
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), false);

    // check if the existed grid exists: true
    grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity());
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), true);

    GridMap<double> &grid = grid_map->getLayer<double>("double_grid");

    // check if the existence of the grid after it was removed
    grid_map->removeLayer("double_grid"); 
    BOOST_CHECK_EQUAL(grid_map->hasLayer("double_grid"), false);
    BOOST_CHECK_EQUAL(grid.getId(), DEFAULT_GRID_MAP_ID);

    delete grid_map;
}

BOOST_AUTO_TEST_CASE(test_gridmap_add)
{   
    MultilayerGridMap *grid_map = new MultilayerGridMap(num_cells, resolution);

    // add grid that does not exist until now: OK
    BOOST_CHECK_NO_THROW(grid_map->addLayer<double>("double_grid", std::numeric_limits<double>::infinity())); 

    // add grid with the key existed already and of the same type: THROW
    BOOST_CHECK_THROW(grid_map->addLayer<double>("double_grid",  std::numeric_limits<double>::infinity()), std::exception);

    // add grid with the key existed already but of the different type: THROW
    BOOST_CHECK_THROW(grid_map->addLayer<int>("double_grid",  std::numeric_limits<int>::infinity()), std::exception);

{'fraction_non_alphanumeric': 0.13167483352179923, 'fraction_numerical': 0.010302801859530092, 'mean_word_length': 4.975975975975976, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7226065', 'n_tokens_mistral': 2675, 'n_tokens_neox': 2532, 'n_words': 444}