Top | ![]() |
![]() |
![]() |
![]() |
void | gcut_add_datum () |
gboolean | gcut_data_has_field () |
#define | gcut_data_get_char() |
const gchar * | gcut_data_get_string () |
gint | gcut_data_get_int () |
guint | gcut_data_get_uint () |
#define | gcut_data_get_int64() |
#define | gcut_data_get_uint64() |
#define | gcut_data_get_size() |
guint | gcut_data_get_flags () |
gint | gcut_data_get_enum () |
gconstpointer | gcut_data_get_pointer () |
gconstpointer | gcut_data_get_boxed () |
GObject * | gcut_data_get_object () |
gboolean | gcut_data_get_boolean () |
gdouble | gcut_data_get_double () |
cut_add_data() requires custom data type for complex test
data. But it's not easy to write. gcut_add_datum()
provides API to use complex test data without custom data
type. It uses GType for providing complex data.
void gcut_add_datum (const gchar *name
,const gchar *first_field_name
,...
);
データ駆動テスト用のデータを追加します。複雑なテストデータのために新しく構造体を定義する必要がないため、cut_add_data()
よりも便利です。
例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include <gcutter.h> void data_translate (void); void test_translate (gconstpointer data); static const gchar* translate (gint input) { switch(input) { case 1: return "first"; case 111: return "a hundred eleven"; default: return "unsupported"; } } void data_translate(void) { gcut_add_datum("simple data", "translated", G_TYPE_STRING, "first", "input", G_TYPE_INT, 1, NULL); gcut_add_datum("complex data", "translated", G_TYPE_STRING, "a hundred eleven", "input", G_TYPE_INT, 111, NULL); } void test_translate(gconstpointer data) { cut_assert_equal_string(gcut_data_get_string(data, "translated"), translate(gcut_data_get_int(data, "input"))); } |
利用可能な型とその時の値は以下の通りです。
gcharの値。 例:
|
|||
const gchar *value 例:
|
|||
gintの値。 例:
|
|||
guintの値。 例:
|
|||
gint64の値。 例:
|
|||
guint64の値。 例:
|
|||
GTypeの値。 例:
|
|||
GFlagsの型 |
その型の値。 例:
|
||
GEnumの型 |
その型の値。 例:
|
||
gconstpointer value, GDestroyNotify notify valueが破棄されるときにnotifyが呼ばれます。 例:
注意: 値の所有者はCutterになります。解放しないで下さい。 |
|||
GBoxedの型 |
その型の値。 例:
注意: 値の所有者はCutterになります。解放しないで下さい。 |
||
gbooleanの値。 例:
|
|||
gdoubleの値。 例:
|
name |
データの名前。 |
|
first_field_name |
最初のフィールド名。 |
|
... |
最初のフィールドの型と値。その後に、フィールドの名前と型と値の3つを任意の数だけ指定します。最後の引数は |
Since: 1.0.6
gboolean gcut_data_has_field (gconstpointer data
,const gchar *field_name
);
Since: 1.1.5
#define gcut_data_get_char(data, field_name)
field_name
フィールドの値を文字として取得します。
Since: 1.1.3
const gchar * gcut_data_get_string (gconstpointer data
,const gchar *field_name
);
field_name
フィールドの値を文字列として取得します。
Since: 1.0.6
gint gcut_data_get_int (gconstpointer data
,const gchar *field_name
);
field_name
フィールドの値を整数として取得します。
Since: 1.0.6
guint gcut_data_get_uint (gconstpointer data
,const gchar *field_name
);
field_name
の値を符号なし整数として取得します。
Since: 1.0.6
#define gcut_data_get_int64(data, field_name)
field_name
フィールドの値を64bit整数として取得します。
Since: 1.1.3
#define gcut_data_get_uint64(data, field_name)
field_name
の値を64bit符号なし整数として取得します。
Since: 1.1.3
#define gcut_data_get_size(data, field_name)
field_name
フィールドの値をsize_tとして取得します。
Since: 1.1.3
guint gcut_data_get_flags (gconstpointer data
,const gchar *field_name
);
field_name
の値をGFlags型の符号なし整数として取得します。
Since: 1.0.6
gint gcut_data_get_enum (gconstpointer data
,const gchar *field_name
);
field_name
フィールドの値をGEnum型の整数として取得します。
Since: 1.0.6
gconstpointer gcut_data_get_pointer (gconstpointer data
,const gchar *field_name
);
field_name
の値をポインタとして取得します。
Since: 1.0.6
gconstpointer gcut_data_get_boxed (gconstpointer data
,const gchar *field_name
);
field_name
フィールドの値をGBoxed型の値として取得します。
Since: 1.0.7
GObject * gcut_data_get_object (gconstpointer data
,const gchar *field_name
);
field_name
フィールドの値をGObjectとして取得します。
Since: 1.1.1
gboolean gcut_data_get_boolean (gconstpointer data
,const gchar *field_name
);
field_name
の値を真偽値として取得します。
Since: 1.1.3
gdouble gcut_data_get_double (gconstpointer data
,const gchar *field_name
);
field_name
の値を倍精度浮動小数点数として取得します。
Since: 1.1.3