2
* This file is part of Soprano Project.
4
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public License
17
* along with this library; see the file COPYING.LIB. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
22
#include "errortest.h"
23
#include "../soprano/error.h"
24
#include "../soprano/locator.h"
26
#include <QtTest/QTest>
27
#include <QtCore/QDebug>
29
using namespace Soprano::Error;
31
void ErrorTest::testErrorCopy()
36
QCOMPARE( e1.message(), QString( "e1" ) );
37
QCOMPARE( e1.code(), 2 );
39
QCOMPARE( e1.message(), e2.message() );
40
QCOMPARE( e1.code(), e2.code() );
43
void ErrorTest::testOperator()
48
QCOMPARE( e1.message(), e2.message() );
49
QCOMPARE( e1.code(), e2.code() );
52
error = Error( "test error" );
54
QCOMPARE( error.message(), QString( "test error" ) );
55
QCOMPARE( error.code(), ( int )error.code() );
59
static const int line = 4;
60
static const int col = 9;
62
void ErrorTest::testParserErrorCopy()
64
ParserError p1( Locator( line, col ), "p1" );
67
QCOMPARE( p1.message(), QString( "p1" ) );
68
QCOMPARE( p1.code(), ( int )Soprano::Error::ErrorParsingFailed );
69
QCOMPARE( p1.locator().line(), line );
70
QCOMPARE( p1.locator().column(), col );
72
QCOMPARE( p1.message(), p2.message() );
73
QCOMPARE( p1.code(), p2.code() );
74
QCOMPARE( p1.locator().line(), p2.locator().line() );
75
QCOMPARE( p1.locator().column(), p2.locator().column() );
78
void ErrorTest::testParserErrorOperator()
80
ParserError p1( Locator( line, col ), "p1" );
83
QCOMPARE( p1.message(), QString( "p1" ) );
84
QCOMPARE( p1.code(), ( int )Soprano::Error::ErrorParsingFailed );
85
QCOMPARE( p1.locator().line(), line );
86
QCOMPARE( p1.locator().column(), col );
88
QCOMPARE( p1.message(), p2.message() );
89
QCOMPARE( p1.code(), p2.code() );
90
QCOMPARE( p1.locator().line(), p2.locator().line() );
91
QCOMPARE( p1.locator().column(), p2.locator().column() );
94
void ErrorTest::testParserErrorConversion()
96
ParserError p1( Locator( line, col ), "p1" );
99
QCOMPARE( p1.message(), ep1.message() );
100
QCOMPARE( p1.code(), ep1.code() );
102
ParserError pep1 = ep1;
104
QCOMPARE( p1.message(), pep1.message() );
105
QCOMPARE( p1.code(), pep1.code() );
106
QCOMPARE( p1.locator().line(), pep1.locator().line() );
107
QCOMPARE( p1.locator().column(), pep1.locator().column() );
110
QTEST_MAIN( ErrorTest )
112
#include "errortest.moc"