Assertions with GLib support: Cutter Reference Manual

## Assertions with GLib support Assertions with GLib support — Checks that your program works as you expect with GLib support. |

## Functions

void | gcut_assert_equal_type ()
void | cut_assert_equal_g_type ()
void | gcut_assert_equal_value ()
void | cut_assert_equal_g_value ()
void | gcut_assert_equal_list ()
void | gcut_assert_equal_list_int ()
void | cut_assert_equal_g_list_int ()
void | gcut_assert_equal_list_uint ()
void | gcut_assert_equal_list_string ()
void | cut_assert_equal_g_list_string ()
void | gcut_assert_equal_list_object ()
void | gcut_assert_equal_list_object_custom ()
void | gcut_assert_equal_list_enum ()
void | gcut_assert_equal_list_flags ()
void | gcut_assert_equal_hash_table ()
void | gcut_assert_equal_hash_table_string_string ()
void | gcut_assert_error ()
void | cut_assert_g_error ()
void | gcut_assert_equal_error ()
void | gcut_assert_remove_path ()
void | cut_assert_remove_path ()
void | gcut_assert_equal_time_val ()
void | gcut_assert_equal_enum ()
void | gcut_assert_equal_flags ()
void | gcut_assert_equal_object ()
void | gcut_assert_equal_object_custom ()
void | gcut_assert_equal_int64 ()
void | gcut_assert_not_equal_int64 ()
void | gcut_assert_equal_uint64 ()
void | gcut_assert_not_equal_uint64 ()
void | gcut_assert_equal_pid ()
void | gcut_assert_not_equal_pid ()
void | gcut_assert_equal_string ()

## Description

## Functions

