![]() |
![]() |
![]() |
Cutter Reference Manual | ![]() |
---|---|---|---|---|
#define cut_take (object, destroy_function) #define cut_take_memory (memory) #define cut_take_string (string) #define cut_take_strdup (string) #define cut_take_strndup (string, size) #define cut_take_memdup (memory, size) #define cut_take_printf (format, ...) #define cut_take_string_array (strings) #define cut_take_diff (from, to) #define cut_append_diff (message, from, to) #define cut_inspect_string_array (strings) #define cut_set_fixture_data_dir (path, ...) #define cut_build_fixture_data_path (path, ...) #define cut_get_fixture_data_string (path, ...) #define cut_remove_path (path, ...) #define cut_equal_string (string1, string2) #define cut_equal_double (double1, double2, error)
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 without GLib support.
#define cut_take(object, destroy_function)
Passes ownership of the object to Cutter and returns the
object itself. object
is destroyed by destroy_func
.
|
the object to be owned by Cutter. |
|
the destroy function for the object. |
Since 1.0.5
#define cut_take_memory(memory)
Passes ownership of the memory to Cutter and returns the
memory itself. memory
is destroyed by free()
.
|
the memory to be owned by Cutter. (void *) |
Since 1.0.5
#define cut_take_string(string)
Passes ownership of the string to Cutter and returns the string itself.
|
the string to be owned by Cutter. |
#define cut_take_strdup(string)
Duplicates the string, passes ownership of the duplicated string to Cutter and returns the duplicated string.
|
the string to be duplicated. (const char *) |
Since 1.0.5
#define cut_take_strndup(string, size)
Duplicates the first size
bytes of the string, passes
ownership of the duplicated string to Cutter and returns
the duplicated string. The duplicated string is always
nul-terminated.
|
the string to be duplicated. (const char *) |
|
the number of bytes to duplicate. (size_t) |
Since 1.0.5
#define cut_take_memdup(memory, size)
Duplicates size
bytes of the memory, passes ownership of
the duplicated memory to Cutter and returns the
duplicated memory.
|
the memory to be duplicated. (void *) |
|
the number of bytes to duplicate. (size_t) |
Since 1.0.5
#define cut_take_printf(format, ...)
Formats a string like printf()
but the formatted string
is owned by Cutter.
|
the message format. See the printf() documentation.
|
|
the parameters to insert into the format string. |
#define cut_take_string_array(strings)
Passes ownership of the array of strings (char **) to
Cutter and returns an array of strings that has same
contents of strings
.
|
the array of strings to be owned by Cutter. |
#define cut_take_diff(from, to)
Computes diff between from
and to
that is owned by Cutter.
|
the original string. |
|
the modified string. |
#define cut_append_diff(message, from, to)
Computes diff between from
and to
and append the diff
to message
. Returned string is owned by Cutter.
|
the string to be appended diff. |
|
the original string. |
|
the modified string. |
Since 1.0.3
#define cut_inspect_string_array(strings)
Formats strings
as human readable string that is owned by Cutter.
|
the array of strings to be inspected. |
#define cut_set_fixture_data_dir(path, ...)
Set fixture data directory that is used by
cut_get_fixture_data_string()
and so on.
|
a first element of the path to the fixture data directory. |
|
remaining elements in path. |
Since 1.0.2
#define cut_build_fixture_data_path(path, ...)
Builds a path to the fixture data. If path
is relative
path, the path is handled as a relative path from a
directory that is specified by cut_set_fixture_data_dir()
or the current directory.
|
a first element of the path to the fixture data. |
|
remaining elements in path. |
Since 1.0.2
#define cut_get_fixture_data_string(path, ...)
Reads the fixture data at "path
/..." and returns it as a
string that is owned by Cutter. The description of
cut_build_fixture_data_path()
shows how the fixture data
path is determined.
|
a first element of the path to the fixture data. |
|
remaining elements in path. |
Since 1.0.2
#define cut_remove_path(path, ...)
Removes path
and it's children recursively. It doesn't
report any errors.
|
a first element of the path to be removed. |
|
remaining elements in path. |
Since 1.0.2
#define cut_equal_string(string1, string2)
Compare string1
to string2
. string1
and/or string2
maybe NULL.
|
a string. (char *) |
|
a string. (char *) |
Since 1.0.5