Commit 34b84f2400804abd1fd592b8613e39f0df45058a
- Diff rendering mode:
- inline
- side by side
src/App.cpp
(2 / 0)
|   | |||
| 89 | 89 | ||
| 90 | 90 | #ifdef DEBUG | |
| 91 | 91 | #include "TestAmarok.h" | |
| 92 | #include "TestCaseConverter.h" | ||
| 92 | 93 | #include "TestPlaylistManager.h" | |
| 93 | 94 | #include "TestSmartPointerList.h" | |
| 94 | 95 | #endif // DEBUG | |
| … | … | ||
| 584 | 584 | ||
| 585 | 585 | PERF_LOG( "Running Unit Tests" ) | |
| 586 | 586 | TestAmarok testAmarok ( testArgumentList ); | |
| 587 | TestCaseConverter testCaseConverter ( testArgumentList ); | ||
| 587 | 588 | TestPlaylistManager testPlaylistManager ( testArgumentList ); | |
| 588 | 589 | TestSmartPointerList testSmartPointerList( testArgumentList ); | |
| 589 | 590 |
src/CMakeLists.txt
(1 / 0)
|   | |||
| 567 | 567 | GlobalCurrentTrackActions.cpp | |
| 568 | 568 | ../tests/playlistmanager/TestPlaylistManager.cpp | |
| 569 | 569 | ../tests/TestAmarok.cpp | |
| 570 | ../tests/TestCaseConverter.cpp | ||
| 570 | 571 | ../tests/TestSmartPointerList.cpp | |
| 571 | 572 | ) | |
| 572 | 573 |
src/CaseConverter.cpp
(1 / 1)
|   | |||
| 28 | 28 | namespace Amarok | |
| 29 | 29 | { | |
| 30 | 30 | const QString CaseConverter::s_MATCH_A_WORD( "\\b([\\w']+)\\b" ); | |
| 31 | const QString CaseConverter::s_LITTLE_WORDS( "\\b(a|an|as|at|by|for|if|and|of|or|to|the|in)\\b" ); | ||
| 31 | const QString CaseConverter::s_LITTLE_WORDS( "\\b(a|an|and|as|at|by|for|if|in|of|on|or|to|the)\\b" ); | ||
| 32 | 32 | ||
| 33 | 33 | QString | |
| 34 | 34 | CaseConverter::toTitleCase( const QString &s ) |
tests/CMakeLists.txt
(1 / 0)
|   | |||
| 7 | 7 | ) | |
| 8 | 8 | ||
| 9 | 9 | QT4_AUTOMOC( TestAmarok.cpp ) | |
| 10 | QT4_AUTOMOC( TestCaseConverter.cpp ) | ||
| 10 | 11 | QT4_AUTOMOC( TestSmartPointerList.cpp ) | |
| 11 | 12 | ||
| 12 | 13 | add_subdirectory( data ) |
tests/TestCaseConverter.cpp
(53 / 0)
|   | |||
| 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 | |||
| 23 | TestCaseConverter::TestCaseConverter( QStringList testArgumentList ) | ||
| 24 | { | ||
| 25 | testArgumentList.replace( 2, testArgumentList.at( 2 ) + "CaseConverter.log" ); | ||
| 26 | QTest::qExec( this, testArgumentList ); | ||
| 27 | } | ||
| 28 | |||
| 29 | void 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 | |||
| 42 | void 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 | } |
tests/TestCaseConverter.h
(37 / 0)
|   | |||
| 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 | |||
| 25 | class TestCaseConverter : public QObject | ||
| 26 | { | ||
| 27 | Q_OBJECT | ||
| 28 | |||
| 29 | public: | ||
| 30 | TestCaseConverter( QStringList testArgumentList ); | ||
| 31 | |||
| 32 | private slots: | ||
| 33 | void testToCapitalizedCase(); | ||
| 34 | void testToTitleCase(); | ||
| 35 | }; | ||
| 36 | |||
| 37 | #endif // TESTCASECONVERTER_H |

