summaryrefslogtreecommitdiff
path: root/tests/cpp/include/class_obj/003-comparable.h
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-03-28 19:00:17 +0600
committervalmat <ufabiz@gmail.com>2014-03-28 19:00:17 +0600
commit708a22fae15b13db871ca5ffc73004c70f0584fe (patch)
tree639e424f544f8ca5c950803620399c57fceb69bd /tests/cpp/include/class_obj/003-comparable.h
parent7bc500847e3027bb785c5525a21078ff72acc2ab (diff)
Changed the structure of the test file. With the increasing number of tests the old structure became uncomfortable.
Diffstat (limited to 'tests/cpp/include/class_obj/003-comparable.h')
-rw-r--r--tests/cpp/include/class_obj/003-comparable.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/cpp/include/class_obj/003-comparable.h b/tests/cpp/include/class_obj/003-comparable.h
new file mode 100644
index 0000000..8a384dc
--- /dev/null
+++ b/tests/cpp/include/class_obj/003-comparable.h
@@ -0,0 +1,74 @@
+/**
+ *
+ * Test Classes and objects
+ * 003-comparable.phpt
+ *
+ */
+
+
+
+
+/**
+ * Set up namespace
+ */
+namespace TestBaseClass {
+
+
+ /**
+ * Test custom comparison operator
+ */
+ class Comparable : public Php::Base
+ {
+ private:
+ /**
+ * Internal value of the class
+ * @var int
+ */
+ static int count;
+ int _nom;
+ int _value;
+
+ public:
+ /**
+ * C++ constructor
+ */
+ Comparable()
+ {
+ // start with random value
+ //_value = rand();
+ _nom = ++count;
+ _value = _nom%2+1;
+ }
+
+ /**
+ * C++ destructor
+ */
+ virtual ~Comparable() {}
+
+ /**
+ * Cast the object to a string
+ * @return std::string
+ */
+ std::string __toString()
+ {
+ return "Obj#" + std::to_string(_nom) + "(" + std::to_string(_value) + ")";
+ }
+
+ /**
+ * Compare with a different object
+ * @param that
+ * @return int
+ */
+ int __compare(const Comparable &that) const
+ {
+ return _value - that._value;
+ }
+ };
+ int Comparable::count = 0;
+
+
+/**
+ * End of namespace
+ */
+}
+