From 86921d65c5c218a2c721d905a93885cf2fe9b7b7 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Wed, 21 Dec 2016 01:09:27 +0300 Subject: tdeio: add tests Signed-off-by: Alexander Golubev (cherry picked from commit ed74769bfaae171809c0bc1a10a8ba0f6ff8895f) --- tdeio/tests/kmimetypetest.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'tdeio/tests/kmimetypetest.cpp') diff --git a/tdeio/tests/kmimetypetest.cpp b/tdeio/tests/kmimetypetest.cpp index 5d963c81c..631521c8a 100644 --- a/tdeio/tests/kmimetypetest.cpp +++ b/tdeio/tests/kmimetypetest.cpp @@ -36,6 +36,17 @@ static void checkIcon( const KURL& url, const TQString& expectedIcon ) } } +static void checkExtention( const TQString& fileName, const TQString& expectedExtention ) { + TQString ext; + KMimeType::diagnoseFileName(fileName, ext); + if ( ext == expectedExtention) { + tqDebug("extension of %s is '%s: OK'", fileName.latin1(), ext.latin1()); + } else { + tqDebug("extension of %s is '%s, expected %s!'", fileName.latin1(), ext.latin1(), expectedExtention.latin1()); + exit(1); + } +} + int main( int argc, char** argv ) { TDEInstance blah("kmimetypetest"); @@ -63,14 +74,8 @@ int main( int argc, char** argv ) checkIcon( "trash:/foo/", "folder" ); } - TQString pdf; - KMimeType::diagnoseFileName("foo.pdf", pdf); - tqDebug("extension: '%s'", pdf.latin1()); - assert(pdf == TQString("*.pdf")); - TQString ps; - KMimeType::diagnoseFileName("foo.ps", ps); - tqDebug("extension: '%s'", ps.latin1()); - assert(ps == TQString("*.ps")); + checkExtention(TQString::fromLatin1("foo.pdf"), TQString::fromLatin1("*.pdf")); + checkExtention(TQString::fromLatin1("foo.ps"), TQString::fromLatin1("*.ps")); return 0; } -- cgit v1.2.1