aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-01-22 01:00:32 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-01-22 02:17:03 -0300
commitc6898072bfb72d76d5e15e8fd59b5e86752006e3 (patch)
treeeae8ff7f44da14929ec9453ca7143a7763fac4ce /tests
parent62bd3820c222cfb6af57c2ff4b23b8b819743bbf (diff)
Fix bug on overflow check routines under 32 bits platforms.
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/functions.cpp6
-rw-r--r--tests/libsample/functions.h1
-rwxr-xr-xtests/samplebinding/overflow_test.py9
-rw-r--r--tests/samplebinding/typesystem_sample.xml1
4 files changed, 16 insertions, 1 deletions
diff --git a/tests/libsample/functions.cpp b/tests/libsample/functions.cpp
index 0df75ba90..d02b7a19d 100644
--- a/tests/libsample/functions.cpp
+++ b/tests/libsample/functions.cpp
@@ -141,6 +141,12 @@ doubleUnsignedInt(unsigned int value)
return value * 2;
}
+short
+doubleShort(short value)
+{
+ return value * 2;
+}
+
int
acceptInt(int x)
{
diff --git a/tests/libsample/functions.h b/tests/libsample/functions.h
index 52a26a7a6..136f9c517 100644
--- a/tests/libsample/functions.h
+++ b/tests/libsample/functions.h
@@ -73,6 +73,7 @@ LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(int val);
LIBSAMPLE_API GlobalOverloadFuncEnum overloadedFunc(double val);
LIBSAMPLE_API unsigned int doubleUnsignedInt(unsigned int value);
+LIBSAMPLE_API short doubleShort(short value);
LIBSAMPLE_API int acceptInt(int x);
LIBSAMPLE_API unsigned int acceptUInt(unsigned int x);
diff --git a/tests/samplebinding/overflow_test.py b/tests/samplebinding/overflow_test.py
index b53e4f3b5..67b7ca5fe 100755
--- a/tests/samplebinding/overflow_test.py
+++ b/tests/samplebinding/overflow_test.py
@@ -29,7 +29,7 @@
import sys
import unittest
-from sample import doubleUnsignedInt
+from sample import *
class OverflowTest(unittest.TestCase):
'''Test case for overflowing C++ numeric types.'''
@@ -44,6 +44,13 @@ class OverflowTest(unittest.TestCase):
def testOverflow(self):
'''Calls function with unsigned int parameter using an overflowing value.'''
self.assertRaises(OverflowError, doubleUnsignedInt, 42415335332353253)
+ doubleUnsignedInt(0xdeadbeef)
+
+ def testShortOverflow(self):
+ doubleShort(-3)
+ '''Calls function with unsigned int parameter using an overflowing value.'''
+ self.assertRaises(OverflowError, doubleShort, 0xFFFF*-1)
+ self.assertRaises(OverflowError, doubleShort, 0xFFFF + 1)
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index ea6e48926..5b23bd58a 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -3,6 +3,7 @@
<primitive-type name="bool"/>
<primitive-type name="double"/>
<primitive-type name="int"/>
+ <primitive-type name="short"/>
<primitive-type name="unsigned int" />
<primitive-type name="signed int" />
<primitive-type name="char"/>