From e0c29962e6f334452f0c9db2caaf6ed18065de85 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 17 Aug 2009 19:31:37 -0300 Subject: The End Is the Beginning Is the End --- tests/samplebinding/enum_test.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tests/samplebinding/enum_test.py (limited to 'tests/samplebinding/enum_test.py') diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py new file mode 100755 index 000000000..699adceda --- /dev/null +++ b/tests/samplebinding/enum_test.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +'''Test cases for Python representation of C++ enums''' + +import sys +import unittest + +from sample import SampleNamespace + +class EnumTest(unittest.TestCase): + '''Test case for Abstract class''' + + def testPassingIntegerOnEnumArgument(self): + '''Test if replacing an enum argument with an integer raises an exception.''' + self.assertRaises(TypeError, lambda : SampleNamespace.getNumber(1)) + + def testExtendingEnum(self): + '''Test if can create new items for an enum declared as extensible on the typesystem file.''' + name, value = 'NewItem', 13 + enumitem = SampleNamespace.Option(name, value) + self.assert_(type(enumitem), SampleNamespace.Option) + self.assert_(enumitem.name, name) + self.assert_(int(enumitem), value) + + def testExtendingNonExtensibleEnum(self): + '''Test if trying to create a new enum item for an unextensible enum raises an exception.''' + self.assertRaises(TypeError, lambda : SampleNamespace.InValue(13)) + + def testEnumConversionToAndFromPython(self): + '''Test conversion of enum objects to Python and C++ in both directions.''' + enumout = SampleNamespace.enumInEnumOut(SampleNamespace.TwoIn) + self.assert_(enumout, SampleNamespace.TwoOut) + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.3