aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/utility/object_test.cpp
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-10-18 04:18:27 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-10-18 04:18:27 +0800
commitfa817eee52694a15241c7d65c578f37c1b869dc9 (patch)
treed1e57674f7ef83f1c01de02ce0c6cf153dae39c3 /meowpp/utility/object_test.cpp
parent0f02ab1d29fc9a9da871711189047572b7724ad0 (diff)
downloadmeow-fa817eee52694a15241c7d65c578f37c1b869dc9.tar.gz
meow-fa817eee52694a15241c7d65c578f37c1b869dc9.tar.zst
meow-fa817eee52694a15241c7d65c578f37c1b869dc9.zip
Move the test code into the main folder
also remove the doc directory from the git filesystem
Diffstat (limited to 'meowpp/utility/object_test.cpp')
-rw-r--r--meowpp/utility/object_test.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/meowpp/utility/object_test.cpp b/meowpp/utility/object_test.cpp
new file mode 100644
index 0000000..5c60440
--- /dev/null
+++ b/meowpp/utility/object_test.cpp
@@ -0,0 +1,45 @@
+#include <meowpp/debug/assert.h>
+#include <meowpp/utility/object.h>
+#include <meowpp/utility/object.h>
+#include <meowpp/utility/object.h>
+
+static bool destructor_be_called = false;
+
+
+class A : public meow::Object {
+ public:
+ ~A() {
+ destructor_be_called = true;
+ }
+} _;
+
+class B : public meow::Object {
+ public:
+ meow::Object* Copy() const {
+ return static_cast<meow::Object*>(&_);
+ }
+ bool Equals(meow::Object const* b) const {
+ return false;;
+ }
+ meow::Object* CopyFrom(meow::Object const* ptr) {
+ return const_cast<meow::Object*>(ptr);
+ }
+};
+
+int main() {
+ meow::Object* ptr = new A, *ptr2 = new B;
+ delete ptr;
+ if (!destructor_be_called) {
+ return 1;
+ }
+ ptr = new A;
+ Assert(ptr->Copy() == NULL, "");
+ Assert(ptr->Equals(NULL) == false, "");
+ Assert(ptr->CopyFrom(ptr2) == NULL, "");
+ ptr = new B;
+ Assert(ptr->Copy() == &_, "");
+ Assert(ptr->Equals(NULL) == false, "");
+ Assert(ptr->CopyFrom(ptr2) == ptr2, "");
+ ////////////////////////////////////////
+ return 0;
+}