<commit_before>#include "TestIntegerEncodingInitializer.hpp"
#include "../include/IntegerEncodingInitializer.hpp"
#include "../include/Graph.hpp"
#include "../include/Vertex.hpp"
#include "../include/IntegerVectorEncoding.hpp"

CPPUNIT_TEST_SUITE_REGISTRATION(TestIntegerEncodingInitializer);

/**
 * @brief Sets up an encoding object with a sample graph
 */
void TestIntegerEncodingInitializer::setUp(void)
{
    g = new Graph();
    Vertex v0(0);
    Vertex v1(1);
    Vertex v2(2);
    Vertex v3(3);

    g->addVertex(v0);
    g->addVertex(v1);
    g->addVertex(v2);
    g->addVertex(v3);

    testObj1 = new IntegerEncodingInitializer(g, 3);
    testObj2 = new IntegerEncodingInitializer(g);
}

/**
 * @brief Deletes the sample object
 */
void TestIntegerEncodingInitializer::tearDown(void)
{
    delete testObj1;
    delete testObj2;
    delete g;
}

/**
 * @brief Test if getting random solution works
 */
void TestIntegerEncodingInitializer::testGetRandomSolution(void)
{
    IntegerVectorEncoding solution1 = testObj1->getRandomSolution();
    CPPUNIT_ASSERT(3 >= solution1.getClusterCount());

    IntegerVectorEncoding solution2 = testObj2->getRandomSolution();
    CPPUNIT_ASSERT(g->getNoVertices() >= solution2.getClusterCount());

    for (int v = 0; v < g->getNoVertices(); v++)
    {
        CPPUNIT_ASSERT(solution1.getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(solution1.getClusterOfVertex(v) < g->getNoVertices());

        CPPUNIT_ASSERT(solution2.getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(solution2.getClusterOfVertex(v) < g->getNoVertices());

    }


}

/**
 * @brief Test the normalization procedure and getEncoding
 */
void TestIntegerEncodingInitializer::testGetInitialPopulation(void)
{
    std::vector<IntegerVectorEncoding> population = testObj1->getInitialPopulation(5);
    CPPUNIT_ASSERT(5 == population.size());

    for (int i = 0; i < 5; i++)
    {
        for (int v = 0; v < g->getNoVertices(); v++)
        {
        CPPUNIT_ASSERT(population[i].getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(population[i].getClusterOfVertex(v) < g->getNoVertices());
        }

    }

}<commit_msg>fixed cppunit test<commit_after>#include "TestIntegerEncodingInitializer.hpp"
#include "../include/IntegerEncodingInitializer.hpp"
#include "../include/Graph.hpp"
#include "../include/Vertex.hpp"
#include "../include/IntegerVectorEncoding.hpp"

CPPUNIT_TEST_SUITE_REGISTRATION(TestIntegerEncodingInitializer);

/**
 * @brief Sets up an encoding object with a sample graph
 */
void TestIntegerEncodingInitializer::setUp(void)
{
    g = new Graph();
    Vertex v0(0);
    Vertex v1(1);
    Vertex v2(2);
    Vertex v3(3);

    g->addVertex(v0);
    g->addVertex(v1);
    g->addVertex(v2);
    g->addVertex(v3);

    testObj1 = new IntegerEncodingInitializer(g, 3);
    testObj2 = new IntegerEncodingInitializer(g);
}

/**
 * @brief Deletes the sample object
 */
void TestIntegerEncodingInitializer::tearDown(void)
{
    delete testObj1;
    delete testObj2;
    delete g;
}

/**
 * @brief Test if getting random solution works
 */
void TestIntegerEncodingInitializer::testGetRandomSolution(void)
{
    IntegerVectorEncoding solution1 = testObj1->getRandomSolution();
    CPPUNIT_ASSERT(3 >= solution1.getClusterCount());

    IntegerVectorEncoding solution2 = testObj2->getRandomSolution();
    CPPUNIT_ASSERT(g->getNoVertices() >= solution2.getClusterCount());

    for (int v = 0; v < g->getNoVertices(); v++)
    {
        CPPUNIT_ASSERT(solution1.getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(solution1.getClusterOfVertex(v) < 3);

        CPPUNIT_ASSERT(solution2.getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(solution2.getClusterOfVertex(v) < g->getNoVertices());

    }


}

/**
 * @brief Test the normalization procedure and getEncoding
 */
void TestIntegerEncodingInitializer::testGetInitialPopulation(void)
{
    std::vector<IntegerVectorEncoding> population = testObj1->getInitialPopulation(5);
    CPPUNIT_ASSERT(5 == population.size());

    for (int i = 0; i < 5; i++)
    {
        for (int v = 0; v < g->getNoVertices(); v++)
        {
        CPPUNIT_ASSERT(population[i].getClusterOfVertex(v) >= 0);
        CPPUNIT_ASSERT(population[i].getClusterOfVertex(v) < g->getNoVertices());
        }

    }

}
{'fraction_non_alphanumeric': 0.13536299765807963, 'fraction_numerical': 0.018032786885245903, 'mean_word_length': 4.06042654028436, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 40, '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': '7136482', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1330, 'n_words': 250}