diff options
author | Stian Selnes <stian@pexip.com> | 2017-04-11 11:17:31 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-05-04 18:56:04 +0200 |
commit | b5eab39ebcae061a46c186beac47f7e936ce57c2 (patch) | |
tree | 88fb47c789cc6a3c1596e568e29d9ec5ecb2209a /tests/test_gobject.py | |
parent | 9c671606cc93a06e6db3ee5ee5f0862a7bfc21f9 (diff) | |
download | pygobject-b5eab39ebcae061a46c186beac47f7e936ce57c2.tar.gz |
gi/pygi-value: Don't wrap GValue in GValue when creating GValueArray
If a GValueArray is created from a list of GValues, it should not wrap
these GValues in a second layer of GValues before appending to the
array. The end result should be a GValueArray of GValues, not a
GValueArray of GValues holding another GValue (unless the user
explicitly creates such a value).
With this patch the behavior is now consistent when creating a
GValueArray and appending GValues directly, and creating a GValueArray
within a GValue based on a list of GValues.
For instance, to create a GValueArray of G_TYPE_UINT the user must
create GValues manually and create a GValueArray from these. The result
should be a GValueArray of GValues that hold G_TYPE_UINT, not a
GValueArray that contain GValues that hold a GValue that holds
G_TYPE_UINT.
See !66
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 cf3d8b54..5d817601 100644 --- a/tests/test_gobject.py +++ b/tests/test_gobject.py @@ -698,6 +698,24 @@ class TestGValue(unittest.TestCase): value.set_value([32, 'foo_bar', 0.3]) self.assertEqual(value.get_value(), [32, 'foo_bar', 0.3]) + def test_value_array_from_gvalue_list(self): + value = GObject.Value(GObject.ValueArray, [ + GObject.Value(GObject.TYPE_UINT, 0xffffffff), + GObject.Value(GObject.TYPE_STRING, 'foo_bar')]) + self.assertEqual(value.g_type, GObject.type_from_name('GValueArray')) + self.assertEqual(value.get_value(), [0xffffffff, 'foo_bar']) + self.assertEqual(testhelper.value_array_get_nth_type(value, 0), GObject.TYPE_UINT) + self.assertEqual(testhelper.value_array_get_nth_type(value, 1), GObject.TYPE_STRING) + + def test_value_array_append_gvalue(self): + arr = GObject.ValueArray.new(0) + arr.append(GObject.Value(GObject.TYPE_UINT, 0xffffffff)) + arr.append(GObject.Value(GObject.TYPE_STRING, 'foo_bar')) + self.assertEqual(arr.get_nth(0), 0xffffffff) + self.assertEqual(arr.get_nth(1), 'foo_bar') + self.assertEqual(testhelper.value_array_get_nth_type(arr, 0), GObject.TYPE_UINT) + self.assertEqual(testhelper.value_array_get_nth_type(arr, 1), GObject.TYPE_STRING) + def test_gerror_boxing(self): error = GLib.Error('test message', domain='mydomain', code=42) value = GObject.Value(GLib.Error, error) |