-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* File: Test_ChangeDir.cpp | ||
* Author: lene | ||
* | ||
* Created on 28 March 2014, 18:38 | ||
*/ | ||
|
||
#include "Test_ChangeDir.h" | ||
|
||
#include "GlobalFunctions.h" | ||
|
||
#include <QTemporaryDir> | ||
|
||
using namespace UnitTests; | ||
|
||
void Test_ChangeDir::initTestCase() { | ||
} | ||
|
||
void Test_ChangeDir::dirIsChanged() { | ||
QTemporaryDir temp_dir; | ||
test(temp_dir.isValid(), std::string("temporary directory created")); | ||
test(QDir::currentPath() != temp_dir.path(), std::string("whut? we already changed to the temp dir?")); | ||
ChangeDir path_change(temp_dir.path()); | ||
test(QDir::currentPath() == temp_dir.path(), std::string("path changed")); | ||
} | ||
|
||
void Test_ChangeDir::changeBackOnExit() { | ||
QTemporaryDir temp_dir; | ||
test(temp_dir.isValid(), std::string("temporary directory created")); | ||
QString old_path = QDir::currentPath(); | ||
test(old_path != temp_dir.path(), std::string("whut? we already changed to the temp dir?")); | ||
{ | ||
ChangeDir path_change(temp_dir.path()); | ||
test(QDir::currentPath() == temp_dir.path(), std::string("path changed")); | ||
} | ||
test(QDir::currentPath() == old_path, std::string("path changed back when objet went out of scope")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* File: Test_ChangeDir.h | ||
* Author: lene | ||
* | ||
* Created on 28 March 2014, 18:38 | ||
*/ | ||
|
||
#ifndef TEST_CHANGEDIR_H | ||
#define TEST_CHANGEDIR_H | ||
|
||
#include "ChangeDir.h" | ||
|
||
#include <QtTest/QtTest> | ||
|
||
class Test_ChangeDir: public QObject { | ||
|
||
Q_OBJECT | ||
|
||
private slots: | ||
|
||
void initTestCase(); | ||
|
||
void dirIsChanged(); | ||
void changeBackOnExit(); | ||
|
||
private: | ||
QString temp_dir; | ||
|
||
}; | ||
|
||
#endif /* TEST_CHANGEDIR_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters