tests/bindingstest.cpp tests/CMakeLists.txt tests/parsingtest.cpp

Till Adam adam at kolabsys.com
Sat Aug 4 21:17:30 CEST 2012


 tests/CMakeLists.txt   |    1 +
 tests/bindingstest.cpp |   13 ++++++-------
 tests/parsingtest.cpp  |    6 ++----
 3 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit 6e0ba6071f61f78ed5d944ff3bca700417fa1867
Author: Till Adam <till at kdab.com>
Date:   Sat Aug 4 21:05:23 2012 +0200

    Reference the testfiles directory properly.

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6b2cc7a..dc4da78 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,5 @@
 find_package(Qt4)
+add_definitions(-DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
 
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
diff --git a/tests/bindingstest.cpp b/tests/bindingstest.cpp
index 02bdef8..0548caa 100644
--- a/tests/bindingstest.cpp
+++ b/tests/bindingstest.cpp
@@ -20,7 +20,6 @@
 #include "src/containers/kolabjournal.h"
 #include "libkolabxml-version.h"
 
-
 void BindingsTest::categorycolorConfigurationCompletness()
 {
     Kolab::CategoryColor color("name");
@@ -181,13 +180,13 @@ void setIncidence(T &ev)
     attachments.push_back(attach);
     
     Kolab::Attachment attach2;
-    attach2.setUri("../../tests/testfiles/icalEvent.xml", "mimetype");
+    attach2.setUri(TEST_DATA_PATH "/testfiles/icalEvent.xml", "mimetype");
     attach2.setLabel("labe2l");
     attachments.push_back(attach2);
     
     Kolab::Attachment attach3;
     using namespace std;
-    ifstream file ("../../tests/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
+    ifstream file (TEST_DATA_PATH "/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
     if (file.is_open()) {
         int size = file.tellg();
         char *memblock = new char [size];
@@ -376,13 +375,13 @@ void BindingsTest::journalCompletness()
     attachments.push_back(attach);
     
     Kolab::Attachment attach2;
-    attach2.setUri("../../tests/testfiles/icalEvent.xml", "mimetype");
+    attach2.setUri(TEST_DATA_PATH "/testfiles/icalEvent.xml", "mimetype");
     attach2.setLabel("labe2l");
     attachments.push_back(attach2);
     
     Kolab::Attachment attach3;
     using namespace std;
-    ifstream file ("../../tests/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
+    ifstream file (TEST_DATA_PATH "/testfiles/icalEvent.xml", ios::in|ios::binary|ios::ate);
     if (file.is_open()) {
         int size = file.tellg();
         char *memblock = new char [size];
@@ -703,7 +702,7 @@ void BindingsTest::errorRecoveryTest()
 
 void BindingsTest::BenchmarkRoundtripKolab()
 {
-    const Kolab::Event &event = Kolab::readEvent("../../tests/testfiles/icalEvent.xml", true);
+    const Kolab::Event &event = Kolab::readEvent(TEST_DATA_PATH "/testfiles/icalEvent.xml", true);
     std::string result = Kolab::writeEvent(event);
     QBENCHMARK {
         Kolab::readEvent(result, false);
@@ -712,7 +711,7 @@ void BindingsTest::BenchmarkRoundtripKolab()
 
 void BindingsTest::BenchmarkRoundtrip()
 {
-    const Kolab::Event &event = Kolab::readEvent("../../tests/testfiles/icalEvent.xml", true);
+    const Kolab::Event &event = Kolab::readEvent(TEST_DATA_PATH "/testfiles/icalEvent.xml", true);
     std::string result;
     QBENCHMARK {
         result = Kolab::writeEvent(event);
diff --git a/tests/parsingtest.cpp b/tests/parsingtest.cpp
index c6619f0..d7957e5 100644
--- a/tests/parsingtest.cpp
+++ b/tests/parsingtest.cpp
@@ -23,11 +23,9 @@
 
 #include "src/kolabformat.h"
 
-#define TESTFILEDIR "../../tests/testfiles/"
-
 void ParsingTest::vcardParsingTest()
 {
-    const Kolab::Contact &contact = Kolab::readContact(TESTFILEDIR "vcard/contact.xml", true);
+    const Kolab::Contact &contact = Kolab::readContact(TEST_DATA_PATH "/testfiles/vcard/contact.xml", true);
     QCOMPARE(Kolab::error(), Kolab::NoError);
     std::cout << Kolab::writeContact(contact);
 }
@@ -35,4 +33,4 @@ void ParsingTest::vcardParsingTest()
 
 QTEST_MAIN( ParsingTest )
 
-#include "parsingtest.moc"
\ No newline at end of file
+#include "parsingtest.moc"





More information about the commits mailing list