1
0
Fork 0

[C] Split tests to 2 categories

This commit is contained in:
seleznevae 2018-05-06 14:11:03 +03:00
parent 9a14de9ac4
commit 2725d452d4
9 changed files with 50 additions and 29 deletions

View File

@ -1,12 +1,33 @@
#include "tests.h"
#include <stdio.h>
#include "fort.h"
struct test_case test_suit [] = {
void run_test_suit(const char *test_suit_name, int n_tests, struct test_case test_suit[])
{
fprintf(stderr, " == RUNNING %s ==\n", test_suit_name);
fprintf(stderr, "[==========] Running %d test(s).\n", n_tests);
int i;
for (i = 0; i < n_tests; ++i) {
fprintf(stderr, "[ RUN ] %s\n", test_suit[i].name);
test_suit[i].test();
fprintf(stderr, "[ OK ] %s\n", test_suit[i].name);
}
fprintf(stderr, "[==========] %d test(s) run.\n", n_tests);
fprintf(stderr, "[ PASSED ] %d test(s).\n", n_tests);
}
struct test_case wb_test_suit [] = {
{"test_vector_basic", test_vector_basic},
{"test_vector_stress", test_vector_stress},
{"test_string_buffer", test_string_buffer},
{"test_table_sizes", test_table_sizes},
{"test_table_geometry", test_table_geometry},
};
struct test_case bb_test_suit [] = {
{"test_table_basic", test_table_basic},
#ifdef FT_HAVE_WCHAR
{"test_wcs_table_boundaries", test_wcs_table_boundaries},
@ -18,17 +39,15 @@ struct test_case test_suit [] = {
{"test_memory_errors", test_memory_errors},
};
int main(void)
{
int n_tests = sizeof(test_suit) / sizeof(test_suit[0]);
fprintf(stderr, "[==========] Running %d test(s).\n", n_tests);
int i;
for (i = 0; i < n_tests; ++i) {
fprintf(stderr, "[ RUN ] %s\n", test_suit[i].name);
test_suit[i].test();
fprintf(stderr, "[ OK ] %s\n", test_suit[i].name);
}
fprintf(stderr, "[==========] %d test(s) run.\n", n_tests);
fprintf(stderr, "[ PASSED ] %d test(s).\n", n_tests);
int wb_n_tests = sizeof(wb_test_suit) / sizeof(wb_test_suit[0]);
run_test_suit("WHITE BOX TEST SUITE", wb_n_tests, wb_test_suit);
fprintf(stderr, "\n");
int bb_n_tests = sizeof(bb_test_suit) / sizeof(bb_test_suit[0]);
run_test_suit("BLACK BOX TEST SUITE", bb_n_tests, bb_test_suit);
return 0;
}

View File

@ -1,4 +1,5 @@
#include "tests.h"
#include "fort.h"
static int aloc_num = 0;
static int aloc_lim = 9999;

View File

@ -1,8 +1,6 @@
#include "tests.h"
#include "string_buffer.h"
//#include "../src/fort.c"
#include "wchar.h"
#include <wchar.h>
size_t strchr_count(const char *str, char ch);

View File

@ -1,5 +1,6 @@
#include "tests.h"
#include <wchar.h>
#include "fort.h"
void test_table_basic(void)
{

View File

@ -1,5 +1,5 @@
#include "tests.h"
#include "fort.h"

View File

@ -1,7 +1,6 @@
#include "tests.h"
#include "table.h"
void test_table_sizes(void)
{
ft_table_t *table = ft_create_table();

View File

@ -1,7 +1,7 @@
#include "tests.h"
#include "fort.h"
int set_test_options_for_table(ft_table_t *table)
int set_test_options_for_table(struct ft_table *table)
{
assert(table);
int status = FT_SUCCESS;
@ -71,7 +71,7 @@ int set_test_options_as_default(void)
ft_table_t *create_test_int_table(int set_test_opts)
struct ft_table *create_test_int_table(int set_test_opts)
{
ft_table_t *table = NULL;
@ -102,7 +102,7 @@ ft_table_t *create_test_int_table(int set_test_opts)
}
#ifdef FT_HAVE_WCHAR
ft_table_t *create_test_int_wtable(int set_test_opts)
struct ft_table *create_test_int_wtable(int set_test_opts)
{
ft_table_t *table = NULL;

View File

@ -1,7 +1,5 @@
#include "tests.h"
#include "vector.h"
//#include "../src/fort.c"
void test_vector_basic(void)

View File

@ -4,15 +4,20 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include "fort_impl.h"
#include <assert.h>
#include "wchar.h"
#include "locale.h"
#include <wchar.h>
#include <locale.h>
#include <string.h>
#include <stdio.h>
#define WHEN(...)
#define THEN(...)
#define SCENARIO(...)
#if defined(FT_CONGIG_HAVE_WCHAR)
#define FT_HAVE_WCHAR
#endif
/* Test cases */
void test_vector_basic(void);
void test_vector_stress(void);
@ -35,7 +40,6 @@ struct test_case
void (*test)(void);
};
/*
* Test utility funcitons
*/
@ -62,13 +66,14 @@ struct test_case
exit(EXIT_FAILURE); \
}
int set_test_options_for_table(ft_table_t *table);
struct ft_table;
int set_test_options_for_table(struct ft_table *table);
int set_test_options_as_default(void);
ft_table_t *create_test_int_table(int set_test_opts);
ft_table_t *create_test_int_wtable(int set_test_opts);
struct ft_table *create_test_int_table(int set_test_opts);
struct ft_table *create_test_int_wtable(int set_test_opts);
void run_test_suit(const char *test_suit_name, int n_tests, struct test_case test_suit []);