<commit_before>#define BOOST_TEST_MODULE SerializationTest
#include <boost/test/unit_test.hpp>

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

/** Based local map **/
#include <maps/grid/MLSMap.hpp>

using namespace ::maps::grid;

BOOST_AUTO_TEST_CASE(test_mls_surfacepatchbase_serialization)
{
    SurfacePatchBase sp_o(0.5, 1.3);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatchBase sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());
}


BOOST_AUTO_TEST_CASE(test_mls_surfacepatchslope_serialization)
{
    SurfacePatch<MLSConfig::SLOPE> sp_o(Eigen::Vector3f(-3.2, 2.5, -4.5), 4.6);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatch<MLSConfig::SLOPE> sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());

    BOOST_CHECK(sp_i. getCenter() == sp_o. getCenter()); 
    BOOST_CHECK(sp_i.getNormal() == sp_o.getNormal());
}

BOOST_AUTO_TEST_CASE(test_mls_surfacepatchkalman_serialization)
{
    SurfacePatch<MLSConfig::KALMAN> sp_o(Eigen::Vector3f(-3.2, 2.5, -4.5), 4.6);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatch<MLSConfig::KALMAN> sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());

    BOOST_CHECK(sp_i. getCenter() == sp_o. getCenter()); 
    BOOST_CHECK(sp_i.getNormal() == sp_o.getNormal());
}

BOOST_AUTO_TEST_CASE(test_mls_serialization)
{
    //    GridConfig conf(300, 300, 0.05, 0.05, -7.5, -7.5);
    Vector2d res(0.05, 0.05);
    Vector2ui numCells(300, 300);

    MLSConfig mls_config;
    mls_config.updateModel = MLSConfig::SLOPE;
    //mls_config.updateModel = MLSConfig::KALMAN;
    MLSMapSloped mls_o = MLSMapSloped(numCells, res, mls_config);

    /** Translate the local frame (offset) **/
    mls_o.getLocalFrame().translation() << 0.5*mls_o.getSize(), 0;


    for (unsigned int x = 0; x < numCells.x(); ++x) for(float dx = -.5f; dx <0.49f; dx+=0.125)
    {
        float xx = x+dx-numCells.x()/2;
        float cs = std::cos(xx * M_PI/50);
        for (unsigned int y = 0; y < numCells.y(); ++y) for (float dy = -0.5f; dy<0.49; dy+=0.125)
        {
            float yy = y+dy-numCells.y()/2;
            float sn = std::sin(yy* M_PI/50);

            mls_o.mergePoint(Eigen::Vector3d(xx*res.x(), yy*res.y(), cs*sn));
        }
    }

    std::stringstream stream;<commit_msg>Fixed (and simplified) unit test<commit_after>#define BOOST_TEST_MODULE SerializationTest
#include <boost/test/unit_test.hpp>

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

/** Based local map **/
#include <maps/grid/MLSMap.hpp>

using namespace ::maps::grid;

BOOST_AUTO_TEST_CASE(test_mls_surfacepatchbase_serialization)
{
    SurfacePatchBase sp_o(0.5, 1.3);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatchBase sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());
}


BOOST_AUTO_TEST_CASE(test_mls_surfacepatchslope_serialization)
{
    SurfacePatch<MLSConfig::SLOPE> sp_o(Eigen::Vector3f(-3.2, 2.5, -4.5), 4.6);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatch<MLSConfig::SLOPE> sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());

    BOOST_CHECK(sp_i. getCenter() == sp_o. getCenter()); 
    BOOST_CHECK(sp_i.getNormal() == sp_o.getNormal());
}

BOOST_AUTO_TEST_CASE(test_mls_surfacepatchkalman_serialization)
{
    SurfacePatch<MLSConfig::KALMAN> sp_o(Eigen::Vector3f(-3.2, 2.5, -4.5), 4.6);

    std::stringstream stream;
    boost::archive::binary_oarchive oa(stream);
    oa << sp_o;

    // deserialize from string stream
    boost::archive::binary_iarchive *ia = new boost::archive::binary_iarchive(stream);
    SurfacePatch<MLSConfig::KALMAN> sp_i;
    (*ia) >> sp_i;

    BOOST_CHECK(sp_i.getMin() == sp_o.getMin()); 
    BOOST_CHECK(sp_i.getMax() == sp_o.getMax());
    BOOST_CHECK(sp_i.getTop() == sp_o.getTop());
    BOOST_CHECK(sp_i.getBottom() == sp_o.getBottom());

    BOOST_CHECK(sp_i. getCenter() == sp_o. getCenter()); 
    BOOST_CHECK(sp_i.getNormal() == sp_o.getNormal());
}

BOOST_AUTO_TEST_CASE(test_mls_serialization)
{
    //    GridConfig conf(300, 300, 0.05, 0.05, -7.5, -7.5);
    Vector2d res(0.05, 0.05);
    Vector2ui numCells(300, 300);

    MLSConfig mls_config;
    mls_config.updateModel = MLSConfig::SLOPE;
    //mls_config.updateModel = MLSConfig::KALMAN;
    MLSMapSloped mls_o = MLSMapSloped(numCells, res, mls_config);

    /** Translate the local frame (offset) **/
    mls_o.getLocalFrame().translation() << 0.5*mls_o.getSize(), 0;


    Eigen::Vector2d max = 0.5 * mls_o.getSize();
    Eigen::Vector2d min = -0.5 * mls_o.getSize();
    for (double x = min.x(); x < max.x(); x += 0.00625)
    {
        double cs = std::cos(x * M_PI/2.5);
        for (double y = min.y(); y < max.y(); y += 0.00625)
        {
            double sn = std::sin(y * M_PI/2.5);
            mls_o.mergePoint(Eigen::Vector3d(x, y, cs*sn));
        }
    }

    std::stringstream stream;
{'fraction_non_alphanumeric': 0.16656617425384385, 'fraction_numerical': 0.023967440458245403, 'mean_word_length': 3.885861561119293, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 31, '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': '125241', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2531, 'n_words': 399}