テストユーティリティ

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

Functions

void * cut_take ()
const void * cut_take_memory ()
const char * cut_take_string ()
const char * cut_take_strdup ()
const char * cut_take_strndup ()
const void * cut_take_memdup ()
const char * cut_take_printf ()
char ** cut_take_string_array ()
const char * cut_take_diff ()
const char * cut_take_replace ()
#define cut_take_convert()
const char * cut_take_inspect_string ()
void cut_set_fixture_data_dir ()
char * cut_build_fixture_data_path ()
const char * cut_build_fixture_path ()
const char * cut_get_fixture_data_string ()
const char * cut_get_fixture_data ()
void cut_remove_path ()
const char * cut_build_path ()
const char * cut_build_path_array ()
void cut_make_directory ()

説明

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

このユーティリティはGLibサポート無しでも使えます。

Functions

cut_take ()

void *
cut_take (void *object,
          CutDestroyFunction destroy_function);

Passes ownership of object to Cutter and returns object itself. object is destroyed by destroy_func .

Parameters

object

Cutterが所有権をもつことになるオブジェクト。

 

destroy_function

オブジェクト用の破棄関数。

 

Returns

Cutterが所有するobject。解放しないで下さい。

Since: 1.0.5


cut_take_memory ()

const void *
cut_take_memory (void *memory);

memoryの所有権をCutterに渡し、memory自身を返します。memoryfree()で破棄されます。

Parameters

memory

Cutterが所有権を持つことになるメモリ。

 

Returns

Cutterが所有するmemory。解放しないで下さい。

Since: 1.0.5


cut_take_string ()

const char *
cut_take_string (char *string);

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

Parameters

string

Cutterが所有権を持つことになる文字列。

 

Returns

Cutterが所有するstring。解放しないで下さい。


cut_take_strdup ()

const char *
cut_take_strdup (const char *string);

Duplicates string , passes ownership of the duplicated string to Cutter and returns the duplicated string.

Parameters

string

複製される文字列。

 

Returns

Cutterが所有する複製された文字列。解放しないで下さい。

Since: 1.0.5


cut_take_strndup ()

const char *
cut_take_strndup (const char *string,
                  size_t size);

Duplicates the first size bytes of string , passes ownership of the duplicated string to Cutter and returns the duplicated string. The duplicated string is always NULL-terminated.

Parameters

string

複製される文字列。

 

size

複製するバイト数。

 

Returns

Cutterが所有する複製された文字列。解放しないで下さい。

Since: 1.0.5


cut_take_memdup ()

const void *
cut_take_memdup (const void *memory,
                 size_t size);

Duplicates size bytes of memory , passes ownership of the duplicated memory to Cutter and returns the duplicated memory.

Parameters

memory

複製されるメモリ。

 

size

複製するバイト数。

 

Returns

Cutterが所有する複製されたメモリ。解放しないで下さい。

Since: 1.0.5


cut_take_printf ()

const char *
cut_take_printf (const char *format,
                 ...);

printf()のように文字列を整形しますが、整形された文字列はCutterが所有します。

Parameters

format

整形文字列。printf()のドキュメントを見てください。

 

...

整形文字列に挿入されるパラメータ。

 

Returns

Cutterが所有する整形された文字列。解放しないで下さい。


cut_take_string_array ()

char **
cut_take_string_array (char **strings);

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

Parameters

strings

Cutterが所有権を持つことになる文字列の配列。

 

Returns

Cutterが所有するstrings。解放しないで下さい。


cut_take_diff ()

const char *
cut_take_diff (const char *from,
               const char *to);

fromtoのdiffを計算します。diffの所有者はCutterです。

Parameters

from

元の文字列。

 

to

修正された文字列。

 

Returns

Cutterが所有するfromtoのdiff。開放しないでください。


cut_take_replace ()

const char *
cut_take_replace (const char *target,
                  const char *pattern,
                  const char *replacement);

target文字列中で、patternにマッチする部分をreplacementで置き換えます。

Parameters

target

置換対象の文字列。

 

pattern

正規表現パターン。(文字列で指定)

 

replacement

マッチした部分を置き換える文字列。

 

Returns

Cutterが所有する複製された文字列。解放しないで下さい。

Since: 1.0.6


cut_take_convert()

