diff options
author | Sébastien Sablé <sable@users.sourceforge.net> | 2013-03-01 11:37:20 +0100 |
---|---|---|
committer | Hugo Parente Lima <hugo.lima@openbossa.org> | 2013-03-14 18:09:06 +0100 |
commit | 91142c00a45b78d6dafd9e0a472243cff951a507 (patch) | |
tree | 319ceab133bca02af73c73babfcad801ce086500 /tests/samplebinding | |
parent | 00d80865b7ef20440a4c925940c5576bbc8e248b (diff) |
Fix handling of unsigned long long and provide unittests.
Change-Id: I29674a2d758ebf4650e2fe26cdc2e663c0bae5c7
Reviewed-by: Sébastien Sablé <sable@users.sourceforge.net>
Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests/samplebinding')
-rw-r--r-- | tests/samplebinding/overflow_test.py | 18 | ||||
-rw-r--r-- | tests/samplebinding/typesystem_sample.xml | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/samplebinding/overflow_test.py b/tests/samplebinding/overflow_test.py index 4529fe201..ea2dd371d 100644 --- a/tests/samplebinding/overflow_test.py +++ b/tests/samplebinding/overflow_test.py @@ -41,6 +41,24 @@ class OverflowTest(unittest.TestCase): val *= -1 self.assertRaises(OverflowError, doubleUnsignedInt, val) + def testLongLong(self): + '''C++ function receives an long long argument and raise OverflowError if the value is negative.''' + val = 100 + self.assertEqual(doubleLongLong(val), 2 * val) + val = long(100) + self.assertEqual(doubleLongLong(val), 2 * val) + val = (2 << 64) + 1 + self.assertRaises(OverflowError, doubleLongLong, val) + + def testUnsignedLongLong(self): + '''C++ function receives an unsigned long long argument and raise OverflowError if the value is negative.''' + val = 100 + self.assertEqual(doubleUnsignedLongLong(val), 2 * val) + val = long(100) + self.assertEqual(doubleUnsignedLongLong(val), 2 * val) + val *= -1 + self.assertRaises(OverflowError, doubleUnsignedLongLong, val) + def testOverflow(self): '''Calls function with unsigned int parameter using an overflowing value.''' self.assertRaises(OverflowError, doubleUnsignedInt, 42415335332353253) diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 6379dbae8..0a9a764ee 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -22,6 +22,8 @@ <primitive-type name="unsigned char"/> <primitive-type name="long"/> <primitive-type name="unsigned long"/> + <primitive-type name="long long"/> + <primitive-type name="unsigned long long"/> <primitive-type name="std::string"/> <primitive-type name="Foo::HANDLE" target-lang-api-name="PyLong"/> @@ -481,6 +483,8 @@ <function signature="transmutePointIntoComplex(const Point&)" /> <function signature="sumComplexPair(std::pair<Complex, Complex>)" /> <function signature="doubleUnsignedInt(unsigned int)" /> + <function signature="doubleLongLong(long long)" /> + <function signature="doubleUnsignedLongLong(unsigned long long)" /> <function signature="doubleShort(short)" /> <function signature="returnNullPrimitivePointer()" /> <function signature="returnNullValueTypePointer()" /> |