diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-18 13:12:09 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:12 -0300 |
commit | b7169ca7fe92c5874076ff47f9b4ec7954acc480 (patch) | |
tree | 3ff52c75c31e11583fb24a57423638410a1a14ea | |
parent | 4f782f5d0f97633261690a19de7dfa62eeec2741 (diff) |
Added a test case for a bit-field structure member.
Also moved a couple of tests from samplebindings to otherbindings.
-rw-r--r-- | tests/libsample/abstract.cpp | 1 | ||||
-rw-r--r-- | tests/libsample/abstract.h | 4 | ||||
-rw-r--r-- | tests/otherbinding/module_reload_test.py (renamed from tests/samplebinding/module_reload_test.py) | 6 | ||||
-rw-r--r-- | tests/otherbinding/test_module_template.py (renamed from tests/samplebinding/test_module_template.py) | 0 | ||||
-rw-r--r-- | tests/otherbinding/typediscovery_test.py (renamed from tests/samplebinding/typediscovery_test.py) | 5 | ||||
-rw-r--r-- | tests/samplebinding/class_fields_test.py | 19 |
6 files changed, 26 insertions, 9 deletions
diff --git a/tests/libsample/abstract.cpp b/tests/libsample/abstract.cpp index 26c342352..d1ca4f3cf 100644 --- a/tests/libsample/abstract.cpp +++ b/tests/libsample/abstract.cpp @@ -33,6 +33,7 @@ Abstract::Abstract(int id) : m_id(id) primitiveField = 123; valueTypeField = Point(12, 34); objectTypeField = 0; + bitField = 0; } Abstract::~Abstract() diff --git a/tests/libsample/abstract.h b/tests/libsample/abstract.h index 95c1c3a0d..feeec980e 100644 --- a/tests/libsample/abstract.h +++ b/tests/libsample/abstract.h @@ -92,8 +92,10 @@ public: protected: virtual const char* className() { return "Abstract"; } + // Protected bit-field structure member. + unsigned int bitField: 1; + private: int m_id; }; #endif // ABSTRACT_H - diff --git a/tests/samplebinding/module_reload_test.py b/tests/otherbinding/module_reload_test.py index 48d6d9572..1863fc989 100644 --- a/tests/samplebinding/module_reload_test.py +++ b/tests/otherbinding/module_reload_test.py @@ -14,10 +14,8 @@ class TestModuleReloading(unittest.TestCase): def testModuleReloading(self): '''Test module reloading with on-the-fly modifications.''' - import test_module - - for i in range(3): + for i in range(3): oldObject = test_module.obj self.assertTrue(oldObject is test_module.obj) reload(test_module) @@ -25,5 +23,3 @@ class TestModuleReloading(unittest.TestCase): if __name__ == "__main__": unittest.main() - - diff --git a/tests/samplebinding/test_module_template.py b/tests/otherbinding/test_module_template.py index b6cfb8389..b6cfb8389 100644 --- a/tests/samplebinding/test_module_template.py +++ b/tests/otherbinding/test_module_template.py diff --git a/tests/samplebinding/typediscovery_test.py b/tests/otherbinding/typediscovery_test.py index f7d5433ce..aab768049 100644 --- a/tests/samplebinding/typediscovery_test.py +++ b/tests/otherbinding/typediscovery_test.py @@ -28,8 +28,8 @@ import unittest -from sample import * -from other import * +from sample import Abstract, Base1, Derived, MDerived1, MDerived3, SonOfMDerived1 +from other import OtherMultipleDerived class TypeDiscoveryTest(unittest.TestCase): @@ -57,4 +57,3 @@ class TypeDiscoveryTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/tests/samplebinding/class_fields_test.py b/tests/samplebinding/class_fields_test.py index eab138f4a..bee4cca87 100644 --- a/tests/samplebinding/class_fields_test.py +++ b/tests/samplebinding/class_fields_test.py @@ -140,5 +140,24 @@ class TestAccessingCppFields(unittest.TestCase): def testStaticField(self): self.assertEqual(Derived.staticPrimitiveField, 0) + def testAccessingUnsignedIntBitField(self): + d = Derived() + + # attribution + old_value = d.bitField + new_value = 1 + d.bitField= new_value + self.assertEqual(d.bitField, new_value) + self.assertNotEqual(d.bitField, old_value) + + # attribution with a convertible type + value = 1.2 + d.bitField = value + self.assertEqual(d.bitField, int(value)) + + # attribution with invalid type + self.assertRaises(TypeError, lambda : setattr(d, 'bitField', None)) + + if __name__ == '__main__': unittest.main() |