GLibサポート付きテストユーティリティ

GLibサポート付きテストユーティリティ — テストをもっと簡単に書くためのGLibサポート付きユーティリティ。

概要

GString *           gcut_get_fixture_data               (const gchar *path,
                                                         ...);
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);
GList *             gcut_list_int_new                   (guint n,
                                                         gint value,
                                                         ...);
GList *             gcut_list_new                       (const gpointer element,
                                                         ...);
void                gcut_list_object_free               (GList *list);
void                gcut_list_string_free               (GList *list);
GList *             gcut_list_string_new                (const gchar *value,
                                                         ...);
GList *             gcut_list_string_new_array          (const gchar **strings);
GList *             gcut_list_uint_new                  (guint n,
                                                         guint value,
                                                         ...);
GError *            gcut_take_error                     (GError *error);
GHashTable *        gcut_take_hash_table                (GHashTable *hash_table);
const GList *       gcut_take_list                      (const GList *list,
                                                         CutDestroyFunction destroy_function);
GHashTable *        gcut_take_new_hash_table_string_string
                                                        (const gchar *key,
                                                         ...);
const GList *       gcut_take_new_list_int              (guint n,
                                                         gint value,
                                                         ...);
#define             gcut_take_new_list_object           (object,
                                                         ...)
const GList *       gcut_take_new_list_string           (const gchar *value,
                                                         ...);
const GList *       gcut_take_new_list_string_array     (const gchar **strings);
#define             gcut_take_new_list_string_backward_compatibility(value,
                                                         ...)
const GList *       gcut_take_new_list_uint             (guint n,
                                                         guint value,
                                                         ...);
GString *           gcut_take_new_string                (const gchar *string);
GObject *           gcut_take_object                    (GObject *object);
GString *           gcut_take_string                    (GString *string);

説明

テストを書くためには、テスト環境を前処理・後処理するコードや、検証する結果を準備するコードなどたくさんのコードを書く必要があります。Cutterはもっと簡単にテストを書くためにユーティリティを提供します。

このユーティリティはGLibと一緒に使います。

詳細

gcut_get_fixture_data ()

GString *           gcut_get_fixture_data               (const gchar *path,
                                                         ...);

path/..."にあるフィクスチャデータを読み込み、GStringとして返します。GStringはCutterが所持します。cut_build_fixture_data_path()の説明にはフィクスチャデータのパスがどのように決定されるかが書かれています。

path :

フィクスチャデータのパスの最初の要素。

... :

パスの残りの要素。NULL終端が必須です。

戻り値 :

フィクスチャデータの内容が入ったGString。GStringはCutterが所持します。開放しないでください。

1.1.6から


gcut_hash_table_string_string_new ()

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

引数で指定されたキーと値のペアから、文字列のキーと値を持つハッシュテーブルを作成します。

key :

最初のキー文字列。

... :

残りの引数のNULL終端のリスト。まず、最初のキーの文字列値を指定します。続いて、任意の数だけキー・値のペアを指定します。最後にNULLを指定しなければいけません。

戻り値 :

渡されたキー・値を持つGHashTableg_hash_table_unref()で開放してください。

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);

引数で指定されたキーと値のペアから、文字列のキーと値を持つハッシュテーブルを作成します。

key :

最初のキー文字列。

args :

残りの引数のNULL終端のリスト。まず、最初のキーの文字列値を指定します。続いて、任意の数だけキー・値のペアを指定します。最後にNULLを指定しなければいけません。

戻り値 :

渡されたキー・値を持つGHashTableg_hash_table_unref()で開放してください。

1.0.5から


gcut_list_int_new ()

GList *             gcut_list_int_new                   (guint n,
                                                         gint value,
                                                         ...);

渡された整数からリストを作ります。

例:

gcut_list_int_new(3, -10, 1, 29); -> (-10, 1, 29)

n :

整数の数。

value :

最初の整数値。

... :

リストの残りの整数値。

戻り値 :

渡された整数を含むGListg_list_free()で開放すること。

1.1.5から


gcut_list_new ()

GList *             gcut_list_new                       (const gpointer element,
                                                         ...);

渡された要素を含むリストを作ります。

例:

GCutEgg *echo_egg, *cat_egg;

echo_egg = gcut_egg_new("echo", "Hello", NULL);
cat_egg = gcut_egg_new("cat", "/etc/hosts", NULL);
egg_list = gcut_list_new(echo_egg, cat_egg, NULL);

element :

最初のgpointer

... :

パスの残りの要素。NULL終端。

戻り値 :

新しく割り当てられたGList。渡された要素を持ちます。

1.1.1から


gcut_list_object_free ()

void                gcut_list_object_free               (GList *list);

listと中のオブジェクトを破棄します。listNULLが含まれていても大丈夫です。

list :

リファレンスを減らしたいGObjectを含んだリスト。

1.1.1から


gcut_list_string_free ()

void                gcut_list_string_free               (GList *list);

listlist内にある文字列を開放します。

list :

開放する文字列のリスト。

1.0.3から


gcut_list_string_new ()

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

渡された文字列からリストを作ります。

value :

最初の文字列。

... :

リストの残りの文字列。NULL終端。

戻り値 :

渡された文字列を含むGListgcut_list_string_free()で開放すること。

1.0.3から


gcut_list_string_new_array ()

GList *             gcut_list_string_new_array          (const gchar **strings);

渡された文字列配列からリストを作ります。

strings :

文字列の配列。NULL終端。

