diff options
author | Lauro Neto <lauro.neto@openbossa.org> | 2010-03-18 17:39:20 -0300 |
---|---|---|
committer | Lauro Neto <lauro.neto@openbossa.org> | 2010-03-22 15:57:26 -0300 |
commit | 50e58a81949c32c3154f5bd65fc68f2b3f8d7d26 (patch) | |
tree | a7f90ef52ac74a8b54db704a002c8a4ed53b70a6 /tests | |
parent | d4e41a5795d74d8ad55069374c34d2dc0a4c33f6 (diff) |
Adding greedy method to Collector
This method will somehow conflict with the external
operator in libother OtherObjectType
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libsample/collector.cpp | 7 | ||||
-rw-r--r-- | tests/libsample/collector.h | 4 | ||||
-rw-r--r-- | tests/libsample/objecttype.h | 2 | ||||
-rwxr-xr-x | tests/samplebinding/collector_test.py | 17 |
4 files changed, 28 insertions, 2 deletions
diff --git a/tests/libsample/collector.cpp b/tests/libsample/collector.cpp index 36e0145f4..c33269de1 100644 --- a/tests/libsample/collector.cpp +++ b/tests/libsample/collector.cpp @@ -54,6 +54,13 @@ Collector::operator<<(signed int item) return *this; } +Collector& +Collector::operator<<(const ObjectType *obj) +{ + m_items.push_back(obj->identifier()); + return *this; +} + std::list<int> Collector::items() { diff --git a/tests/libsample/collector.h b/tests/libsample/collector.h index 68d7f536c..623f64696 100644 --- a/tests/libsample/collector.h +++ b/tests/libsample/collector.h @@ -38,6 +38,8 @@ #include <list> #include "libsamplemacros.h" +#include "objecttype.h" + class LIBSAMPLE_API Collector { public: @@ -49,6 +51,8 @@ public: Collector& operator<<(unsigned int item); Collector& operator<<(signed int item); + Collector& operator<<(const ObjectType *); + std::list<int> items(); int size(); diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h index 3679b3b77..b606dd818 100644 --- a/tests/libsample/objecttype.h +++ b/tests/libsample/objecttype.h @@ -81,6 +81,8 @@ public: Str objectName() const; void setObjectName(const Str& name); + unsigned long identifier() const { return reinterpret_cast<unsigned long>(this); } + bool causeEvent(Event::EventType eventType); // Returns true if the event is processed. diff --git a/tests/samplebinding/collector_test.py b/tests/samplebinding/collector_test.py index a4c9248c4..69cf2a147 100755 --- a/tests/samplebinding/collector_test.py +++ b/tests/samplebinding/collector_test.py @@ -3,7 +3,7 @@ # # This file is part of the Shiboken Python Bindings Generator project. # -# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (C) 2009,2010 Nokia Corporation and/or its subsidiary(-ies). # # Contact: PySide team <contact@pyside.org> # @@ -29,7 +29,8 @@ import sys import unittest -from sample import Collector, IntWrapper +from sample import Collector, IntWrapper, ObjectType + class CollectorTest(unittest.TestCase): '''Test cases for Collector class' shift operators.''' @@ -58,6 +59,18 @@ class CollectorExternalOperator(unittest.TestCase): self.assertEqual(collector.size(), 1) self.assertEqual(collector.items(), [5]) + +class CollectorObjectType(unittest.TestCase): + '''Test cases for Collector ObjectType''' + + def testBasic(self): + '''Collector << ObjectType # greedy collector''' + collector = Collector() + obj = ObjectType() + collector << obj + self.assertEqual(collector.items()[0], obj.identifier()) + + if __name__ == '__main__': unittest.main() |