File: readerxdxftest.cpp

package info (click to toggle)
libkeduvocdocument 4%3A16.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 948 kB
  • ctags: 1,086
  • sloc: cpp: 7,995; sh: 16; makefile: 10
file content (99 lines) | stat: -rw-r--r-- 2,756 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 Copyright 2014 Andreas Xavier <andxav at zoho dot com>

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA
*/

#include "keduvocdocument.h"
#include "readermanager.h"
#include "keduvocxdxfreader.h"

#include "readerTestHelpers.h"

#include <qdebug.h>
#include <QtTest>

namespace XdxfReaderUnitTests
{

/**
 * @file Unit Tests of parsing of Xdxf strings
 *
 * Each test creates a QString of Xdxf format
 * reads, parses and verifies the parse.  The portions of the
 * generator object relevant to each test are defined in this file.
 *
 * The current tests are cursory.
 * @todo add check to verify that the words are actually in the kvocdocument
 * */

/**
 * @brief Unit Tests of parsing of Xdxf strings
 *
 * Each test creates a string
 * reads, parses and verifies the parse.
 * */

class XdxfReaderTest : public QObject
{
    Q_OBJECT

private slots:
    /** Initialize the string*/
    void init();
    /** Two word doc*/
    void testParseTwoWord();
    /** InvalidDoc*/
    void testParseInvalid();
private :
    QString oneGoodDoc;
    KEduVocDocument::FileType myType;
};

void XdxfReaderTest::init() {
    oneGoodDoc = \
                 QString( "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" )
                 + "<!DOCTYPE xdxf SYSTEM \"http://xdxf.sourceforge.net/xdxf_lousy.dtd\">\n"
                 + "<xdxf lang_from=\"GER\" lang_to=\"SPA\" format=\"visual\">\net"
                 + "<full_name>German Spanish</full_name>\n"
                 + "<description>Description of German and Spanish</description>\n"
                 + ""
                 + "<ar><k>Hund</k>el perro</ar>\n"
                 + "<ar><k>Schwein</k>el cerdo</ar>\n"
                 + "</xdxf>\n";
    myType = KEduVocDocument::Xdxf;
}


void XdxfReaderTest::testParseTwoWord()
{
    KVOCREADER_EXPECT( oneGoodDoc ,  KEduVocDocument::NoError ,  myType);
}

void XdxfReaderTest::testParseInvalid()
{
    QString invalid = oneGoodDoc +" bad parse";

    KVOCREADER_EXPECT( invalid ,  KEduVocDocument::FileReaderFailed ,  myType );
}

}

QTEST_MAIN( XdxfReaderUnitTests::XdxfReaderTest )



#include "readerxdxftest.moc"