summaryrefslogtreecommitdiffstats
path: root/src/piklab-test/base/main_test.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/piklab-test/base/main_test.h
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/piklab-test/base/main_test.h')
-rw-r--r--src/piklab-test/base/main_test.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/piklab-test/base/main_test.h b/src/piklab-test/base/main_test.h
new file mode 100644
index 0000000..601b779
--- /dev/null
+++ b/src/piklab-test/base/main_test.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * 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 *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef MAIN_TEST_H
+#define MAIN_TEST_H
+
+#include "common/global/about.h"
+
+//----------------------------------------------------------------------------
+#define TEST_SKIPPED_RETURN { skipped(); return false; }
+#define TEST_FAILED_RETURN(message) { failed(message, __FILE__, __LINE__); return false; }
+#define TEST_FAILED(message) { failed(message, __FILE__, __LINE__); }
+#define TEST_PASSED { printf("."); fflush(stdout); passed(); }
+#define TEST_MAIN(Type) \
+ int main(int argc, char **argv) \
+ { \
+ Type *check = new Type; \
+ Piklab::OptionList opt = check->optionList(); \
+ Piklab::init(new Piklab::AboutData("test", 0, 0), argc, argv, false, opt.ptr()); \
+ check->runTest(); \
+ return 0; \
+ }
+
+//----------------------------------------------------------------------------
+class Test
+{
+public:
+ Test();
+ virtual Piklab::OptionList optionList() const { return Piklab::OptionList(); }
+ virtual void runTest();
+
+protected:
+ KCmdLineArgs *_args;
+ QString _message;
+
+ void passed() { _nbPassed++; }
+ void failed(const QString &message, const char *file, int line);
+ void skipped() { _nbSkipped++; }
+ virtual bool execute() = 0; // returns false if failed or skipped
+ virtual void checkArguments() {}
+
+private:
+ uint _nbPassed, _nbFailed, _nbSkipped;
+};
+
+#endif