File indexing completed on 2024-04-21 04:48:05

0001 /***************************************************************************
0002  *   Copyright (c) 2009 Sven Krohlas <sven@asbest-online.de>               *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #include "TestCaseConverter.h"
0021 
0022 #include "CaseConverter.h"
0023 
0024 #include <QTest>
0025 
0026 
0027 QTEST_GUILESS_MAIN( TestCaseConverter )
0028 
0029 TestCaseConverter::TestCaseConverter()
0030 {
0031 }
0032 
0033 void TestCaseConverter::testToCapitalizedCase()
0034 {
0035     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "" ), QString( "" ) );
0036 
0037     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A" ), QString( "A" ) );
0038     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a" ), QString( "A" ) );
0039     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A tale of true love" ), QString( "A Tale Of True Love" ) );
0040     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A horse with no name" ), QString( "A Horse With No Name" ) );
0041     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "riding on a dead horse" ), QString( "Riding On A Dead Horse" ) );
0042     // ätest -> Ätest
0043     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( QChar( 0x00E4 ) + QString( "test" ) ), QChar( 0x00C4 ) + QString( "test" ) );
0044     QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a an in of on" ), QString( "A An In Of On" ) );
0045 }
0046 
0047 void TestCaseConverter::testToTitleCase()
0048 {
0049     QCOMPARE( Amarok::CaseConverter::toTitleCase( "" ), QString( "" ) );
0050 
0051     QCOMPARE( Amarok::CaseConverter::toTitleCase( "A" ), QString( "A" ) );
0052     QCOMPARE( Amarok::CaseConverter::toTitleCase( "a" ), QString( "A" ) );
0053     QCOMPARE( Amarok::CaseConverter::toTitleCase( "a tale of true love" ), QString( "A Tale of True Love" ) );
0054     QCOMPARE( Amarok::CaseConverter::toTitleCase( "a horse with no name" ), QString( "A Horse With No Name" ) );
0055     QCOMPARE( Amarok::CaseConverter::toTitleCase( "riding on a dead horse" ), QString( "Riding on a Dead Horse" ) );
0056     // ätest -> Ätest
0057     QCOMPARE( Amarok::CaseConverter::toTitleCase( QChar( 0x00E4 ) + QString( "test" ) ), QChar( 0x00C4 ) + QString( "test" ) );
0058     QCOMPARE( Amarok::CaseConverter::toTitleCase( "a a an in of on" ), QString( "A a an in of on" ) );
0059 }