libfort/tests/tests.h

96 lines
2.4 KiB
C
Raw Normal View History

2018-01-01 09:26:34 +01:00
#ifndef TESTS_H
#define TESTS_H
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
2018-03-19 21:07:18 +01:00
#include <assert.h>
2018-05-06 13:11:03 +02:00
#include <wchar.h>
#include <locale.h>
#include <string.h>
#include <stdio.h>
2018-01-01 09:26:34 +01:00
#define WHEN(...)
#define THEN(...)
2018-03-20 18:57:50 +01:00
#define SCENARIO(...)
2018-01-01 09:26:34 +01:00
2018-05-06 13:11:03 +02:00
#if defined(FT_CONGIG_HAVE_WCHAR)
#define FT_HAVE_WCHAR
#endif
2018-03-19 21:07:18 +01:00
/* Test cases */
void test_vector_basic(void);
2018-04-22 20:42:22 +02:00
void test_vector_stress(void);
2018-03-19 21:07:18 +01:00
void test_string_buffer(void);
void test_table_sizes(void);
void test_table_geometry(void);
void test_table_basic(void);
void test_table_copy(void);
2018-04-16 20:01:45 +02:00
#ifdef FT_HAVE_WCHAR
void test_wcs_table_boundaries(void);
2018-04-16 20:01:45 +02:00
#endif
2018-03-20 18:57:50 +01:00
void test_table_write(void);
2018-03-19 21:07:18 +01:00
void test_table_border_style(void);
2018-05-06 17:25:53 +02:00
void test_table_builtin_border_styles(void);
2018-11-03 21:50:30 +01:00
void test_table_cell_properties(void);
2018-11-10 07:58:21 +01:00
void test_table_text_styles(void);
2018-11-03 21:50:30 +01:00
void test_table_tbl_properties(void);
void test_memory_errors(void);
2018-01-01 09:26:34 +01:00
2018-05-06 16:04:34 +02:00
struct test_case {
char name [128];
2018-03-19 21:07:18 +01:00
void (*test)(void);
};
2018-03-19 21:07:18 +01:00
/*
* Test utility funcitons
*/
#define assert_true(args) assert(args)
2018-01-01 09:26:34 +01:00
#define assert_str_equal(str1, str2) \
if (strcmp(str1, str2) != 0) \
{ \
fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \
fprintf(stderr, "Left string(len = %d):\n%s\n", (int)strlen(str1), str1); \
fprintf(stderr, "Right string(len = %d):\n%s\n", (int)strlen(str2), str2); \
exit(EXIT_FAILURE); \
}
#define assert_wcs_equal(str1, str2) \
if (wcscmp(str1, str2) != 0) \
{ \
fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \
setlocale(LC_CTYPE, ""); \
fwprintf(stdout, L"Left string(len = %d):\n%ls\n", (int)wcslen(str1), str1); \
fwprintf(stdout, L"Right string(len = %d):\n%ls\n", (int)wcslen(str2), str2); \
2018-03-31 12:33:37 +02:00
fflush(stdout); \
exit(EXIT_FAILURE); \
}
2018-05-06 13:11:03 +02:00
struct ft_table;
2018-07-25 21:37:10 +02:00
#ifdef __cplusplus
2018-11-21 18:50:56 +01:00
#define assert_string_equal(str1, str2) assert_str_equal(str1.c_str(), str2.c_str())
namespace fort
{
class table;
}
bool set_cpp_test_props_for_table(fort::table *table);
fort::table create_cpp_test_int_table(int set_test_opts);
2018-07-25 21:37:10 +02:00
extern "C" {
#endif
2018-11-03 21:50:30 +01:00
int set_test_props_for_table(struct ft_table *table);
int set_test_properties_as_default(void);
2018-05-06 13:11:03 +02:00
struct ft_table *create_test_int_table(int set_test_opts);
struct ft_table *create_test_int_wtable(int set_test_opts);
2018-07-25 21:37:10 +02:00
void run_test_suit(const char *test_suit_name, int n_tests, struct test_case test_suit[]);
2018-07-25 21:37:10 +02:00
#ifdef __cplusplus
}
#endif
2018-01-01 09:26:34 +01:00
#endif // TESTS_H