[pygobject] test_gi: Enable GBytes test cases
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] test_gi: Enable GBytes test cases
- Date: Fri, 9 Nov 2012 08:14:24 +0000 (UTC)
commit e2c545896ab08b1f1885b502a8472db83f193d08
Author: Martin Pitt <martinpitt gnome org>
Date: Fri Nov 9 09:11:38 2012 +0100
test_gi: Enable GBytes test cases
GBytes annotations are fixed in GLib now, enable the test case and add more
for g_bytes_new_take() and g_bytes_{compare,equal}().
Please note that calling unref_to_array() on a GBytes object that we created
ourselves currently causes a double free crash, so disable that part for now.
tests/test_gi.py | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 8e14559..067b076 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -973,18 +973,24 @@ class TestGPtrArray(unittest.TestCase):
class TestGBytes(unittest.TestCase):
- @unittest.expectedFailure
def test_gbytes_create(self):
b = GLib.Bytes.new(b'\x00\x01\xFF')
self.assertEqual(3, b.get_size())
- # FIXME: gets garbage, missing annotation?
- self.assertEqual(b'\x00\x01\xFF', b.unref_to_array())
+ self.assertEqual(b'\x00\x01\xFF', b.get_data())
+ # FIXME: crashes at cleanup, double-free
+ #self.assertEqual(b'\x00\x01\xFF', b.unref_to_array())
+
+ def test_gbytes_create_take(self):
+ b = GLib.Bytes.new_take(b'\x00\x01\xFF')
+ self.assertEqual(3, b.get_size())
+ self.assertEqual(b'\x00\x01\xFF', b.get_data())
+ # FIXME: crashes at cleanup, double-free
+ #self.assertEqual(b'\x00\x01\xFF', b.unref_to_array())
def test_gbytes_full_return(self):
b = GIMarshallingTests.gbytes_full_return()
self.assertEqual(4, b.get_size())
- # FIXME: g_bytes_get_data() is not introspectable
- #self.assertEqual(b'\x00\x31\xFFx33', b.get_data())
+ self.assertEqual(b'\x00\x31\xFF\x33', b.get_data())
self.assertEqual(b'\x00\x31\xFF\x33', b.unref_to_array())
@@ -992,6 +998,20 @@ class TestGBytes(unittest.TestCase):
b = GIMarshallingTests.gbytes_full_return()
GIMarshallingTests.gbytes_none_in(b)
+ def test_compare(self):
+ a1 = GLib.Bytes.new(b'\x00\x01\xFF')
+ a2 = GLib.Bytes.new(b'\x00\x01\xFF')
+ b = GLib.Bytes.new(b'\x00\x01\xFE')
+
+ self.assertTrue(a1.equal(a2))
+ self.assertTrue(a2.equal(a1))
+ self.assertFalse(a1.equal(b))
+ self.assertFalse(b.equal(a2))
+
+ self.assertEqual(0, a1.compare(a2))
+ self.assertEqual(1, a1.compare(b))
+ self.assertEqual(-1, b.compare(a1))
+
class TestGByteArray(unittest.TestCase):
# FIXME: g_byte_array_new() not introspectable
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]