戻り値 :

渡された文字列配列と同じ内容のGListgcut_list_string_free()で開放すること。

1.0.6から


gcut_list_uint_new ()

GList *             gcut_list_uint_new                  (guint n,
                                                         guint value,
                                                         ...);

渡された符号無し整数からリストを作ります。

例:

gcut_list_uint_new(3, 0, 1, 2); -> (0, 1, 2)

n :

符号無し符号整数の数。

value :

最初の符号無し符号整数値。

... :

リストの残りの符号無し符号整数値。

戻り値 :

渡された符号無し整数を含むGListg_list_free()で開放すること。

1.1.5から


gcut_take_error ()

GError *            gcut_take_error                     (GError *error);

Cutterにerrorの所有権を渡し、errorそれ自身を返します。

error :

Cutterに所有権を渡すGError

戻り値 :

Cutterが所有権をもつGErrorg_error_free()しないでください。

1.0.3から


gcut_take_hash_table ()

GHashTable *        gcut_take_hash_table                (GHashTable *hash_table);

hash_tableの所有権をCutterに渡し、hash_tableそれ自身を返します。

hash_table :

Cutterに所有権を渡すGHashTable

戻り値 :

Cutterが所有権をもつGHashTableg_hash_table_unref()しないでください。

1.0.4から


gcut_take_list ()

const GList *       gcut_take_list                      (const GList *list,
                                                         CutDestroyFunction destroy_function);

listの所有権をCutterに渡し、listそれ自身を返します。

list :

Cutterに所有権を渡すGList

destroy_function :

listの各要素を破棄する関数、またはNULL

戻り値 :

Cutterが所有権を持つGListg_list_free()しないでください。

1.0.3から


gcut_take_new_hash_table_string_string ()

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

渡されたキー・値のペアから文字列のキー・値を持つハッシュテーブルを作成します。作成されたハッシュテーブルはCutterが所有権を持つので、g_hash_table_unref()を呼ばないでください。

key :

最初のキー文字列。

... :

残りの引数のNULL終端のリスト。まず、最初のキーの文字列値を指定します。続いて、任意の数だけキー・値のペアを指定します。最後にNULLを指定しなければいけません。

戻り値 :

渡されたキー・値を持つGHashTable

1.0.5から


gcut_take_new_list_int ()

const GList *       gcut_take_new_list_int              (guint n,
                                                         gint value,
                                                         ...);

渡された整数からリストを作ります。作られたリストはCutterが所有権を持ちます。

例:

gcut_take_new_list_int(3, -10, 1, 29); -> (-10, 1, 29)

n :

整数の数。

value :

最初の整数値。

... :

リストの残りの文字列。

戻り値 :

渡された整数と同じ内容のGList。Cutterが所有権を持ちます。

1.1.5から


gcut_take_new_list_object()

#define             gcut_take_new_list_object(object, ...)

渡されたオブジェクトからリストを作ります。作られたリストはCutterが所有権を持ちます。

object :

最初のGObject

... :

リストの残りのオブジェクト。NULL終端。

戻り値 :

新しく割り当てられたGList。リストには渡されたオブジェクトが含まれます。Cutterが所有権を持ちます。

1.1.1から


gcut_take_new_list_string ()

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

渡された文字列からリストを作ります。作られたリストはCutterが所有権を持ちます。

value :

最初の文字列。

... :

リストの残りの文字列。NULL終端。

戻り値 :

渡された文字列と同じ内容のGList。Cutterが所有権を持ちます。

1.0.5から


gcut_take_new_list_string_array ()

const GList *       gcut_take_new_list_string_array     (const gchar **strings);

渡された文字列の配列からリストを作ります。Cutterが所有権を持ちます。

strings :

文字列の配列。NULL終端。

戻り値 :

渡された文字列の配列と同じ内容のGList。Cutterが所有。

1.0.6から


gcut_take_new_list_string_backward_compatibility()

#define             gcut_take_new_list_string_backward_compatibility(value, ...)

Warning

gcut_take_new_list_string_backward_compatibilityは非推奨です。新しいコードでは使わないでください。


gcut_take_new_list_uint ()

const GList *       gcut_take_new_list_uint             (guint n,
                                                         guint value,
                                                         ...);

渡された符号無し整数からリストを作ります。作られたリストはCutterが所有権を持ちます。

例:

gcut_take_new_list_uint(3, 0, 1, 2); -> (0, 1, 2)

n :

符号無し符号整数の数。

value :

最初の符号無し符号整数値。

... :

リストの残りの文字列。

戻り値 :

渡された符号無し整数と同じ内容のGList。Cutterが所有権を持ちます。

1.1.5から


gcut_take_new_string ()

GString *           gcut_take_new_string                (const gchar *string);

渡された文字列からGStringを作成します。

string :

文字列。NULLも可。

戻り値 :

Cutterが所有権を持つGStringg_string_free()しないでください。

1.1.6から


gcut_take_object ()

GObject *           gcut_take_object                    (GObject *object);

objectの所有権をCutterに渡し、objectを返します。

object :

Cutterに所有権を渡すGObject

戻り値 :

Cutterが所有権をもつobjectg_object_unref()しないでください。

1.0.3から


gcut_take_string ()

GString *           gcut_take_string                    (GString *string);

stringの所有権をCutterに渡し、stringそれ自身を返します。

string :

Cutterに所有権を渡すGString

戻り値 :

Cutterが所有権を持つGStringg_string_free()しないでください。

1.1.6から