[gjs] marshalling tests: Add tests for GHashTable
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] marshalling tests: Add tests for GHashTable
- Date: Tue, 1 Nov 2016 23:08:21 +0000 (UTC)
commit 37212f77b69cff174d58e00b713c14adf6de77c8
Author: Philip Chimento <philip endlessm com>
Date: Mon Oct 31 16:04:53 2016 -0700
marshalling tests: Add tests for GHashTable
This adds the GHashTable marshalling tests currently available in
gimarshallingtests.c. In accordance with the current state of what works
and what doesn't, broken tests are commented out.
https://bugzilla.gnome.org/show_bug.cgi?id=773763
installed-tests/js/testGIMarshalling.js | 50 +++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/installed-tests/js/testGIMarshalling.js b/installed-tests/js/testGIMarshalling.js
index 3cfd5c7..314acfb 100644
--- a/installed-tests/js/testGIMarshalling.js
+++ b/installed-tests/js/testGIMarshalling.js
@@ -243,6 +243,56 @@ function testPtrArray() {
assertArrayEquals(refArray, GIMarshallingTests.gptrarray_utf8_full_out());
}
+function testGHashTable() {
+ function dictEquals(dict, ref) {
+ let dict_keys = Object.keys(dict);
+ let ref_keys = Object.keys(ref);
+ assertEquals(ref_keys.length, dict_keys.length);
+ ref_keys.forEach((key, ix) => {
+ assertEquals(key, dict_keys[ix]);
+ assertEquals(ref[key], dict[key]);
+ });
+ }
+
+ let INT_DICT = {
+ '-1': 1,
+ 0: 0,
+ 1: -1,
+ 2: -2,
+ };
+ const STRING_DICT = {
+ '-1': '1',
+ 0: '0',
+ 1: '-1',
+ 2: '-2',
+ };
+ const STRING_DICT_OUT = {
+ '-1': '1',
+ 0: '0',
+ 1: '1',
+ };
+
+ dictEquals(GIMarshallingTests.ghashtable_int_none_return(), INT_DICT);
+ dictEquals(GIMarshallingTests.ghashtable_utf8_none_return(), STRING_DICT);
+ dictEquals(GIMarshallingTests.ghashtable_utf8_container_return(), STRING_DICT);
+ dictEquals(GIMarshallingTests.ghashtable_utf8_full_return(), STRING_DICT);
+
+ // FIXME: Broken
+ //GIMarshallingTests.ghashtable_int_none_in(INT_DICT);
+ //GIMarshallingTests.ghashtable_utf8_none_in(STRING_DICT);
+
+ dictEquals(GIMarshallingTests.ghashtable_utf8_none_out(), STRING_DICT);
+ dictEquals(GIMarshallingTests.ghashtable_utf8_container_out(), STRING_DICT);
+ dictEquals(GIMarshallingTests.ghashtable_utf8_full_out(), STRING_DICT);
+
+ // FIXME: Broken
+ //dictEquals(GIMarshallingTests.ghashtable_utf8_none_inout(STRING_DICT), STRING_DICT_OUT);
+ // FIXME: Container transfer for in parameters not supported
+ //dictEquals(GIMarshallingTests.ghashtable_utf8_container_inout(STRING_DICT), STRING_DICT_OUT);
+ // FIXME: Broken
+ //dictEquals(GIMarshallingTests.ghashtable_utf8_full_inout(STRING_DICT), STRING_DICT_OUT);
+}
+
function testGValue() {
assertEquals(42, GIMarshallingTests.gvalue_return());
assertEquals(42, GIMarshallingTests.gvalue_out());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]