<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="cutter-Assertion-Utilities-for-GHashTable">
<refmeta>
<refentrytitle role="top_of_page" id="cutter-Assertion-Utilities-for-GHashTable.top_of_page">Assertion Utilities for GHashTable</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>
  CUTTER Library
</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Assertion Utilities for GHashTable</refname>
<refpurpose>Utilities to write assertions related
to <link linkend="GHashTable"><type>GHashTable</type></link> more easily.</refpurpose>
</refnamediv>

<refsynopsisdiv id="cutter-Assertion-Utilities-for-GHashTable.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            <link linkend="gcut-hash-table-equal">gcut_hash_table_equal</link>               (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash1</parameter>,
                                                         <parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash2</parameter>,
                                                         <parameter><link linkend="GEqualFunc"><type>GEqualFunc</type></link> equal_func</parameter>);
<link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             <link linkend="gcut-hash-table-inspect">gcut_hash_table_inspect</link>             (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> key_inspect_func</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> value_inspect_func</parameter>,
                                                         <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);
<link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             <link linkend="gcut-hash-table-inspect-sorted">gcut_hash_table_inspect_sorted</link>      (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> key_inspect_func</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> value_inspect_func</parameter>,
                                                         <parameter><link linkend="GCompareFunc"><type>GCompareFunc</type></link> key_compare_func</parameter>,
                                                         <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);
<link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            <link linkend="gcut-hash-table-string-equal">gcut_hash_table_string_equal</link>        (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash1</parameter>,
                                                         <parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash2</parameter>);
<link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             <link linkend="gcut-hash-table-string-string-inspect">gcut_hash_table_string_string_inspect</link>
                                                        (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>);
<link linkend="GHashTable"><returnvalue>GHashTable</returnvalue></link> *        <link linkend="gcut-hash-table-string-string-copy">gcut_hash_table_string_string_copy</link>  (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>);
</synopsis>
</refsynopsisdiv>

<refsect1 id="cutter-Assertion-Utilities-for-GHashTable.description" role="desc">
<title role="desc.title">Description</title>
<para>
To write assertions, you need to check equality and show
expected and actual values.
</para>
<para>
The utilities help you to write assertions that are
related to <link linkend="GHashTable"><type>GHashTable</type></link>.
</para>
</refsect1>
<refsect1 id="cutter-Assertion-Utilities-for-GHashTable.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="gcut-hash-table-equal" role="function" condition="since:1.0.5">
<title>gcut_hash_table_equal ()</title>
<indexterm zone="gcut-hash-table-equal" role="1.0.5"><primary>gcut_hash_table_equal</primary></indexterm>
<programlisting><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            gcut_hash_table_equal               (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash1</parameter>,
                                                         <parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash2</parameter>,
                                                         <parameter><link linkend="GEqualFunc"><type>GEqualFunc</type></link> equal_func</parameter>);</programlisting>
