[C] Split tests to 2 categories
This commit is contained in:
		
							
								
								
									
										41
									
								
								tests/test.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								tests/test.c
									
									
									
									
									
								
							@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
#include "fort.h"
 | 
			
		||||
 | 
			
		||||
static int aloc_num = 0;
 | 
			
		||||
static int aloc_lim = 9999;
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
#include <wchar.h>
 | 
			
		||||
#include "fort.h"
 | 
			
		||||
 | 
			
		||||
void test_table_basic(void)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
 | 
			
		||||
#include "fort.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
#include "table.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void test_table_sizes(void)
 | 
			
		||||
{
 | 
			
		||||
    ft_table_t *table = ft_create_table();
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
#include "tests.h"
 | 
			
		||||
 | 
			
		||||
#include "vector.h"
 | 
			
		||||
//#include "../src/fort.c"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void test_vector_basic(void)
 | 
			
		||||
 
 | 
			
		||||
@@ -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 []);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user