00001 #ifndef XMLWRITERTEST_H
00002 #define XMLWRITERTEST_H
00003
00004 #define QT_NO_CAST_ASCII
00005
00006
00007
00008
00009 #include <QBuffer>
00010 #include <QRegExp>
00011
00012 #define TEST_BEGIN(publicId,systemId) \
00013 { \
00014 QByteArray cstr; \
00015 QBuffer buffer( &cstr ); \
00016 buffer.open( QIODevice::WriteOnly ); \
00017 { \
00018 KoXmlWriter writer( &buffer ); \
00019 writer.startDocument( "r", publicId, systemId ); \
00020 writer.startElement( "r" )
00021
00022 #define TEST_END(testname, expected) \
00023 writer.endElement(); \
00024 writer.endDocument(); \
00025 } \
00026 buffer.putch( '\0' ); \
00027 QString expectedFull = QString::fromLatin1( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); \
00028 expectedFull += QString::fromLatin1( expected ); \
00029 QString s1 = QString::fromLatin1( cstr ); \
00030 if ( s1 == expectedFull ) \
00031 qDebug( "%s OK", testname ); \
00032 else { \
00033 qDebug( "%s FAILED!", testname ); \
00034 QString s2 = expectedFull; \
00035 if ( s1.length() != s2.length() ) \
00036 qDebug( "got length %d, expected %d", s1.length(), s2.length() ); \
00037 s1.replace( QRegExp( QString::fromLatin1( "[x]{1000}" ) ), QString::fromLatin1( "[x]*1000" ) ); \
00038 s2.replace( QRegExp( QString::fromLatin1( "[x]{1000}" ) ), QString::fromLatin1( "[x]*1000" ) ); \
00039 qDebug( "%s", qPrintable( s1 ) ); \
00040 qDebug( "Expected:\n%s", qPrintable( s2 ) ); \
00041 return 1; \
00042 } \
00043 }
00044
00045
00046 #endif