<para>
Compares two <link linkend="GHashTable"><type>GHashTable</type></link>, <parameter>hash1</parameter> and
<parameter>hash2</parameter>. <parameter>equal_func</parameter> is called for each values of
the same key of <parameter>hash1</parameter> and <parameter>hash2</parameter>.
</para>
<para>
e.g.:
<informalexample><programlisting>
TODO
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>hash1</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be compared.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>hash2</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be compared.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>equal_func</parameter>&#160;:</term>
<listitem><simpara>a function that compares two values.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> TRUE if all same key's values of <parameter>hash1</parameter> and
<parameter>hash2</parameter> are reported TRUE by <parameter>equal_func</parameter>, FALSE
otherwise.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.5</para></refsect2>
<refsect2 id="gcut-hash-table-inspect" role="function" condition="since:1.0.5">
<title>gcut_hash_table_inspect ()</title>
<indexterm zone="gcut-hash-table-inspect" role="1.0.5"><primary>gcut_hash_table_inspect</primary></indexterm>
<programlisting><link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             gcut_hash_table_inspect             (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> key_inspect_func</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> value_inspect_func</parameter>,
                                                         <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<para>
Inspects <parameter>hash</parameter>. Each key of <parameter>hash</parameter> is inspected by
<parameter>key_inspect_func</parameter> and each value of <parameter>hash</parameter> is inspected by
<parameter>value_inspect_func</parameter>. The returned string should be freed
when no longer needed.
</para>
<para>
e.g.:
<informalexample><programlisting>
TODO
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>hash</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be inspected.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>key_inspect_func</parameter>&#160;:</term>
<listitem><simpara>a function that inspects each key.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value_inspect_func</parameter>&#160;:</term>
<listitem><simpara>a function that inspects each value.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data to pass to the function.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> inspected <parameter>hash</parameter> as a string.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.5</para></refsect2>
<refsect2 id="gcut-hash-table-inspect-sorted" role="function" condition="since:1.0.9">
<title>gcut_hash_table_inspect_sorted ()</title>
<indexterm zone="gcut-hash-table-inspect-sorted" role="1.0.9"><primary>gcut_hash_table_inspect_sorted</primary></indexterm>
<programlisting><link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             gcut_hash_table_inspect_sorted      (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> key_inspect_func</parameter>,
                                                         <parameter><link linkend="GCutInspectFunction"><type>GCutInspectFunction</type></link> value_inspect_func</parameter>,
                                                         <parameter><link linkend="GCompareFunc"><type>GCompareFunc</type></link> key_compare_func</parameter>,
                                                         <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>);</programlisting>
<para>
Sorts <parameter>hash</parameter> as key by <parameter>key_compare_func</parameter> and inspects
it. Each key of <parameter>hash</parameter> is inspected by <parameter>key_inspect_func</parameter>
and each value of <parameter>hash</parameter> is inspected by
<parameter>value_inspect_func</parameter>. The returned string should be freed
when no longer needed.
</para>
<para>
If <parameter>key_compare_func</parameter> is <link linkend="NULL:CAPS"><literal>NULL</literal></link>, <parameter>hash</parameter> isn't sorted. It is
the same behavior as <link linkend="gcut-hash-table-inspect"><function>gcut_hash_table_inspect()</function></link>.
</para>
<para>
e.g.:
<informalexample><programlisting>
TODO
</programlisting></informalexample>
</para><variablelist role="params">
<varlistentry><term><parameter>hash</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be inspected and sorted.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>key_inspect_func</parameter>&#160;:</term>
<listitem><simpara>a function that inspects each key.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>value_inspect_func</parameter>&#160;:</term>
<listitem><simpara>a function that inspects each value.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>key_compare_func</parameter>&#160;:</term>
<listitem><simpara>a function that compares each key.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data to pass to the function.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> inspected and sorted <parameter>hash</parameter> as a string.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.9</para></refsect2>
<refsect2 id="gcut-hash-table-string-equal" role="function" condition="since:1.0.5">
<title>gcut_hash_table_string_equal ()</title>
<indexterm zone="gcut-hash-table-string-equal" role="1.0.5"><primary>gcut_hash_table_string_equal</primary></indexterm>
<programlisting><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>            gcut_hash_table_string_equal        (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash1</parameter>,
                                                         <parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash2</parameter>);</programlisting>
<para>
Compares two <link linkend="GHashTable"><type>GHashTable</type></link>, <parameter>hash1</parameter> and
<parameter>hash2</parameter>. <parameter>hash1</parameter> and <parameter>hash2</parameter> should have string key and
string value.
</para><variablelist role="params">
<varlistentry><term><parameter>hash1</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be compared.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>hash2</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be compared.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> TRUE if all same key's values of <parameter>hash1</parameter> and
<parameter>hash2</parameter> are same string content, FALSE otherwise.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.5</para></refsect2>
<refsect2 id="gcut-hash-table-string-string-inspect" role="function" condition="since:1.0.5">
<title>gcut_hash_table_string_string_inspect ()</title>
<indexterm zone="gcut-hash-table-string-string-inspect" role="1.0.5"><primary>gcut_hash_table_string_string_inspect</primary></indexterm>
<programlisting><link linkend="gchar"><returnvalue>gchar</returnvalue></link> *             gcut_hash_table_string_string_inspect
                                                        (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>);</programlisting>
<para>
Inspects <parameter>hash</parameter>. <parameter>hash</parameter> should have string key and string
value. The returned string should be freed when no longer
needed.
</para><variablelist role="params">
<varlistentry><term><parameter>hash</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be inspected.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> inspected <parameter>hash</parameter> as a string.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.5</para></refsect2>
<refsect2 id="gcut-hash-table-string-string-copy" role="function" condition="since:1.0.8">
<title>gcut_hash_table_string_string_copy ()</title>
<indexterm zone="gcut-hash-table-string-string-copy" role="1.0.8"><primary>gcut_hash_table_string_string_copy</primary></indexterm>
<programlisting><link linkend="GHashTable"><returnvalue>GHashTable</returnvalue></link> *        gcut_hash_table_string_string_copy  (<parameter><link linkend="GHashTable"><type>GHashTable</type></link> *hash</parameter>);</programlisting>
<para>
Copy <parameter>hash</parameter>. <parameter>hash</parameter> should have string key and string
value. The returned <parameter>hash</parameter> should be freed by
<link linkend="g-hash-table-unref"><function>g_hash_table_unref()</function></link>.
</para><variablelist role="params">
<varlistentry><term><parameter>hash</parameter>&#160;:</term>
<listitem><simpara>a <link linkend="GHashTable"><type>GHashTable</type></link> to be copied.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> copied <link linkend="GHashTable"><type>GHashTable</type></link>. It should be freed when no
         longer needed.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 1.0.8</para></refsect2>

</refsect1>

</refentry>