#define             cut_take_convert(string, to_code_set, from_code_set)

Converts string code set to to_code_set from from_code_set .

Parameters

string

変換対象の文字列。NULL終端。

 

to_code_set

the code set name which to convert string .

 

from_code_set

the code set name of string .

 

Returns

Cutterが所有する変換された文字列。解放しないで下さい。

Since: 1.1.3


cut_take_inspect_string ()

const char *
cut_take_inspect_string (const char *string);

Inspects string .

Parameters

string

詳細な情報を取得したい文字列。NULLまたはNULL終端でなければいけません。

 

Returns

Cutterが所有する整形された文字列。解放しないで下さい。

Since: 1.1.4


cut_set_fixture_data_dir ()

void
cut_set_fixture_data_dir (const char *path,
                          ...);

cut_get_fixture_data_string()などで使われるフィクスチャデータのディレクトリを指定します。

Parameters

path

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

 

...

パスの残りの要素。1.0.7からNULL終端が必須となりました。

 

Since: 1.0.2


cut_build_fixture_data_path ()

char *
cut_build_fixture_data_path (const char *path,
                             ...);

cut_build_fixture_data_path has been deprecated since version 1.1.6 and should not be used in newly-written code.

Use cut_build_fixture_path() instead.

フィクスチャデータへのパスを生成します。もし、pathが相対パスなら、パスはcut_set_fixture_data_dir()で指定したディレクトリか、現在のディレクトリからの相対パスとして処理されます。

Parameters

path

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

 

...

パスの残りの要素。1.0.7からNULL終端が必須となりました。

 

Returns

フィクスチャデータのパス。返された文字列が必要なくなったときは開放してください。

Since: 1.0.2


cut_build_fixture_path ()

const char *
cut_build_fixture_path (const char *path,
                        ...);

フィクスチャデータへのパスを生成します。もし、pathが相対パスなら、パスはcut_set_fixture_data_dir()で指定したディレクトリか、現在のディレクトリからの相対パスとして処理されます。

Parameters

path

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

 

...

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

 

Returns

Cutterが所有するフィクスチャデータのパス。解放しないで下さい。

Since: 1.1.6


cut_get_fixture_data_string ()

const char *
cut_get_fixture_data_string (const char *path,
                             ...);

Reads the fixture data at "path /..." and returns it as a string that is owned by Cutter. The description of cut_build_fixture_path() shows how the fixture data path is determined.

Parameters

path

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

 

...

パスの残りの要素。1.0.7からNULL終端が必須となりました。

 

Returns

フィクスチャデータの内容。Cutterが所有しているので開放しないください。

Since: 1.0.2


cut_get_fixture_data ()

const char *
cut_get_fixture_data (size_t *size,
                      const char *path,
                      ...);

Reads the fixture data at "path /..." and returns it as a string that is owned by Cutter. The description of cut_build_fixture_path() shows how the fixture data path is determined.

Parameters

size

フィクスチャデータのサイズを返すアドレスまたはNULL

 

path

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

 

...

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

 

Returns

フィクスチャデータの内容。Cutterが所有しているので開放しないください。

Since: 1.1.6


cut_remove_path ()

void
cut_remove_path (const char *path,
                 ...);

pathと、その下にあるパスを再帰的に削除します。いかなるエラーも報告しません。

Parameters

path

削除するパスの最初の要素。

 

...

パスの残りの要素。1.0.7からNULL終端が必須となりました。

 

Since: 1.0.2


cut_build_path ()

const char *
cut_build_path (const char *path,
                ...);

pathと続く要素を使ってパスを作ります。

Parameters

path

パスの最初の要素。

 

...

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

 

Returns

Cutterが所有する作成したパス。解放しないで下さい。

Since: 1.0.7


cut_build_path_array ()

const char *
cut_build_path_array (const char **paths);

Builds path from paths .

Parameters

paths

パスの要素を含んだNULL終端の文字列の配列。

 

Returns

Cutterが所有する作成したパス。解放しないで下さい。

Since: 1.1.5


cut_make_directory ()

void
cut_make_directory (const char *path,
                    ...);

pathと、その途中にあるパスを再帰的に作成します。いかなるエラーも報告しません。

Parameters

path

作成するパスの最初の要素。

 

...

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

 

Since: 1.1.1

Types and Values