<commit_before>#include "tst_configuration.h"

void TST_Configuration::test()
{
    QString path(QDir::currentPath() + "/server");
    if(!QDir(path).exists())
        QVERIFY2(QDir().mkdir(path), "Could not create server folder");
    if(!QDir(path + "/config").exists())
        QVERIFY2(QDir().mkdir(path + "/config"), "Could not create server config");
    QFile file(path + "/config/CPPWeb.ini");
    QVERIFY2(file.open(QIODevice::WriteOnly), "Could not create CPPWeb.ini file");

    file.write("[config]\n");
    file.write("host=127.0.0.1\n");
    file.write("port=8080\n");
    file.write("maxThread=200\n");
    file.write("cleanupInterval=60000\n");
    file.write("timeOut=60000\n");
    file.write("sessionExpirationTime=6000\n");
    file.write("maxUploadFile=20971520\n");
    file.write("path=" + path.toLatin1() + "\n");
    file.write("suffix=.xhtml\n");
    file.write("logFilePath=/config/log/\n");
    file.write("sslKeyFile=/config/ssl/my.key\n");
    file.write("sslCertFile=/config/ssl/my.cert\n");
    file.write("indexPage=/config/cppwebserverpages/index\n");
    file.write("accessCPPWebIni=false\n");
    file.write("accessServerPages=true");

    file.close();


    CWF::Configuration configuration(path);
    QVERIFY2(configuration.getHost().toString() == "127.0.0.1", "Should be Any");
    QVERIFY2(configuration.getPort() == 8080, "Should be 8080");
    QVERIFY2(configuration.getMaxThread() == 200, "Should be 200");
    QVERIFY2(configuration.getCleanupInterval() == 60000, "Should return 60000");
    QVERIFY2(configuration.getTimeOut() == 60000, "Should return 60000");
    QVERIFY2(configuration.getSessionExpirationTime() == 6000, "Should return 6000");
    QVERIFY2(configuration.getMaxUploadFile() == 20971520, "Should return 20971520");
    QVERIFY2(configuration.getPath() == path, QString("Should be " + path).toStdString().data());
    QVERIFY2(configuration.getLogFilePath().endsWith("log") == true, "Should be true");
    QVERIFY2(configuration.getSslCertFile().endsWith("my.cert") == true, "Should be true");
    QVERIFY2(configuration.getSslKeyFile().endsWith("my.key") == true, "Should be true");
}<commit_msg>New test for Configuration<commit_after>#include "tst_configuration.h"

void TST_Configuration::test()
{
    QString path(QDir::currentPath() + "/server");
    if(!QDir(path).exists())
        QVERIFY2(QDir().mkdir(path), "Could not create server folder");
    if(!QDir(path + "/config").exists())
        QVERIFY2(QDir().mkdir(path + "/config"), "Could not create server config");
    QFile file(path + "/config/CPPWeb.ini");
    QVERIFY2(file.open(QIODevice::WriteOnly), "Could not create CPPWeb.ini file");

    file.write("[config]\n");
    file.write("host=127.0.0.1\n");
    file.write("port=8080\n");
    file.write("maxThread=200\n");
    file.write("cleanupInterval=60000\n");
    file.write("timeOut=60000\n");
    file.write("sessionExpirationTime=6000\n");
    file.write("maxUploadFile=20971520\n");
    file.write("path=" + path.toLatin1() + "\n");
    file.write("suffix=.xhtml\n");
    file.write("logFilePath=/config/log/\n");
    file.write("sslKeyFile=/config/ssl/my.key\n");
    file.write("sslCertFile=/config/ssl/my.cert\n");
    file.write("indexPage=/config/cppwebserverpages/index\n");
    file.write("accessCPPWebIni=false\n");
    file.write("accessServerPages=true");

    file.close();


    CWF::Configuration configuration(path);
    QVERIFY2(configuration.getHost().toString() == "127.0.0.1", "Should be Any");
    QVERIFY2(configuration.getPort() == 8080, "Should be 8080");
    QVERIFY2(configuration.getMaxThread() == 200, "Should be 200");
    QVERIFY2(configuration.getCleanupInterval() == 60000, "Should return 60000");
    QVERIFY2(configuration.getTimeOut() == 60000, "Should return 60000");
    QVERIFY2(configuration.getSessionExpirationTime() == 6000, "Should return 6000");
    QVERIFY2(configuration.getMaxUploadFile() == 20971520, "Should return 20971520");
    QVERIFY2(configuration.getPath() == path, QString("Should be " + path).toStdString().data());
    QVERIFY2(configuration.getLogFilePath().endsWith("log") == true, "Should be true");
    QVERIFY2(configuration.getSslCertFile().endsWith("my.cert") == true, "Should be true");
    QVERIFY2(configuration.getSslKeyFile().endsWith("my.key") == true, "Should be true");

    QVERIFY2(file.remove(), "Should return true");

    CWF::Configuration conf("");
    QVERIFY2(conf.isValid() == false, "Shoud return false.");
}
{'fraction_non_alphanumeric': 0.1883508145503236, 'fraction_numerical': 0.051327828609685336, 'mean_word_length': 4.783225806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3302280', 'n_tokens_mistral': 1638, 'n_tokens_neox': 1478, 'n_words': 230}