~vcs-imports/qtsmbstatus/trunk

« back to all changes in this revision

Viewing changes to utest/utestlinecore.cpp

  • Committer: rocher.daniel
  • Date: 2011-01-25 14:07:01 UTC
  • Revision ID: rocher.daniel-20110125140701-w9cvywjrdl9aqp9g
Add a warning file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2004 by Daniel Rocher                                   *
3
 
 *   daniel.rocher@adella.org                                              *
4
 
 *                                                                         *
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.                                   *
9
 
 *                                                                         *
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.                          *
14
 
 *                                                                         *
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
 
 ***************************************************************************/
20
 
 
21
 
 
22
 
#include <QtTest/QtTest>
23
 
#include "utestlinecore.h"
24
 
 
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};
30
 
 
31
 
        cols <<  m_cols0 << m_cols1 << m_cols2 << m_cols3;
32
 
        
33
 
        QString header;
34
 
        for (int i = 0; i < cols.size(); ++i)
35
 
                header.append(QString("%1").arg(cols.at(i).name, - cols.at(i).fieldWidth));
36
 
 
37
 
        // qDebug() << header;
38
 
        linecore.InitHeader(header);
39
 
}
40
 
 
41
 
void UtestLineCore::InitElement() {
42
 
        for (int i = 0; i < cols.size(); ++i)
43
 
                QCOMPARE(linecore.InitElement(cols.at(i).name),i);
44
 
}
45
 
 
46
 
void UtestLineCore::ReturnElement_data()
47
 
{
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");
53
 
 
54
 
        QString line;
55
 
        for (int j = -9; j <= 2 ; ++j) { // change fields size
56
 
                line.clear();
57
 
                for (int i = 0; i < cols.size(); ++i)
58
 
                        line.append(QString("%1").arg(cols.at(i).data, j - (cols.at(i).fieldWidth)));
59
 
                // qDebug() << line;
60
 
                QTest::newRow("test row") << line << cols.at(0).data << cols.at(1).data << cols.at(2).data << cols.at(3).data;
61
 
        }
62
 
}
63
 
 
64
 
void UtestLineCore::ReturnElement()
65
 
{
66
 
        QFETCH(QString, aRow);
67
 
        QFETCH(QString, col1);
68
 
        QFETCH(QString, col2);
69
 
        QFETCH(QString, col3);
70
 
        QFETCH(QString, col4);
71
 
 
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);
81
 
}
82
 
 
83