1
/***************************************************************************
2
* Copyright (C) 2004 by Daniel Rocher *
3
* daniel.rocher@adella.org *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
22
#include <QtTest/QtTest>
23
#include "utestlinecore.h"
25
void UtestLineCore::initTestCase() {
26
col m_cols0= { "PID", "3456", 8};
27
col m_cols1= { "Username", "robert Gas", 14};
28
col m_cols2= { "Group", "etude 5519", 14};
29
col m_cols3= { "Machine", "etude1 (192.168.1.1)", 31};
31
cols << m_cols0 << m_cols1 << m_cols2 << m_cols3;
34
for (int i = 0; i < cols.size(); ++i)
35
header.append(QString("%1").arg(cols.at(i).name, - cols.at(i).fieldWidth));
37
// qDebug() << header;
38
linecore.InitHeader(header);
41
void UtestLineCore::InitElement() {
42
for (int i = 0; i < cols.size(); ++i)
43
QCOMPARE(linecore.InitElement(cols.at(i).name),i);
46
void UtestLineCore::ReturnElement_data()
48
QTest::addColumn<QString>("aRow");
49
QTest::addColumn<QString>("col1");
50
QTest::addColumn<QString>("col2");
51
QTest::addColumn<QString>("col3");
52
QTest::addColumn<QString>("col4");
55
for (int j = -9; j <= 2 ; ++j) { // change fields size
57
for (int i = 0; i < cols.size(); ++i)
58
line.append(QString("%1").arg(cols.at(i).data, j - (cols.at(i).fieldWidth)));
60
QTest::newRow("test row") << line << cols.at(0).data << cols.at(1).data << cols.at(2).data << cols.at(3).data;
64
void UtestLineCore::ReturnElement()
66
QFETCH(QString, aRow);
67
QFETCH(QString, col1);
68
QFETCH(QString, col2);
69
QFETCH(QString, col3);
70
QFETCH(QString, col4);
72
linecore.Analysis(aRow);
73
QCOMPARE(linecore.ReturnElement(0), col1);
74
QCOMPARE(linecore.ReturnElement(1), col2);
75
QCOMPARE(linecore.ReturnElement(2), col3);
76
QCOMPARE(linecore.ReturnElement(3), col4);
77
QCOMPARE(linecore.ReturnElement(cols.at(0).name), col1);
78
QCOMPARE(linecore.ReturnElement(cols.at(1).name), col2);
79
QCOMPARE(linecore.ReturnElement(cols.at(2).name), col3);
80
QCOMPARE(linecore.ReturnElement(cols.at(3).name), col4);