<commit_before>#include <QString>
#include <QtTest>

#include <libgpsbip/OptionBase.h>
#include <libgpsbip/OptionTypes.h>

class Tst_options : public QObject
{
    Q_OBJECT

public:
    Tst_options();

private Q_SLOTS:
    // OptionBase tests
    void testOptionBaseEnabledProperty();

    // Typed options tests
    void testStringOption();
    void testBoolOption();
};

Tst_options::Tst_options()
{
}

void Tst_options::testOptionBaseEnabledProperty()
{
    struct OptionStub : gpsbip::OptionBase { };
    OptionStub opt;
    opt.setEnabled(true);
    QCOMPARE(opt.isEnabled(), true);

    opt.setEnabled(false);
    QCOMPARE(opt.property("enabled").toBool(), false);
}

void Tst_options::testStringOption()
{
    bool valueChanged = false;
    gpsbip::StringOption opt;
    connect(&opt, &gpsbip::StringOption::valueChanged, [&valueChanged] () { valueChanged = true; });
    opt = "test";

    QCOMPARE(static_cast<QString>(opt), QString("test"));
    QCOMPARE(valueChanged, true);

    valueChanged = false;
    opt = "test";
    QCOMPARE(valueChanged, false);
}

void Tst_options::testBoolOption()<commit_msg>Added test validating enabler feature<commit_after>#include <QString>
#include <QtTest>

#include <libgpsbip/OptionBase.h>
#include <libgpsbip/OptionTypes.h>

class Tst_options : public QObject
{
    Q_OBJECT

public:
    Tst_options();

private Q_SLOTS:
    // OptionBase tests
    void testOptionBaseEnabledProperty();
    void testOptionBaseEnabler();

    // Typed options tests
    void testStringOption();
    void testBoolOption();
};

Tst_options::Tst_options()
{
}

void Tst_options::testOptionBaseEnabledProperty()
{
    struct OptionStub : gpsbip::OptionBase { };
    OptionStub opt;
    opt.setEnabled(true);
    QCOMPARE(opt.isEnabled(), true);

    opt.setEnabled(false);
    QCOMPARE(opt.property("enabled").toBool(), false);
}

void Tst_options::testOptionBaseEnabler()
{
    gpsbip::BoolOption root;

    gpsbip::BoolOption dependant;
    dependant.dependsOn(root);

    QCOMPARE(dependant.isEnabled(), false);

    root = true;
    QCOMPARE(dependant.isEnabled(), true);

    root = false;
    QCOMPARE(dependant.isEnabled(), false);
}

void Tst_options::testStringOption()
{
    bool valueChanged = false;
    gpsbip::StringOption opt;
    connect(&opt, &gpsbip::StringOption::valueChanged, [&valueChanged] () { valueChanged = true; });
    opt = "test";

    QCOMPARE(static_cast<QString>(opt), QString("test"));
    QCOMPARE(valueChanged, true);

    valueChanged = false;
    opt = "test";
    QCOMPARE(valueChanged, false);
}

void Tst_options::testBoolOption()
{'fraction_non_alphanumeric': 0.13389765294343978, 'fraction_numerical': 0.0, 'mean_word_length': 4.450733752620545, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4257691', 'n_tokens_mistral': 879, 'n_tokens_neox': 870, 'n_words': 158}