Commit 34b84f2400804abd1fd592b8613e39f0df45058a

Tests and fixes for class CaseConverter.
  
8989
9090#ifdef DEBUG
9191#include "TestAmarok.h"
92#include "TestCaseConverter.h"
9293#include "TestPlaylistManager.h"
9394#include "TestSmartPointerList.h"
9495#endif // DEBUG
584584
585585 PERF_LOG( "Running Unit Tests" )
586586 TestAmarok testAmarok ( testArgumentList );
587 TestCaseConverter testCaseConverter ( testArgumentList );
587588 TestPlaylistManager testPlaylistManager ( testArgumentList );
588589 TestSmartPointerList testSmartPointerList( testArgumentList );
589590
  
567567 GlobalCurrentTrackActions.cpp
568568 ../tests/playlistmanager/TestPlaylistManager.cpp
569569 ../tests/TestAmarok.cpp
570 ../tests/TestCaseConverter.cpp
570571 ../tests/TestSmartPointerList.cpp
571572)
572573
  
2828namespace Amarok
2929{
3030const QString CaseConverter::s_MATCH_A_WORD( "\\b([\\w']+)\\b" );
31const QString CaseConverter::s_LITTLE_WORDS( "\\b(a|an|as|at|by|for|if|and|of|or|to|the|in)\\b" );
31const QString CaseConverter::s_LITTLE_WORDS( "\\b(a|an|and|as|at|by|for|if|in|of|on|or|to|the)\\b" );
3232
3333QString
3434CaseConverter::toTitleCase( const QString &s )
  
77)
88
99QT4_AUTOMOC( TestAmarok.cpp )
10QT4_AUTOMOC( TestCaseConverter.cpp )
1011QT4_AUTOMOC( TestSmartPointerList.cpp )
1112
1213add_subdirectory( data )
  
1/***************************************************************************
2 * Copyright (c) 2009 Sven Krohlas <sven@getamarok.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19
20#include "CaseConverter.h"
21#include "TestCaseConverter.h"
22
23TestCaseConverter::TestCaseConverter( QStringList testArgumentList )
24{
25 testArgumentList.replace( 2, testArgumentList.at( 2 ) + "CaseConverter.log" );
26 QTest::qExec( this, testArgumentList );
27}
28
29void TestCaseConverter::testToCapitalizedCase()
30{
31 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "" ), QString( "" ) );
32
33 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A" ), QString( "A" ) );
34 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a" ), QString( "A" ) );
35 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A tale of true love" ), QString( "A Tale Of True Love" ) );
36 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "A horse with no name" ), QString( "A Horse With No Name" ) );
37 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "riding on a dead horse" ), QString( "Riding On A Dead Horse" ) );
38 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "ätest" ), QString( "Ätest" ) );
39 QCOMPARE( Amarok::CaseConverter::toCapitalizedCase( "a an in of on" ), QString( "A An In Of On" ) );
40}
41
42void TestCaseConverter::testToTitleCase()
43{
44 QCOMPARE( Amarok::CaseConverter::toTitleCase( "" ), QString( "" ) );
45
46 QCOMPARE( Amarok::CaseConverter::toTitleCase( "A" ), QString( "A" ) );
47 QCOMPARE( Amarok::CaseConverter::toTitleCase( "a" ), QString( "A" ) );
48 QCOMPARE( Amarok::CaseConverter::toTitleCase( "a tale of true love" ), QString( "A Tale of True Love" ) );
49 QCOMPARE( Amarok::CaseConverter::toTitleCase( "a horse with no name" ), QString( "A Horse With No Name" ) );
50 QCOMPARE( Amarok::CaseConverter::toTitleCase( "riding on a dead horse" ), QString( "Riding on a Dead Horse" ) );
51 QCOMPARE( Amarok::CaseConverter::toTitleCase( "ätest" ), QString( "Ätest" ) );
52 QCOMPARE( Amarok::CaseConverter::toTitleCase( "a a an in of on" ), QString( "A a an in of on" ) );
53}
  
1/***************************************************************************
2 * Copyright (c) 2009 Sven Krohlas <sven@getamarok.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
19
20#ifndef TESTCASECONVERTER_H
21#define TESTCASECONVERTER_H
22
23#include <QtTest>
24
25class TestCaseConverter : public QObject
26{
27Q_OBJECT
28
29public:
30 TestCaseConverter( QStringList testArgumentList );
31
32private slots:
33 void testToCapitalizedCase();
34 void testToTitleCase();
35};
36
37#endif // TESTCASECONVERTER_H