Commit 1a494848d09fe389145d12ffeaba3bb26aa85df4

  • Tree SHA1: 8ac32e2
  • Parent SHA1: d716827 (Make TestAmarok::testRecursiveUrlExpand() pass again. Changing test data can have side effects sometimes...)
  • raw diff | raw patch
First tests for QStringx, including a possible crash fix.
  
9393#include "TestDirectoryLoader.h"
9494#include "TestExpression.h"
9595#include "TestPlaylistManager.h"
96#include "TestQStringx.h"
9697#include "TestSmartPointerList.h"
9798#endif // DEBUG
9899
591591 TestDirectoryLoader testDirectoryLoader ( testArgumentList );
592592 TestExpression testExpression ( testArgumentList );
593593 TestPlaylistManager testPlaylistManager ( testArgumentList );
594 TestQStringx testQStringx( testArgumentList );
594595 TestSmartPointerList testSmartPointerList( testArgumentList );
595596
596597 /* add more test classes here ^^ */
  
575575 ../tests/TestCaseConverter.cpp
576576 ../tests/TestDirectoryLoader.cpp
577577 ../tests/TestExpression.cpp
578 ../tests/TestQStringx.cpp
578579 ../tests/TestSmartPointerList.cpp
579580 )
580581endif(CMAKE_BUILD_TYPE MATCHES debugfull)
  
4949 QList<QString>::ConstIterator endArgs = args.constEnd();
5050 QString merged = (*itrText);
5151 ++itrText;
52 while ( itrText != endText && itrArgs != endArgs )
52 while( itrText != endText && itrArgs != endArgs )
5353 {
5454 merged += (*itrArgs) + (*itrText);
5555 ++itrText;
5656 ++itrArgs;
5757 }
5858
59 Q_ASSERT( itrText == text.end() && itrArgs == args.end() );
59 Q_ASSERT( itrText == text.end() || itrArgs == args.end() );
6060
6161 return merged;
6262 }
  
66 ../src/playlistmanager/
77)
88
9QT4_AUTOMOC( TestAmarok.cpp )
10QT4_AUTOMOC( TestCaseConverter.cpp )
11QT4_AUTOMOC( TestDirectoryLoader.cpp )
12QT4_AUTOMOC( TestExpression.cpp )
13QT4_AUTOMOC( TestSmartPointerList.cpp )
9QT4_AUTOMOC( TestAmarok.cpp
10 TestCaseConverter.cpp
11 TestDirectoryLoader.cpp
12 TestExpression.cpp
13 TestQStringx.cpp
14 TestSmartPointerList.cpp
15)
1416
1517add_subdirectory( data )
1618add_subdirectory( playlistmanager )
  
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 "TestQStringx.h"
21
22TestQStringx::TestQStringx( QStringList testArgumentList )
23{
24 testArgumentList.replace( 2, testArgumentList.at( 2 ) + "QStringx.log" );
25 QTest::qExec( this, testArgumentList );
26}
27
28void TestQStringx::testArgs()
29{
30 QStringList testArgs;
31
32 m_testString = "";
33 QCOMPARE( m_testString.args( testArgs ) , QString( "" ) );
34
35 m_testString = "test";
36 QCOMPARE( m_testString.args( testArgs ), QString( "test" ) );
37
38 m_testString = "";
39 testArgs.append( "test" );
40 QCOMPARE( m_testString.args( testArgs ), QString( "" ) );
41
42 m_testString = "test%12abc";
43 QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabc" ) );
44
45 m_testString = "%12test abc";
46 QCOMPARE( m_testString.args( testArgs ) , QString( "testtest abc" ) );
47
48 m_testString = "te%st%12abc";
49 QCOMPARE( m_testString.args( testArgs ) , QString( "te%sttestabc" ) );
50
51 testArgs.clear();
52 testArgs.append( "test" );
53 testArgs.append( "abc" );
54 m_testString = "test%12abc%2xyz";
55 QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabcabcxyz" ) );
56
57 m_testString = "%12test%23abc";
58 QCOMPARE( m_testString.args( testArgs ) , QString( "testtestabcabc" ) );
59}
60
61void TestQStringx::testNamedArgs()
62{
63}
64
65void TestQStringx::testNamedOptArgs()
66{
67}
  
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 TESTQSTRINGX_H
21#define TESTQSTRINGX_H
22
23#include "QStringx.h"
24
25#include <QtTest>
26
27class TestQStringx : public QObject
28{
29Q_OBJECT
30
31public:
32 TestQStringx( QStringList testArgumentList );
33
34private slots:
35 void testArgs();
36 void testNamedArgs();
37 void testNamedOptArgs();
38
39private:
40 Amarok::QStringx m_testString;
41};
42
43#endif // TESTQSTRINGX_H