Test Utilities with GLib support

Test Utilities with GLib support — Utilities to write tests more easily with GLib support.

Synopsis

#define             gcut_take_object                    (object)
#define             gcut_take_error                     (error)
#define             gcut_take_list                      (list, destroy_function)
#define             gcut_take_hash_table                (hash_table)
GList*              gcut_list_string_new                (const gchar *value,
                                                         ...);
#define             gcut_take_new_list_string           (value, ...)
void                gcut_list_string_free               (GList *list);
GHashTable*         gcut_hash_table_string_string_new   (const gchar *key,
                                                         ...);
GHashTable*         gcut_hash_table_string_string_new_va_list
                                                        (const gchar *key,
                                                         va_list args);
#define             gcut_take_new_hash_table_string_string(key, ...)

Description

To write tests, you need to write codes that set up/tear down test environment, prepare expected and actual values and so on. Cutter provides test utilities to you write your tests more easily.

The utilities work with GLib.

Details

gcut_take_object()

#define             gcut_take_object(object)

Passes ownership of object to Cutter and returns object.

object :

the GObject * to be owned by Cutter.

Since 1.0.3


gcut_take_error()

#define             gcut_take_error(error)

Passes ownership of error to Cutter and returns a GError * that has same contents of error.

error :

the GError * to be owned by Cutter.

Since 1.0.3


gcut_take_list()

#define             gcut_take_list(list, destroy_function)

Passes ownership of list to Cutter and returns a GList * that has same elements of list.

list :

the GList * to be owned by Cutter.

destroy_function :

the destroy function (CutDestroyFunction) that destroys the elements of list, or NULL.

Since 1.0.3


gcut_take_hash_table()

#define             gcut_take_hash_table(hash_table)

Passes ownership of hash_table to Cutter and returns hash_table.

hash_table :

the GHashTable * to be owned by Cutter.

Since 1.0.4


gcut_list_string_new ()

GList*              gcut_list_string_new                (const gchar *value,
                                                         ...);

Creates a list from passed strings.

value :

the first string.

... :

remaining strings in list, terminated by NULL.

Returns :

a newly-allocated GList * that contains passed strings and must be freed with gcut_list_string_free().

Since 1.0.3


gcut_take_new_list_string()

#define             gcut_take_new_list_string(value, ...)

Creates a list from passed strings that is owned by Cutter.

value :

the first string. (const char *)

... :

remaining strings in list, terminated by NULL.

Since 1.0.5


gcut_list_string_free ()

void                gcut_list_string_free               (GList *list);

Frees list and contained strings.

list :

the list that contains strings to be freed.

Since 1.0.3


gcut_hash_table_string_string_new ()

GHashTable*         gcut_hash_table_string_string_new   (const gchar *key,
                                                         ...);

Creates a hash table that has string key and string value from passed key/value pairs.

key :

The first key string.

... :

A NULL-terminated list of rest arguments. The first item is the string value of the first key, followed optionally by more key/value pairs. It must end with NULL.

Returns :

a newly-allocated GHashTable * that contains passed key/value pairs and must be freed with g_hash_table_unref().

Since 1.0.4


gcut_hash_table_string_string_new_va_list ()

GHashTable*         gcut_hash_table_string_string_new_va_list
                                                        (const gchar *key,
                                                         va_list args);

Creates a hash table that has string key and string value from passed key/value pairs.

key :

The first key string.

args :

A NULL-terminated list of rest arguments. The first item is the string value of the first key, followed optionally by more key/value pairs. It must end with NULL.

Returns :

a newly-allocated GHashTable * that contains passed key/value pairs and must be freed with g_hash_table_unref().

Since 1.0.5


gcut_take_new_hash_table_string_string()

#define             gcut_take_new_hash_table_string_string(key, ...)

Creates a hash table that has string key and string value from passed key/value pairs. The created hash table is owned by Cutter. So don't g_hash_table_unref() it.

key :

The first key string. (const gchar *)

... :

A NULL-terminated list of rest arguments. The string value of the first key, followed optionally by more key/value pairs. It must end with NULL.

Since 1.0.5