diff options
author | Philip Chimento <philip@endlessm.com> | 2016-11-02 15:00:11 -0700 |
---|---|---|
committer | Philip Chimento <philip@endlessm.com> | 2016-11-02 18:14:23 -0700 |
commit | 88b42e54504747210a84fbe9551502827eef89aa (patch) | |
tree | 1332da90c84a0cba64797a7177e40323b83f3769 /tests/gimarshallingtests.c | |
parent | efc4fa67575e58219626314aa8fb8dae2a919cf4 (diff) | |
download | gobject-introspection-88b42e54504747210a84fbe9551502827eef89aa.tar.gz |
tests: Test hashtables with allocated values
In order to test GJS's support for GHashTables with float, double,
gint64, and guint64 value types, here are some new GI marshalling tests.
https://bugzilla.gnome.org/show_bug.cgi?id=773763
Diffstat (limited to 'tests/gimarshallingtests.c')
-rw-r--r-- | tests/gimarshallingtests.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 2e001c02..568492c0 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -3109,6 +3109,90 @@ gi_marshalling_tests_ghashtable_utf8_none_in (GHashTable *hash_table) } /** + * gi_marshalling_tests_ghashtable_double_in: + * @hash_table: (element-type utf8 double) (transfer none): + * + * Meant to test a value type that doesn't fit inside a pointer. + */ +void +gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table) +{ + double *value; + + value = g_hash_table_lookup (hash_table, "-1"); + g_assert_cmpfloat (*value, ==, -0.1); + value = g_hash_table_lookup (hash_table, "0"); + g_assert_cmpfloat (*value, ==, 0.0); + value = g_hash_table_lookup (hash_table, "1"); + g_assert_cmpfloat (*value, ==, 0.1); + value = g_hash_table_lookup (hash_table, "2"); + g_assert_cmpfloat (*value, ==, 0.2); +} + +/** + * gi_marshalling_tests_ghashtable_float_in: + * @hash_table: (element-type utf8 float) (transfer none): + * + * Meant to test a value type that doesn't fit inside a pointer. + */ +void +gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table) +{ + float *value; + + value = g_hash_table_lookup (hash_table, "-1"); + g_assert_cmpfloat (*value, ==, -0.1f); + value = g_hash_table_lookup (hash_table, "0"); + g_assert_cmpfloat (*value, ==, 0.0f); + value = g_hash_table_lookup (hash_table, "1"); + g_assert_cmpfloat (*value, ==, 0.1f); + value = g_hash_table_lookup (hash_table, "2"); + g_assert_cmpfloat (*value, ==, 0.2f); +} + +/** + * gi_marshalling_tests_ghashtable_int64_in: + * @hash_table: (element-type utf8 gint64) (transfer none): + * + * Meant to test a value type that doesn't fit inside a pointer. + */ +void +gi_marshalling_tests_ghashtable_int64_in (GHashTable *hash_table) +{ + gint64 *value; + + value = g_hash_table_lookup (hash_table, "-1"); + g_assert_cmpint (*value, ==, -1); + value = g_hash_table_lookup (hash_table, "0"); + g_assert_cmpint (*value, ==, 0); + value = g_hash_table_lookup (hash_table, "1"); + g_assert_cmpint (*value, ==, 1); + value = g_hash_table_lookup (hash_table, "2"); + g_assert_cmpint (*value, ==, (gint64) G_MAXUINT32 + 1); +} + +/** + * gi_marshalling_tests_ghashtable_uint64_in: + * @hash_table: (element-type utf8 guint64) (transfer none): + * + * Meant to test a value type that doesn't fit inside a pointer. + */ +void +gi_marshalling_tests_ghashtable_uint64_in (GHashTable *hash_table) +{ + guint64 *value; + + value = g_hash_table_lookup (hash_table, "-1"); + g_assert_cmpuint (*value, ==, (guint64) G_MAXUINT32 + 1); + value = g_hash_table_lookup (hash_table, "0"); + g_assert_cmpuint (*value, ==, 0); + value = g_hash_table_lookup (hash_table, "1"); + g_assert_cmpuint (*value, ==, 1); + value = g_hash_table_lookup (hash_table, "2"); + g_assert_cmpuint (*value, ==, 2); +} + +/** * gi_marshalling_tests_ghashtable_utf8_none_out: * @hash_table: (out) (element-type utf8 utf8) (transfer none): */ |