aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2013-07-26 12:16:45 -0400
committerJohn Ehresman <jpe@wingware.com>2013-07-30 17:26:24 +0200
commit46db89a2a500c5b760c6f2b35ecde38d7e5ebfb6 (patch)
tree1feb857d0b8a1a8e34496b57e72300703e8f78ed /tests/samplebinding
parentae2a80453b95775364e93ed1a4647429b2fd7bad (diff)
Fix '%#' substitution for # > 9
Change '%#' substitution to use a regular expression for the 'old' text to enforce a word boundary after '#', such that we don't perform e.g. '%1' replacement on inputs like '%10'. This fixes problems trying to modify functions with more than nine arguments, such as the example from the previous commit (which now compiles and passes). Also add a test case for this. Change-Id: I9956804b3c65bddf7e36838866641b24ceb87c57 Reviewed-by: John Ehresman <jpe@wingware.com>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r--tests/samplebinding/global.h1
-rw-r--r--tests/samplebinding/transform_test.py53
-rw-r--r--tests/samplebinding/typesystem_sample.xml21
3 files changed, 75 insertions, 0 deletions
diff --git a/tests/samplebinding/global.h b/tests/samplebinding/global.h
index 37e00b372..28bac0a4e 100644
--- a/tests/samplebinding/global.h
+++ b/tests/samplebinding/global.h
@@ -53,6 +53,7 @@
#include "str.h"
#include "strlist.h"
#include "sometime.h"
+#include "transform.h"
#include "virtualmethods.h"
#include "voidholder.h"
#include "valueandvirtual.h"
diff --git a/tests/samplebinding/transform_test.py b/tests/samplebinding/transform_test.py
new file mode 100644
index 000000000..7b87300a9
--- /dev/null
+++ b/tests/samplebinding/transform_test.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2013 Kitware, Inc.
+#
+# This file is part of the Shiboken Python Bindings Generator project.
+#
+# Copyright (C) 2013 Digia Plc 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 StrList class that inherits from std::list<Str>.'''
+
+import unittest
+
+from sample import Point, applyHomogeneousTransform
+
+class TransformTest(unittest.TestCase):
+ '''Test cases for modifying a function with > 9 arguments.'''
+
+ def testTransform_ValidMatrix(self):
+ '''Transform applies successfully.'''
+ p = Point(3, 4)
+ r = applyHomogeneousTransform(p, 0, 1, 0, -1, 0, 0, 0, 0, 1)
+ self.assertTrue(type(r) is Point)
+ self.assertEqual(r.x(), 4)
+ self.assertEqual(r.y(), -3)
+
+ def testTransform_InvalidMatrix(self):
+ '''Transform does not apply successfully.'''
+ p = Point(3, 4)
+ r = applyHomogeneousTransform(p, 1, 0, 0, 0, 1, 0, 0, 0, 0)
+ self.assertTrue(r is None)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 813e0a09e..14b4f9d0f 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -1492,6 +1492,27 @@
</modify-function>
</value-type>
+ <function signature="applyHomogeneousTransform(Point,double,double,double,double,double,double,double,double,double,bool*)">
+ <!--
+ Tests handling of the '%#' substitution for # > 9.
+ -->
+ <modify-function signature="applyHomogeneousTransform(Point,double,double,double,double,double,double,double,double,double,bool*)">
+ <modify-argument index="11">
+ <remove-argument/>
+ </modify-argument>
+ <inject-code class="target" position="beginning">
+ bool ok_;
+ %RETURN_TYPE retval_ =
+ %FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, &amp;ok_);
+ if (!ok_)
+ %PYARG_0 = Py_None;
+ else
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval_);
+ </inject-code>
+ </modify-function>
+ </function>
+
+
<value-type name="InjectCode">
<!--
Various tests for inject codes.