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

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

#include <QDebug>
class MockGroup : public gpsbip::OptionsGroupBase
{
    Q_OBJECT
    Q_PROPERTY(int stubOption READ getStubOption WRITE setStubOption NOTIFY stubOptionChanged)

public:
    MockGroup() {
        opt = addOption(new gpsbip::BoolOption());
    }

    bool getStubOption() { return get<gpsbip::BoolOption>(opt); }
    void setStubOption(bool v) { get<gpsbip::BoolOption>(opt) = v; emit stubOptionChanged(); }

signals:
    void stubOptionChanged();

private:
    int opt;
};

class Tst_optionsGroups : public QObject
{
    Q_OBJECT

public:
    Tst_optionsGroups();

private Q_SLOTS:
    void testOptionGroupMechanic();
};

Tst_optionsGroups::Tst_optionsGroups()
{
}

void Tst_optionsGroups::testOptionGroupMechanic()
{
    MockGroup g;
    g.setStubOption(true);
    QCOMPARE(g.getStubOption(), true);

    g.setProperty("stubOption", false);
    QCOMPARE(g.property("stubOption").toBool(), false);
}

QTEST_APPLESS_MAIN(Tst_optionsGroups)

#include "tst_optionsgroups.moc"<commit_msg>Updated Tst_optionsGroups::testOptionGroupMechanic to validates all the base group related constructs<commit_after>#include <QString>
#include <QtTest>

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

class MockGroup : public gpsbip::OptionsGroupBase
{
    Q_OBJECT

public:
    MockGroup() {
        auto r = new gpsbip::BoolOption();
        root = addOption(r);
        opt = addOption<gpsbip::BoolOption>("label");
        strOpt = addOption<gpsbip::StringOption>(*r, "label");
    }

    gpsbip::BoolOption* getRootOption() { return &get<gpsbip::BoolOption>(root); }
    gpsbip::BoolOption* getOption() { return &get<gpsbip::BoolOption>(opt); }
    gpsbip::StringOption* getStrOption() { return &get<gpsbip::StringOption>(strOpt); }

private:
    int root, opt, strOpt;
};

class Tst_optionsGroups : public QObject
{
    Q_OBJECT

public:
    Tst_optionsGroups();

private Q_SLOTS:
    void testOptionGroupMechanic();
};

Tst_optionsGroups::Tst_optionsGroups()
{
}

void Tst_optionsGroups::testOptionGroupMechanic()
{
    // Validates all 3 addOption variants
    MockGroup g;

    // Validates get<>
    gpsbip::BoolOption *root = g.getRootOption();
    QVERIFY(root != nullptr);
    gpsbip::BoolOption *opt = g.getOption();
    QVERIFY(opt != nullptr);
}

QTEST_APPLESS_MAIN(Tst_optionsGroups)

#include "tst_optionsgroups.moc"
{'fraction_non_alphanumeric': 0.12520064205457465, 'fraction_numerical': 0.0004012841091492777, 'mean_word_length': 4.879716981132075, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '416247', 'n_tokens_mistral': 877, 'n_tokens_neox': 879, 'n_words': 158}