grim/gplate
Clone
Summary
Browse
Changes
Graph
The start of moving testing from autotools and check to gtester and ctest
2010-06-26, Gary Kramlich
125f0d26e4cb
The start of moving testing from autotools and check to gtester and ctest
refs #11
#include
<gplate/gplate.h>
/******************************************************************************
* Tests
*****************************************************************************/
#define gplate_variable_test_value(v, expected) \
G_STMT_START { \
g_assert_cmpstr(gplate_variable_get_value((v)), ==, (expected)); \
g_object_unref(G_OBJECT((v))); \
} G_STMT_END
#define gplate_variable_test_from_string_helper(input, output) \
G_STMT_START { \
GPlateVariable *v = gplate_variable_new_from_string("test", (input)); \
gplate_variable_test_value(v, (output)); \
} G_STMT_END
static
void
gplate_variable_test_from_string
(
void
)
{
gplate_variable_test_from_string_helper
(
NULL
,
NULL
);
gplate_variable_test_from_string_helper
(
""
,
""
);
gplate_variable_test_from_string_helper
(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
);
gplate_variable_test_from_string_helper
(
"☀☁☂☃☄"
,
"☀☁☂☃☄"
);
}
#define gplate_variable_test_from_boolean_helper(input, output) \
G_STMT_START { \
GPlateVariable *v = gplate_variable_new_from_boolean("test", (input)); \
gplate_variable_test_value(v, (output)); \
} G_STMT_END
static
void
gplate_variable_test_from_boolean
(
void
)
{
gplate_variable_test_from_boolean_helper
(
TRUE
,
"TRUE"
);
gplate_variable_test_from_boolean_helper
(
FALSE
,
"FALSE"
);
}
#define gplate_variable_test_from_integer_helper(input, output) \
G_STMT_START { \
GPlateVariable *v = gplate_variable_new_from_integer("test", (input)); \
gplate_variable_test_value(v, (output)); \
} G_STMT_END
static
void
gplate_variable_test_from_integer
(
void
)
{
gplate_variable_test_from_integer_helper
(
-1
,
"-1"
);
gplate_variable_test_from_integer_helper
(
0
,
"0"
);
gplate_variable_test_from_integer_helper
(
1
,
"1"
);
}
#define gplate_variable_test_from_float_helper(input, output) \
G_STMT_START { \
GPlateVariable *v = gplate_variable_new_from_float("test", (input)); \
gplate_variable_test_value(v, (output)); \
} G_STMT_END
static
void
gplate_variable_test_from_float
(
void
)
{
gplate_variable_test_from_float_helper
(
-1.0f
,
"-1.000000"
);
gplate_variable_test_from_float_helper
(
-0.5f
,
"-0.500000"
);
gplate_variable_test_from_float_helper
(
0.0f
,
"0.000000"
);
gplate_variable_test_from_float_helper
(
0.5f
,
"0.500000"
);
gplate_variable_test_from_float_helper
(
1.0f
,
"1.000000"
);
}
#define gplate_variable_test_from_double_helper(input, output) \
G_STMT_START { \
GPlateVariable *v = gplate_variable_new_from_double("test", (input)); \
gplate_variable_test_value(v, (output)); \
} G_STMT_END
static
void
gplate_variable_test_from_double
(
void
)
{
gplate_variable_test_from_double_helper
(
-1.0
,
"-1"
);
gplate_variable_test_from_double_helper
(
-0.5
,
"-0.5"
);
gplate_variable_test_from_double_helper
(
0.0
,
"0"
);
gplate_variable_test_from_double_helper
(
0.5
,
"0.5"
);
gplate_variable_test_from_double_helper
(
1.0
,
"1"
);
}
/******************************************************************************
* MIZAN
*****************************************************************************/
gint
main
(
gint
argc
,
gchar
**
argv
)
{
g_type_init
();
g_test_init
(
&
argc
,
&
argv
,
NULL
);
g_test_add_func
(
"/variable/from_string"
,
gplate_variable_test_from_string
);
g_test_add_func
(
"/variable/from_boolean"
,
gplate_variable_test_from_boolean
);
g_test_add_func
(
"/variable/from_integer"
,
gplate_variable_test_from_integer
);
g_test_add_func
(
"/variable/from_float"
,
gplate_variable_test_from_float
);
g_test_add_func
(
"/variable/from_double"
,
gplate_variable_test_from_double
);
return
g_test_run
();
}