summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authordeva <deva>2011-02-14 12:21:48 +0000
committerdeva <deva>2011-02-14 12:21:48 +0000
commit95cfffa53760942c3ccf6abc18b81f48d03a3ff6 (patch)
treeec5bc512bbcf4b59d42755b62d59360724651102 /server/src
parent7b7a472eb22a4cc91c73c8b8233c3d457467de36 (diff)
Reenable unit test.
Diffstat (limited to 'server/src')
-rw-r--r--server/src/exception.cc49
1 files changed, 27 insertions, 22 deletions
diff --git a/server/src/exception.cc b/server/src/exception.cc
index 09c6918..a2bbf95 100644
--- a/server/src/exception.cc
+++ b/server/src/exception.cc
@@ -42,8 +42,16 @@ const char* Exception::what() const throw()
return _what.c_str();
}
-
#ifdef TEST_EXCEPTION
+//deps: log.cc
+//cflags: -I..
+//libs:
+
+#undef TEST_EXCEPTION // 'fix' redefined test macro.
+#include <test.h>
+
+#define PRE "MyExtException has been thrown: "
+#define MSG "Hello World!"
class MyException : public Exception {
public:
@@ -54,30 +62,27 @@ public:
class MyExtException : public Exception {
public:
MyExtException(std::string thingy) :
- Exception("MyExtException has been thrown: " + thingy) {}
+ Exception(PRE + thingy) {}
};
-int main()
+void throwit()
{
- try {
- throw MyException();
- } catch( MyException &e ) {
- printf("%s\n", e.what());
- goto on;
- }
- return 1;
- on:
-
- try {
- throw MyExtException("Yeaaah!");
- } catch( MyExtException &e ) {
- printf("%s\n", e.what());
- goto onandon;
- }
- return 1;
- onandon:
-
- return 0;
+ throw MyException();
}
+TEST_BEGIN;
+
+TEST_EXCEPTION(throwit(), MyException, "Throw it.");
+
+std::string w;
+try {
+ throw MyExtException(MSG);
+} catch( MyExtException &e ) {
+ w = e.what();
+}
+
+TEST_EQUAL_STR(w, PRE MSG, "We got a 'what'.");
+
+TEST_END;
+
#endif/*TEST_EXCEPTION*/