<commit_before>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "memorybenchmark.h"
#include "memorybenchmark.inl"
#include "mt_mbuttongroup.h"

#include <MButton>
#include <MButtonGroup>
#include <MApplication>

MApplication *app;

void Mt_MButtonGroup::initTestCase()
{
    int argc = 1;
    char *app_name = (char *) "./mt_mbuttongroup";
    app = new MApplication(argc, &app_name);
}

void Mt_MButtonGroup::cleanupTestCase()
{
    delete app;
}

void Mt_MButtonGroup::memoryBenchmark_data()
{
    QTest::addColumn<int>("buttonCount");

    QTest::newRow("0 buttons") << 0;
    QTest::newRow("1 buttons") << 1;
    QTest::newRow("2 buttons") << 2;
    QTest::newRow("10 buttons") << 10;
    QTest::newRow("20 buttons") << 20;
    QTest::newRow("50 buttons") << 50;
    QTest::newRow("100 buttons") << 100;
}

void Mt_MButtonGroup::memoryBenchmark()
{
    QFETCH(int, buttonCount);

    MButton **buttons = new MButton*[buttonCount];

    beginMemoryBenchmark();

    MButtonGroup *buttonGroup = new MButtonGroup();

    for (int i = 0; i < buttonCount; ++i) {
        buttons[i] = new MButton();
        buttons[i]->setCheckable(true);
        buttonGroup->addButton(buttons[i]);
    }

    outputAllocatedMemorySize();

    for (int i = 0; i < buttonCount; ++i) {
        delete buttons[i];
    }

    delete buttonGroup;

    endMemoryBenchmark();

    delete buttons;
}

QTEST_APPLESS_MAIN(Mt_MButtonGroup)<commit_msg>Changes: Fix coverity issue 6<commit_after>/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (<EMAIL>)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at <EMAIL>.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "memorybenchmark.h"
#include "memorybenchmark.inl"
#include "mt_mbuttongroup.h"

#include <MButton>
#include <MButtonGroup>
#include <MApplication>

MApplication *app;

void Mt_MButtonGroup::initTestCase()
{
    int argc = 1;
    char *app_name = (char *) "./mt_mbuttongroup";
    app = new MApplication(argc, &app_name);
}

void Mt_MButtonGroup::cleanupTestCase()
{
    delete app;
}

void Mt_MButtonGroup::memoryBenchmark_data()
{
    QTest::addColumn<int>("buttonCount");

    QTest::newRow("0 buttons") << 0;
    QTest::newRow("1 buttons") << 1;
    QTest::newRow("2 buttons") << 2;
    QTest::newRow("10 buttons") << 10;
    QTest::newRow("20 buttons") << 20;
    QTest::newRow("50 buttons") << 50;
    QTest::newRow("100 buttons") << 100;
}

void Mt_MButtonGroup::memoryBenchmark()
{
    QFETCH(int, buttonCount);

    QList<MButton*> buttons;

    beginMemoryBenchmark();

    MButtonGroup *buttonGroup = new MButtonGroup();

    for (int i = 0; i < buttonCount; ++i) {
        buttons.append( new MButton );
        buttons[i]->setCheckable(true);
        buttonGroup->addButton(buttons[i]);
    }

    outputAllocatedMemorySize();

    for (int i = 0; i < buttonCount; ++i) {
        delete buttons[i];
    }

    delete buttonGroup;

    endMemoryBenchmark();
}

QTEST_APPLESS_MAIN(Mt_MButtonGroup)
{'fraction_non_alphanumeric': 0.20043103448275862, 'fraction_numerical': 0.016044061302681992, 'mean_word_length': 4.410621761658031, 'pattern_counts': {'":': 0, '<': 48, '<?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': '6879875', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1246, 'n_words': 353}