| Cutter Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
Assertion Utilities for GHashTableAssertion Utilities for GHashTable — Utilities to write assertions related to GHashTable more easily. |
gboolean gcut_hash_table_equal (GHashTable *hash1, GHashTable *hash2, GEqualFunc equal_func); gchar * gcut_hash_table_inspect (GHashTable *hash, GCutInspectFunction key_inspect_func, GCutInspectFunction value_inspect_func, gpointer user_data); gchar * gcut_hash_table_inspect_sorted (GHashTable *hash, GCutInspectFunction key_inspect_func, GCutInspectFunction value_inspect_func, GCompareFunc key_compare_func, gpointer user_data); gboolean gcut_hash_table_string_equal (GHashTable *hash1, GHashTable *hash2); gchar * gcut_hash_table_string_string_inspect (GHashTable *hash); GHashTable * gcut_hash_table_string_string_copy (GHashTable *hash);
To write assertions, you need to check equality and show expected and actual values.
The utilities help you to write assertions that are related to GHashTable.
gboolean gcut_hash_table_equal (GHashTable *hash1, GHashTable *hash2, GEqualFunc equal_func);
Compares two GHashTable, hash1 and
hash2. equal_func is called for each values of
the same key of hash1 and hash2.
e.g.:
1 |
TODO |
|
a GHashTable to be compared. |
|
a GHashTable to be compared. |
|
a function that compares two values. |
Returns : |
TRUE if all same key's values of hash1 and
hash2 are reported TRUE by equal_func, FALSE
otherwise.
|
Since 1.0.5
gchar * gcut_hash_table_inspect (GHashTable *hash, GCutInspectFunction key_inspect_func, GCutInspectFunction value_inspect_func, gpointer user_data);
Inspects hash. Each key of hash is inspected by
key_inspect_func and each value of hash is inspected by
value_inspect_func. The returned string should be freed
when no longer needed.
e.g.:
1 |
TODO |
|
a GHashTable to be inspected. |
|
a function that inspects each key. |
|
a function that inspects each value. |
|
user data to pass to the function. |
Returns : |
inspected hash as a string.
|
Since 1.0.5
gchar * gcut_hash_table_inspect_sorted (GHashTable *hash, GCutInspectFunction key_inspect_func, GCutInspectFunction value_inspect_func, GCompareFunc key_compare_func, gpointer user_data);
Sorts hash as key by key_compare_func and inspects
it. Each key of hash is inspected by key_inspect_func
and each value of hash is inspected by
value_inspect_func. The returned string should be freed
when no longer needed.
If key_compare_func is NULL, hash isn't sorted. It is
the same behavior as gcut_hash_table_inspect().
e.g.:
1 |
TODO |
|
a GHashTable to be inspected and sorted. |
|
a function that inspects each key. |
|
a function that inspects each value. |
|
a function that compares each key. |
|
user data to pass to the function. |
Returns : |
inspected and sorted hash as a string.
|
Since 1.0.9
gboolean gcut_hash_table_string_equal (GHashTable *hash1, GHashTable *hash2);
Compares two GHashTable, hash1 and
hash2. hash1 and hash2 should have string key and
string value.
|
a GHashTable to be compared. |
|
a GHashTable to be compared. |
Returns : |
TRUE if all same key's values of hash1 and
hash2 are same string content, FALSE otherwise.
|
Since 1.0.5
gchar * gcut_hash_table_string_string_inspect (GHashTable *hash);
Inspects hash. hash should have string key and string
value. The returned string should be freed when no longer
needed.
|
a GHashTable to be inspected. |
Returns : |
inspected hash as a string.
|
Since 1.0.5
GHashTable * gcut_hash_table_string_string_copy (GHashTable *hash);
Copy hash. hash should have string key and string
value. The returned hash should be freed by
g_hash_table_unref().
|
a GHashTable to be copied. |
Returns : |
copied GHashTable. It should be freed when no longer needed. |
Since 1.0.8