summaryrefslogtreecommitdiffstats
path: root/QA
diff options
context:
space:
mode:
Diffstat (limited to 'QA')
-rw-r--r--QA/Checker/IO.cpp57
-rw-r--r--QA/Checker/IO.h15
-rw-r--r--QA/Checker/SConscript2
-rw-r--r--QA/Checker/checker.cpp5
-rw-r--r--QA/UnitTest/SConscript14
5 files changed, 87 insertions, 6 deletions
diff --git a/QA/Checker/IO.cpp b/QA/Checker/IO.cpp
new file mode 100644
index 0000000..d9eadd6
--- /dev/null
+++ b/QA/Checker/IO.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <QA/Checker/IO.h>
+
+#include <iostream>
+
+std::ostream& operator<<(std::ostream& os, const Swift::ByteArray& s) {
+ std::ios::fmtflags oldFlags = os.flags();
+ os << std::hex;
+ for (Swift::ByteArray::const_iterator i = s.begin(); i != s.end(); ++i) {
+ if (*i >= 32 && *i < 127) {
+ os << *i;
+ }
+ else {
+ os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(*i));
+ }
+ }
+ os << std::endl;
+ os.flags(oldFlags);
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const Swift::SafeByteArray& s) {
+ std::ios::fmtflags oldFlags = os.flags();
+ os << std::hex;
+ for (Swift::SafeByteArray::const_iterator i = s.begin(); i != s.end(); ++i) {
+ if (*i >= 32 && *i < 127) {
+ os << *i;
+ }
+ else {
+ os << "\\x" << static_cast<unsigned int>(static_cast<unsigned char>(*i));
+ }
+ }
+ os << std::endl;
+ os.flags(oldFlags);
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const std::vector<int>& s) {
+ for (std::vector<int>::const_iterator i = s.begin(); i != s.end(); ++i) {
+ os << *i << " ";
+ }
+ os << std::endl;
+ return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const std::vector<size_t>& s) {
+ for (std::vector<size_t>::const_iterator i = s.begin(); i != s.end(); ++i) {
+ os << *i << " ";
+ }
+ os << std::endl;
+ return os;
+}
diff --git a/QA/Checker/IO.h b/QA/Checker/IO.h
new file mode 100644
index 0000000..2545d24
--- /dev/null
+++ b/QA/Checker/IO.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <Swiften/Base/ByteArray.h>
+#include <Swiften/Base/SafeByteArray.h>
+
+std::ostream& operator<<(std::ostream& os, const Swift::ByteArray& s);
+std::ostream& operator<<(std::ostream& os, const Swift::SafeByteArray& s);
+std::ostream& operator<<(std::ostream& os, const std::vector<int>& s);
+std::ostream& operator<<(std::ostream& os, const std::vector<size_t>& s);
diff --git a/QA/Checker/SConscript b/QA/Checker/SConscript
index 0456b93..96479db 100644
--- a/QA/Checker/SConscript
+++ b/QA/Checker/SConscript
@@ -11,4 +11,4 @@ if env["TEST"] :
if env["SCONS_STAGE"] == "build" :
checker_env = env.Clone()
checker_env.MergeFlags(env["CPPUNIT_FLAGS"])
- checker_env.Library("Checker", "checker.cpp")
+ checker_env.Library("Checker", ["checker.cpp", "IO.cpp"])
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp
index 1870b5d..12237dc 100644
--- a/QA/Checker/checker.cpp
+++ b/QA/Checker/checker.cpp
@@ -13,6 +13,8 @@
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/TextOutputter.h>
+#include <Swiften/Base/Log.h>
+
int main(int argc, char* argv[]) {
bool verbose = false;
bool outputXML = false;
@@ -27,6 +29,9 @@ int main(int argc, char* argv[]) {
else if (param == "--xml") {
outputXML = true;
}
+ else if (param == "--debug") {
+ Swift::logging = true;
+ }
else {
testsToRun.push_back(param);
}
diff --git a/QA/UnitTest/SConscript b/QA/UnitTest/SConscript
index 8cc43b9..3a19ea5 100644
--- a/QA/UnitTest/SConscript
+++ b/QA/UnitTest/SConscript
@@ -27,8 +27,12 @@ if env["TEST"] :
myenv.Append(CPPDEFINES = ["HAVE_LIBXML"])
if env.get("HAVE_EXPAT") :
myenv.Append(CPPDEFINES = ["HAVE_EXPAT"])
- checker = myenv.Program("checker", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
- for i in ["HOME", "USERPROFILE", "APPDATA"]:
- if os.environ.get(i, "") :
- myenv["ENV"][i] = os.environ[i]
- myenv.Test(checker, is_checker = True)
+ if env["TEST_CREATE_LIBRARIES"] :
+ lib = myenv.StaticLibrary("Swift_UnitTests", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
+ myenv.Program("checker", lib)
+ else :
+ checker = myenv.Program("checker", env["UNITTEST_SOURCES"] + env["UNITTEST_OBJECTS"])
+ for i in ["HOME", "USERPROFILE", "APPDATA"]:
+ if os.environ.get(i, "") :
+ myenv["ENV"][i] = os.environ[i]
+ myenv.Test(checker, is_checker = True)