diff options
Diffstat (limited to 'tests/test_gobject.py')
-rw-r--r-- | tests/test_gobject.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_gobject.py b/tests/test_gobject.py index 9b4f5f7..ec4cb44 100644 --- a/tests/test_gobject.py +++ b/tests/test_gobject.py @@ -597,6 +597,10 @@ class TestPropertyBindings(unittest.TestCase): class TestGValue(unittest.TestCase): + def test_type_constant(self): + self.assertEqual(GObject.TYPE_VALUE, GObject.Value.__gtype__) + self.assertEqual(GObject.type_name(GObject.TYPE_VALUE), 'GValue') + def test_no_type(self): value = GObject.Value() self.assertEqual(value.g_type, GObject.TYPE_INVALID) @@ -620,10 +624,24 @@ class TestGValue(unittest.TestCase): # python float is G_TYPE_DOUBLE value = GObject.Value(float, 23.4) self.assertEqual(value.g_type, GObject.TYPE_DOUBLE) + value.set_value(1e50) + self.assertAlmostEqual(value.get_value(), 1e50) value = GObject.Value(GObject.TYPE_FLOAT, 23.4) self.assertEqual(value.g_type, GObject.TYPE_FLOAT) self.assertRaises(TypeError, value.set_value, 'string') + self.assertRaises(ValueError, value.set_value, 1e50) + + def test_float_inf_nan(self): + nan = float('nan') + for type_ in [GObject.TYPE_FLOAT, GObject.TYPE_DOUBLE]: + for x in [float('inf'), float('-inf'), nan]: + value = GObject.Value(type_, x) + # assertEqual() is False for (nan, nan) + if x is nan: + self.assertEqual(str(value.get_value()), 'nan') + else: + self.assertEqual(value.get_value(), x) def test_enum(self): value = GObject.Value(GLib.FileError, GLib.FileError.FAILED) |