aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/libsample/CMakeLists.txt1
-rw-r--r--tests/libsample/collector.cpp61
-rw-r--r--tests/libsample/collector.h57
-rw-r--r--tests/samplebinding/CMakeLists.txt1
-rwxr-xr-xtests/samplebinding/collector_test.py54
-rw-r--r--tests/samplebinding/global.h1
-rwxr-xr-xtests/samplebinding/overload_test.py10
-rw-r--r--tests/samplebinding/typesystem_sample.xml1
8 files changed, 181 insertions, 5 deletions
diff --git a/tests/libsample/CMakeLists.txt b/tests/libsample/CMakeLists.txt
index 227951672..3672faf26 100644
--- a/tests/libsample/CMakeLists.txt
+++ b/tests/libsample/CMakeLists.txt
@@ -2,6 +2,7 @@ project(libsample)
set(libsample_SRC
abstract.cpp
+collector.cpp
complex.cpp
derived.cpp
functions.cpp
diff --git a/tests/libsample/collector.cpp b/tests/libsample/collector.cpp
new file mode 100644
index 000000000..0b81b2996
--- /dev/null
+++ b/tests/libsample/collector.cpp
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation. Please
+ * review the following information to ensure the GNU Lesser General
+ * Public License version 2.1 requirements will be met:
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "collector.h"
+
+void
+Collector::clear()
+{
+ m_items.clear();
+}
+
+Collector&
+Collector::operator<<(int item)
+{
+ m_items.push_back(item);
+ return *this;
+}
+
+std::list<int>
+Collector::items()
+{
+ return m_items;
+}
+
+int
+Collector::size()
+{
+ return (int) m_items.size();
+}
+
diff --git a/tests/libsample/collector.h b/tests/libsample/collector.h
new file mode 100644
index 000000000..1253cdd33
--- /dev/null
+++ b/tests/libsample/collector.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the Shiboken Python Binding Generator project.
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: PySide team <contact@pyside.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation. Please
+ * review the following information to ensure the GNU Lesser General
+ * Public License version 2.1 requirements will be met:
+ * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ *
+ * As a special exception to the GNU Lesser General Public License
+ * version 2.1, the object code form of a "work that uses the Library"
+ * may incorporate material from a header file that is part of the
+ * Library. You may distribute such object code under terms of your
+ * choice, provided that the incorporated material (i) does not exceed
+ * more than 5% of the total size of the Library; and (ii) is limited to
+ * numerical parameters, data structure layouts, accessors, macros,
+ * inline functions and templates.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef COLLECTOR_H
+#define COLLECTOR_H
+
+#include <list>
+
+class Collector
+{
+public:
+ Collector() {}
+ virtual ~Collector() {}
+
+ void clear();
+
+ Collector& operator<<(int item);
+
+ std::list<int> items();
+ int size();
+
+private:
+ std::list<int> m_items;
+};
+#endif // COLLECTOR_H
+
diff --git a/tests/samplebinding/CMakeLists.txt b/tests/samplebinding/CMakeLists.txt
index ed876ec7d..94de71102 100644
--- a/tests/samplebinding/CMakeLists.txt
+++ b/tests/samplebinding/CMakeLists.txt
@@ -7,6 +7,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sample.xml
set(sample_SRC
${CMAKE_CURRENT_BINARY_DIR}/sample/abstractmodifications_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/abstract_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/sample/collector_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/mbase_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/mbase2_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/sample/mderived_wrapper.cpp
diff --git a/tests/samplebinding/collector_test.py b/tests/samplebinding/collector_test.py
new file mode 100755
index 000000000..2ff2c7665
--- /dev/null
+++ b/tests/samplebinding/collector_test.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+#
+# Contact: PySide team <contact@pyside.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# version 2.1 as published by the Free Software Foundation. Please
+# review the following information to ensure the GNU Lesser General
+# Public License version 2.1 requirements will be met:
+# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+# #
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+
+'''Test cases for Collector class' shift operators.'''
+
+import sys
+import unittest
+
+from sample import Collector
+
+class CollectorTest(unittest.TestCase):
+ '''Test cases for Collector class' shift operators.'''
+
+ def testLShiftOperatorSingleUse(self):
+ '''Test case for using the Collector.__lshift__ operator just one time.'''
+ collector = Collector()
+ collector << 13
+ self.assertEqual(collector.size(), 1)
+ self.assertEqual(collector.items(), [13])
+
+ def testLShiftOperatorMultipleUses(self):
+ '''Test case for using the Collector.__lshift__ operator many times in the same line.'''
+ collector = Collector()
+ collector << 2 << 3 << 5 << 7 << 11
+ self.assertEqual(collector.size(), 5)
+ self.assertEqual(collector.items(), [2, 3, 5, 7, 11, 13])
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/tests/samplebinding/global.h b/tests/samplebinding/global.h
index 413ff92a7..13fd4f0e7 100644
--- a/tests/samplebinding/global.h
+++ b/tests/samplebinding/global.h
@@ -1,4 +1,5 @@
#include "abstract.h"
+#include "collector.h"
#include "derived.h"
#include "point.h"
#include "size.h"
diff --git a/tests/samplebinding/overload_test.py b/tests/samplebinding/overload_test.py
index f7d7c0756..ca36cf78c 100755
--- a/tests/samplebinding/overload_test.py
+++ b/tests/samplebinding/overload_test.py
@@ -31,31 +31,31 @@ import unittest
from sample import Overload, Point, Size
-class OVerloadTest(unittest.TestCase):
+class OverloadTest(unittest.TestCase):
'''Test case for Overload class'''
def testOverloadMethod0(self):
- '''Check overloaded method calling for signature "overloaded()".'''
+ '''Check overloaded method call for signature "overloaded()".'''
overload = Overload()
result = overload.overloaded()
self.assertEqual(result, Overload.Function0)
def testOverloadMethod1(self):
- '''Check overloaded method calling for signature "overloaded(Size*)".'''
+ '''Check overloaded method call for signature "overloaded(Size*)".'''
overload = Overload()
size = Size()
result = overload.overloaded(size)
self.assertEqual(result, Overload.Function1)
def testOverloadMethod2(self):
- '''Check overloaded method calling for signature "overloaded(Point*, ParamEnum)".'''
+ '''Check overloaded method call for signature "overloaded(Point*, ParamEnum)".'''
overload = Overload()
point = Point()
result = overload.overloaded(point, Overload.Param1)
self.assertEqual(result, Overload.Function2)
def testOverloadMethod3(self):
- '''Check overloaded method calling for signature "overloaded(const Point&)".'''
+ '''Check overloaded method call for signature "overloaded(const Point&)".'''
overload = Overload()
point = Point()
result = overload.overloaded(point)
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index f8185c6c8..9f7a47b41 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -234,6 +234,7 @@
<value-type name="NonDefaultCtor" />
<value-type name="OddBoolUser" />
<value-type name="Overload" />
+ <value-type name="Collector" />
<value-type name="SimpleFile">
<modify-function signature="open()">