83 lines
1.7 KiB
C
83 lines
1.7 KiB
C
#include "xtest.h"
|
|
#include "source.h"
|
|
#include "examples.h"
|
|
|
|
void test_add(XTEST_UNUSED void *fixture, void **params) {
|
|
int a = xtest_get_param(int, 0, params);
|
|
int b = xtest_get_param(int, 1, params);
|
|
int result = a + b;
|
|
xtest_assert_is(add(a, b), result);
|
|
}
|
|
|
|
void test_str_equals(XTEST_UNUSED void *fixture, void **params) {
|
|
const char *s1 = xtest_get_param_ptr(const char*, 0, params);
|
|
const char *s2 = xtest_get_param_ptr(const char*, 1, params);
|
|
if (str_equals(s1, s2)) {
|
|
xtest_assert_str_is(s1, s2);
|
|
} else {
|
|
xtest_assert_str_is_not(s1, s2);
|
|
}
|
|
}
|
|
|
|
|
|
xtest_param add_params[] = {
|
|
{
|
|
.name = "A",
|
|
.values = &(xtest_param_values) {
|
|
&(int) {1},
|
|
&(int) {10},
|
|
&(int) {100},
|
|
NULL
|
|
}
|
|
},
|
|
{
|
|
.name = "B",
|
|
.values = &(xtest_param_values) {
|
|
&(int) {2},
|
|
&(int) {22},
|
|
&(int) {222},
|
|
NULL
|
|
}
|
|
},
|
|
{
|
|
.name = NULL,
|
|
.values = NULL,
|
|
}
|
|
};
|
|
|
|
|
|
xtest_param str_params[] = {
|
|
{
|
|
.name = "A",
|
|
.values = &(xtest_param_values) {
|
|
"foo",
|
|
"bar",
|
|
"hello",
|
|
"world",
|
|
NULL
|
|
}
|
|
},
|
|
{
|
|
.name = "B",
|
|
.values = &(xtest_param_values) {
|
|
"foo",
|
|
"bar",
|
|
"xyz",
|
|
NULL
|
|
}
|
|
},
|
|
{
|
|
.name = NULL,
|
|
.values = NULL,
|
|
}
|
|
};
|
|
|
|
void example_parameterized(void) {
|
|
xtest_run_parameterized(test_add, add_params);
|
|
xtest_run_parameterized(test_str_equals, str_params);
|
|
}
|
|
|
|
#ifndef XTEST_ALL_EXAMPLES
|
|
XTEST_RUN_MAIN(example_parameterized)
|
|
#endif
|