aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-12-29 16:34:39 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:12:51 -0300
commit87ae5790fa75114dbf335380ca7ab644b013a50b (patch)
treec4b502dcf425cb832d8ba1c577d790a1ba28ce1a /tests
parent4a25e3a3801cebfb90cf89fd1eb1faf05c4725a1 (diff)
Add support to fix the bug#493 - "__eq__ and friends not implemented for QKeyEvent == QKeySequence"
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/objecttypeoperators.cpp22
-rw-r--r--tests/libsample/objecttypeoperators.h8
-rw-r--r--tests/samplebinding/objecttypeoperators_test.py9
3 files changed, 33 insertions, 6 deletions
diff --git a/tests/libsample/objecttypeoperators.cpp b/tests/libsample/objecttypeoperators.cpp
index 08c49b1a4..43aedc5de 100644
--- a/tests/libsample/objecttypeoperators.cpp
+++ b/tests/libsample/objecttypeoperators.cpp
@@ -31,13 +31,27 @@ bool ObjectTypeOperators::operator==(const ObjectTypeOperators& other) const
return m_key == other.m_key;
}
-bool ObjectTypeOperators::operator==(const std::string& other) const
+const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const
{
- return m_key == other;
+ return m_key < other.m_key ? *this : other;
}
-const ObjectTypeOperators& ObjectTypeOperators::operator<(const ObjectTypeOperators& other) const
+bool operator==(const ObjectTypeOperators* obj, const std::string& str)
{
- return m_key < other.m_key ? *this : other;
+ return obj->key() == str;
+}
+
+bool operator==(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str == obj->key();
+}
+
+std::string operator+(const ObjectTypeOperators* obj, const std::string& str)
+{
+ return obj->key() + str;
}
+std::string operator+(const std::string& str, const ObjectTypeOperators* obj)
+{
+ return str + obj->key();
+}
diff --git a/tests/libsample/objecttypeoperators.h b/tests/libsample/objecttypeoperators.h
index 1d65eb167..9c1a85dc7 100644
--- a/tests/libsample/objecttypeoperators.h
+++ b/tests/libsample/objecttypeoperators.h
@@ -29,10 +29,9 @@
class LIBSAMPLE_API ObjectTypeOperators
{
public:
- ObjectTypeOperators(const std::string key);
+ explicit ObjectTypeOperators(const std::string key);
bool operator==(const ObjectTypeOperators& other) const;
- bool operator==(const std::string& other) const;
const ObjectTypeOperators& operator<(const ObjectTypeOperators& other) const;
// chaos!
@@ -47,4 +46,9 @@ private:
ObjectTypeOperators& operator=(ObjectTypeOperators&);
};
+LIBSAMPLE_API bool operator==(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API bool operator==(const std::string& str, const ObjectTypeOperators* obj);
+LIBSAMPLE_API std::string operator+(const ObjectTypeOperators* obj, const std::string& str);
+LIBSAMPLE_API std::string operator+(const std::string& str, const ObjectTypeOperators* obj);
+
#endif // OBJECTTYPEOPERATORS_H
diff --git a/tests/samplebinding/objecttypeoperators_test.py b/tests/samplebinding/objecttypeoperators_test.py
index d03c9bc48..148bc3591 100644
--- a/tests/samplebinding/objecttypeoperators_test.py
+++ b/tests/samplebinding/objecttypeoperators_test.py
@@ -39,5 +39,14 @@ class ObjectTypeOperatorsTest(unittest.TestCase):
self.assertEqual(None, a > b)
self.assertEqual(a.key(), "aoperator>")
+ def testPointerOpeators(self):
+ a = ObjectTypeOperators("a")
+ b = ObjectTypeOperators("b")
+ self.assertEqual(a + "bc", "abc")
+ self.assertEqual("bc" + a, "bca")
+ self.assertEqual("a", a)
+ self.assertEqual(a, "a")
+
+
if __name__ == '__main__':
unittest.main()