krenametest.h (krename-4.0.9) | : | krenametest.h (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
/*************************************************************************** | /*************************************************************************** | |||
* * | * * | |||
* This program is free software; you can redistribute it and/or modify * | * This program is free software; you can redistribute it and/or modify * | |||
* it under the terms of the GNU General Public License as published by * | * it under the terms of the GNU General Public License as published by * | |||
* the Free Software Foundation; either version 2 of the License, or * | * the Free Software Foundation; either version 2 of the License, or * | |||
* (at your option) any later version. * | * (at your option) any later version. * | |||
* * | * * | |||
***************************************************************************/ | ***************************************************************************/ | |||
#ifndef _KRENAME_TEST_H | #ifndef KRENAME_TEST_H | |||
#define _KRENAME_TEST_H | #define KRENAME_TEST_H | |||
#include <stdarg.h> | #include <stdarg.h> | |||
#include <QWidget> | #include <QWidget> | |||
#include "krenamefile.h" | #include "krenamefile.h" | |||
class KUrl; | class QUrl; | |||
class QTextEdit; | class QTextEdit; | |||
/** This class contains KRename's selftest. | /** This class contains KRename's selftest. | |||
* The selftest consists of several unit tests for | * The selftest consists of several unit tests for | |||
* important classes. | * important classes. | |||
* | * | |||
* Currently covered classes: | * Currently covered classes: | |||
* | * | |||
* - KRenameFile | * - KRenameFile | |||
*/ | */ | |||
class KRenameTest : public QWidget { | class KRenameTest : public QWidget | |||
public: | { | |||
public: | ||||
/** Construct a new KRenameTest dialog | /** Construct a new KRenameTest dialog | |||
*/ | */ | |||
KRenameTest(); | KRenameTest(); | |||
~KRenameTest(); | ~KRenameTest(); | |||
/** Starts the selftest | /** Starts the selftest | |||
*/ | */ | |||
void startTest(); | void startTest(); | |||
private: | private: | |||
/** Test the KRenameFile class | /** Test the KRenameFile class | |||
*/ | */ | |||
void testKRenameFile(); | void testKRenameFile(); | |||
/** Test a KRenameFile class object for | /** Test a KRenameFile class object for | |||
* an url if the pass is splitted correctly. | * an url if the pass is split correctly. | |||
* | * | |||
* \param url the url to split | * \param url the url to split | |||
* \param directory the expected directory | * \param directory the expected directory | |||
* \param filename the expected filename | * \param filename the expected filename | |||
* \param extension the expected extension | * \param extension the expected extension | |||
* \param eSplitMode the splitmode to use | * \param eSplitMode the splitmode to use | |||
* \param dot the dot to use as splitter | * \param dot the dot to use as splitter | |||
* \param isDir test a file or a directory | * \param isDir test a file or a directory | |||
*/ | */ | |||
bool testKRenameFileInternal( const KUrl & url, const QString & directory, | bool testKRenameFileInternal(const QUrl &url, const QString &directory, | |||
const QString & filename, const QString & exte | const QString &filename, const QString &extensi | |||
nsion, | on, | |||
ESplitMode eSplitMode, int dot, bool isDir ); | ESplitMode eSplitMode, int dot, bool isDir); | |||
/** Test the BatchRenamer class | /** Test the BatchRenamer class | |||
*/ | */ | |||
void testBatchRenamer(); | void testBatchRenamer(); | |||
bool tokenTest( const char* token, const QString & filename, const QString & | bool tokenTest(const char *token, const QString &filename, const QString &ex | |||
expected) ; | pected) ; | |||
bool numberingTest( int length, int start, int step, QList<int> skip, int nu | bool numberingTest(int length, int start, int step, QList<int> skip, int num | |||
m = 100 ); | = 100); | |||
bool replaceTest( const QString & token, const QString & filename, const QSt | bool replaceTest(const QString &token, const QString &filename, const QStrin | |||
ring & expected, | g &expected, | |||
const QString & replace, const QString & with, bool regExp | const QString &replace, const QString &with, bool regExp); | |||
); | ||||
/** Write a test caption to the output window | /** Write a test caption to the output window | |||
* \param text the text which will be output | * \param text the text which will be output | |||
*/ | */ | |||
void writeTestHeader( const QString & text ); | void writeTestHeader(const QString &text); | |||
/** Write a message about to the output window | /** Write a message about to the output window | |||
* \param text the text which will be output | * \param text the text which will be output | |||
*/ | */ | |||
void writeTestMessage( const char* format, ... ); | void writeTestMessage(const char *format, ...); | |||
/** | /** | |||
* Test a list of multiple files. | * Test a list of multiple files. | |||
* @param files a list of filenames to be tested | * @param files a list of filenames to be tested | |||
* @param a list of expected filenames | * @param a list of expected filenames | |||
* @param a list of expected paths | * @param a list of expected paths | |||
* @param a token to use | * @param a token to use | |||
*/ | */ | |||
bool testMultipleFiles( KRenameFile::List & files, const QStringList & expec | bool testMultipleFiles(KRenameFile::List &files, const QStringList &expected | |||
ted, | , | |||
const QStringList & exptectedPaths, const QString & | const QStringList &exptectedPaths, const QString &tok | |||
token ); | en); | |||
private: | private: | |||
QTextEdit* m_text; ///< output window | QTextEdit *m_text; ///< output window | |||
int m_counter; ///< test counter (increased for each individual te st) | int m_counter; ///< test counter (increased for each individual te st) | |||
bool m_result; ///< return value of tests is stored here | bool m_result; ///< return value of tests is stored here | |||
bool m_verbose; ///< if true print more information for each test | bool m_verbose; ///< if true print more information for each test | |||
int m_success; ///< counter of successfull tests | int m_success; ///< counter of successful tests | |||
int m_failed; ///< counter of failed tests | int m_failed; ///< counter of failed tests | |||
static const int BUFFER_LENGTH = 512; | static const int BUFFER_LENGTH = 512; | |||
char m_buffer[BUFFER_LENGTH]; ///< buffer in which messages are constr ucted | char m_buffer[BUFFER_LENGTH]; ///< buffer in which messages are constr ucted | |||
}; | }; | |||
#endif // _KRENAME_TEST_H | #endif // KRENAME_TEST_H | |||
End of changes. 13 change blocks. | ||||
28 lines changed or deleted | 28 lines changed or added |