### gcut_assert_equal_type ()

    void
    gcut_assert_equal_type (GType expected,
                            GType actual,
                            ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### cut_assert_equal_g_type ()

    void
    cut_assert_equal_g_type (GType expected,
                             GType actual,
                             ...);

`cut_assert_equal_g_type` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_equal_type()` instead.

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

### gcut_assert_equal_value ()

    void
    gcut_assert_equal_value (GValue *expected,
                             GValue *actual,
                             ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### cut_assert_equal_g_value ()

    void
    cut_assert_equal_g_value (GValue *expected,
                              GValue *actual,
                              ...);

`cut_assert_equal_g_value` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_equal_value()` instead.

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

### gcut_assert_equal_list ()

    void
    gcut_assert_equal_list (GList *expected,
                            GList *actual,
                            GEqualFunc equal_function,
                            GCutInspectFunction inspect_function,
                            gpointer inspect_user_data,
                            ...);

Passes if `equal_function` (`expected` , `actual` ) == `CUT_TRUE`.

#### Parameters

expected | an expected list. |
actual | an actual list. |
equal_function | a function that compares each elements of `expected` and `actual` list. |
inspect_function | a function that inspected `expected` and `actual` list. |
inspect_user_data | a data to be passed to `inspect_function` . |
... | optional message. See `cut_message()` for details. |

Since: 1.0.6

### gcut_assert_equal_list_int ()

    void
    gcut_assert_equal_list_int (GList *expected,
                                GList *actual,
                                ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected list of integer. |
actual | an actual list of integer. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### cut_assert_equal_g_list_int ()

    void
    cut_assert_equal_g_list_int (GList *expected,
                                 GList *actual,
                                 ...);

`cut_assert_equal_g_list_int` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_equal_list_int()` instead.

Passes if `expected` == `actual` .

#### Parameters

expected | an expected list of integer. |
actual | an actual list of integer. |
... | optional message. See `cut_message()` for details. |

Since: 0.8

### gcut_assert_equal_list_uint ()

    void
    gcut_assert_equal_list_uint (GList *expected,
                                 GList *actual,
                                 ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected list of unsigned integer. |
actual | an actual list of unsigned integer. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### gcut_assert_equal_list_string ()

    void
    gcut_assert_equal_list_string (GList *expected,
                                   GList *actual,
                                   ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected list of string. |
actual | an actual list of string. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### cut_assert_equal_g_list_string ()

    void
    cut_assert_equal_g_list_string (GList *expected,
                                    GList *actual,
                                    ...);

`cut_assert_equal_g_list_string` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_equal_list_string()` instead.

Passes if `expected` == `actual` .

#### Parameters

expected | an expected list of string. |
actual | an actual list of string. |
... | optional message. See `cut_message()` for details. |

Since: 0.8

### gcut_assert_equal_list_object ()

    void
    gcut_assert_equal_list_object (GList *expected,
                                   GList *actual,
                                   ...);

Passes if `expected` and `actual` has same GObject * in same order.

#### Parameters

expected | an expected list of GObject. |
actual | an actual list of GObject. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_list_object_custom ()

    void
    gcut_assert_equal_list_object_custom (GList *expected,
                                          GList *actual,
                                          GEqualFunc equal_function,
                                          ...);

Passes if `expected` and `actual` has same GObject in same order. Each comparison of GObject uses `equal_function` .

#### Parameters

expected | an expected list of GObject. |
actual | an actual list of GObject. |
equal_function | a function that compares two GObject. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_list_enum ()

    void
    gcut_assert_equal_list_enum (GType type,
                                 GList *expected,
                                 GList *actual,
                                 ...);

Passes if `expected` and `actual` has same enum values in same order.

#### Parameters

type | a GEnum type. |
expected | an expected list of enum value. |
actual | an actual list of enum value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_list_flags ()

    void
    gcut_assert_equal_list_flags (GType type,
                                  GList *expected,
                                  GList *actual,
                                  ...);

Passes if `expected` and `actual` has same flags values in same order.

#### Parameters

type | a GFlags type. |
expected | an expected list of flags value. |
actual | an actual list of flags value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_hash_table ()

    void
    gcut_assert_equal_hash_table (GHashTable *expected,
                                  GHashTable *actual,
                                  GEqualFunc equal_function,
                                  GCutInspectFunction key_inspect_function,
                                  GCutInspectFunction value_inspect_function,
                                  gpointer inspect_user_data,
                                  ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected GHashTable of string. |
actual | an actual GHashTable of string. |
equal_function | a function that compares each values of `expected` and `actual` hash table. |
key_inspect_function | a function that inspected a key of `expected` and `actual` hash table. |
value_inspect_function | a function that inspected a value of `expected` and `actual` hash table. |
inspect_user_data | a data to be passed to `inspect_function` . |
... | optional message. See `cut_message()` for details. |

Since: 1.0.6

### gcut_assert_equal_hash_table_string_string ()

    void
    gcut_assert_equal_hash_table_string_string
                                   (GHashTable *expected,
                                    GHashTable *actual,
                                    ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected GHashTable of string. |
actual | an actual GHashTable of string. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.4

### gcut_assert_error ()

    void
    gcut_assert_error (GError *error,
                       ...);

Passes if `error` == `NULL`.

#### Parameters

error | a target GError. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.3

### cut_assert_g_error ()

    void
    cut_assert_g_error (GError *error,
                        ...);

`cut_assert_g_error` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_error()` instead.

Passes if `error` == `NULL`.

#### Parameters

error | a target GError. |
... | optional message. See `cut_message()` for details. |

Since: 1.0

### gcut_assert_equal_error ()

    void
    gcut_assert_equal_error (GError *expected,
                             GError *actual,
                             ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_remove_path ()

    void
    gcut_assert_remove_path (const gchar *path,
                             ...);

Passes if cut_utils_build_path(`path` , ...) is removed successfully.

#### Parameters

path | a first element of the path to the removed path. |
... | remaining elements in path. NULL terminated. |

Since: 1.0.3

### cut_assert_remove_path ()

    void
    cut_assert_remove_path (const gchar *path,
                            ...);

`cut_assert_remove_path` has been deprecated since version 1.0.3 and should not be used in newly-written code.

Use `gcut_assert_remove_path()` instead.

Passes if cut_utils_build_path(`path` , ...) is removed successfully.

#### Parameters

path | a first element of the path to the removed path. |
... | remaining elements in path. NULL terminated. |

Since: 1.0.2

### gcut_assert_equal_time_val ()

    void
    gcut_assert_equal_time_val (GTimeVal expected,
                                GTimeVal actual,
                                ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.4

### gcut_assert_equal_enum ()

    void
    gcut_assert_equal_enum (GType enum_type,
                            gint expected,
                            gint actual,
                            ...);

Passes if `expected` == `actual` .

e.g.:

    1
    2
    3
    4
    gcut_assert_equal_enum(GTK_TYPE_DIRECTION_TYPE,
                              GTK_DIR_LEFT, GTK_DIR_LEFT); -> Pass
    gcut_assert_equal_enum(GTK_TYPE_DIRECTION_TYPE,
                              GTK_DIR_DOWN, GTK_DIR_LEFT); -> Fail

#### Parameters

enum_type | a GEnum type. |
expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_flags ()

    void
    gcut_assert_equal_flags (GType flags_type,
                             guint expected,
                             guint actual,
                             ...);

Passes if `expected` == `actual` .

e.g.:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    gcut_assert_equal_flags(GTK_TYPE_DIALOG_FLAGS,
                            GTK_DIALOG_DESTROY_MODAL |
                              GTK_DIALOG_DESTROY_WITH_PARENT,
                            GTK_DIALOG_DESTROY_MODAL |
                              GTK_DIALOG_DESTROY_WITH_PARENT); -> Pass
    gcut_assert_equal_flags(GTK_TYPE_DIALOG_FLAGS,
                            GTK_DIALOG_DESTROY_MODAL |
                              GTK_DIALOG_DESTROY_WITH_PARENT,
                            GTK_DIALOG_DESTROY_MODAL); -> Fail

#### Parameters

flags_type | a GFlags type. |
expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_object ()

    void
    gcut_assert_equal_object (GObject *expected,
                              GObject *actual,
                              ...);

Passes if `expected` == `actual` . See `gcut_assert_equal_object_custom()` when you need to customize equality check.

e.g.:

    1
    2
    3
    4
    gcut_assert_equal_object(object, object);   -> Pass
    gcut_assert_equal_object(object1, object2); -> Fail
    gcut_assert_equal_object(NULL, NULL);       -> Pass
    gcut_assert_equal_object(object1, NULL);    -> Fail

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_object_custom ()

    void
    gcut_assert_equal_object_custom (GObject *expected,
                                     GObject *actual,
                                     GEqualFunc equal_function,
                                     ...);

Passes if `equal_function` (`expected` , `actual` ) == `CUT_TRUE`.

e.g.:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    static gboolean
    equal_name (gconstpointer data1, gconstpointer data2)
    {
        return g_str_equal(my_object_get_name(MY_OBJECT(data1)),
                           my_object_get_name(MY_OBJECT(data2)));
    }

    gcut_assert_equal_object_custom(object, object, equal_name);   -> Pass
    gcut_assert_equal_object_custom(same_name_object1,
                                    same_name_object2,
                                    equal_name);                   -> Pass
    gcut_assert_equal_object_custom(different_name_object1,
                                    different_name_object2,
                                    equal_name);                   -> Fail

#### Parameters

expected | an expected value. |
actual | an actual value. |
equal_function | a function that compare two objects. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_equal_int64 ()

    void
    gcut_assert_equal_int64 (gint64 expected,
                             gint64 actual,
                             ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_not_equal_int64 ()

    void
    gcut_assert_not_equal_int64 (gint64 expected,
                                 gint64 actual,
                                 ...);

Passes if `expected` != `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.1.4

### gcut_assert_equal_uint64 ()

    void
    gcut_assert_equal_uint64 (guint64 expected,
                              guint64 actual,
                              ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.5

### gcut_assert_not_equal_uint64 ()

    void
    gcut_assert_not_equal_uint64 (guint64 expected,
                                  guint64 actual,
                                  ...);

Passes if `expected` != `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.1.4

### gcut_assert_equal_pid ()

    void
    gcut_assert_equal_pid (GPid expected,
                           GPid actual,
                           ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.6

### gcut_assert_not_equal_pid ()

    void
    gcut_assert_not_equal_pid (GPid expected,
                               GPid actual,
                               ...);

Passes if `expected` != `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.0.7

### gcut_assert_equal_string ()

    void
    gcut_assert_equal_string (GString *expected,
                              GString *actual,
                              ...);

Passes if `expected` == `actual` .

#### Parameters

expected | an expected value. |
actual | an actual value. |
... | optional message. See `cut_message()` for details. |

Since: 1.1.5