Fixed all criterion-related warnings with MSVC
This commit is contained in:
parent
34aacc2dd8
commit
7577cf8940
8 changed files with 63 additions and 24 deletions
|
@ -9,6 +9,10 @@ set(LIBCSPTR_DISABLE_COVERALLS ON)
|
|||
|
||||
include(Submodules)
|
||||
|
||||
if (MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
|
||||
|
||||
|
|
|
@ -52,12 +52,12 @@ struct criterion_prefix_data {
|
|||
# ifdef CRITERION_LOGGING_COLORS
|
||||
# define CRIT_COLOR_NORMALIZE(Str) (criterion_options.use_ascii ? "" : Str)
|
||||
|
||||
# define CRIT_FG_BOLD "\e[0;1m"
|
||||
# define CRIT_FG_RED "\e[0;31m"
|
||||
# define CRIT_FG_GREEN "\e[0;32m"
|
||||
# define CRIT_FG_GOLD "\e[0;33m"
|
||||
# define CRIT_FG_BLUE "\e[0;34m"
|
||||
# define CRIT_RESET "\e[0m"
|
||||
# define CRIT_FG_BOLD "\33[0;1m"
|
||||
# define CRIT_FG_RED "\33[0;31m"
|
||||
# define CRIT_FG_GREEN "\33[0;32m"
|
||||
# define CRIT_FG_GOLD "\33[0;33m"
|
||||
# define CRIT_FG_BLUE "\33[0;34m"
|
||||
# define CRIT_RESET "\33[0m"
|
||||
|
||||
# define FG_BOLD CRIT_COLOR_NORMALIZE(CRIT_FG_BOLD)
|
||||
# define FG_RED CRIT_COLOR_NORMALIZE(CRIT_FG_RED)
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
# define strtok_r(str, delim, saveptr) strtok(str, delim)
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strdup _strdup
|
||||
#endif
|
||||
|
||||
typedef const char *const msg_t;
|
||||
|
||||
// Used to mark string for gettext
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include "posix-compat.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define strdup _strdup
|
||||
#endif
|
||||
|
||||
void tap_log_pre_all(struct criterion_test_set *set) {
|
||||
size_t enabled_count = 0;
|
||||
FOREACH_SET(struct criterion_suite_set *s, set->suites) {
|
||||
|
|
|
@ -31,7 +31,7 @@ static void destroy_ordered_set(void *ptr, UNUSED void *meta) {
|
|||
sfree(((struct criterion_ordered_set *) ptr)->first);
|
||||
}
|
||||
|
||||
static INLINE void nothing() {}
|
||||
static INLINE void nothing(UNUSED void *ptr, UNUSED void *meta) {}
|
||||
|
||||
static void destroy_ordered_set_node(void *ptr, void *meta) {
|
||||
struct criterion_ordered_set *set = *(void **) meta;
|
||||
|
|
|
@ -47,6 +47,6 @@ DECL_CALL_REPORT_HOOKS(POST_ALL);
|
|||
#define log(Type, Arg) \
|
||||
log_(criterion_options.output_provider->log_ ## Type, Arg);
|
||||
#define log_(Log, Arg) \
|
||||
(Log ? Log : nothing)(Arg);
|
||||
(Log ? Log(Arg) : nothing());
|
||||
|
||||
#endif /* !REPORT_H_ */
|
||||
|
|
10
src/runner.c
10
src/runner.c
|
@ -169,14 +169,14 @@ static void run_test_child(struct criterion_test *test,
|
|||
|
||||
send_event(PRE_INIT, NULL, 0);
|
||||
if (suite->data)
|
||||
(suite->data->init ? suite->data->init : nothing)();
|
||||
(test->data->init ? test->data->init : nothing)();
|
||||
suite->data->init ? suite->data->init() : nothing();
|
||||
test->data->init ? test->data->init() : nothing();
|
||||
send_event(PRE_TEST, NULL, 0);
|
||||
|
||||
struct timespec_compat ts;
|
||||
if (setup_abort_test()) {
|
||||
timer_start(&ts);
|
||||
(test->test ? test->test : nothing)();
|
||||
test->test ? test->test() : nothing();
|
||||
}
|
||||
|
||||
double elapsed_time;
|
||||
|
@ -184,9 +184,9 @@ static void run_test_child(struct criterion_test *test,
|
|||
elapsed_time = -1;
|
||||
|
||||
send_event(POST_TEST, &elapsed_time, sizeof (double));
|
||||
(test->data->fini ? test->data->fini : nothing)();
|
||||
test->data->fini ? test->data->fini() : nothing();
|
||||
if (suite->data)
|
||||
(suite->data->fini ? suite->data->fini : nothing)();
|
||||
suite->data->fini ? suite->data->fini() : nothing();
|
||||
send_event(POST_FINI, NULL, 0);
|
||||
}
|
||||
|
||||
|
|
49
src/stats.c
49
src/stats.c
|
@ -29,18 +29,38 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
static void nothing() {};
|
||||
static void push_pre_suite();
|
||||
static void push_pre_init();
|
||||
static void push_assert();
|
||||
static void push_post_test();
|
||||
static void push_test_crash();
|
||||
|
||||
typedef struct criterion_global_stats s_glob_stats;
|
||||
typedef struct criterion_suite_stats s_suite_stats;
|
||||
typedef struct criterion_test_stats s_test_stats;
|
||||
typedef struct criterion_assert_stats s_assert_stats;
|
||||
|
||||
static void push_pre_suite(s_glob_stats *stats,
|
||||
s_suite_stats *sstats,
|
||||
s_test_stats *tstats,
|
||||
void *data);
|
||||
static void push_pre_init(s_glob_stats *stats,
|
||||
s_suite_stats *sstats,
|
||||
s_test_stats *tstats,
|
||||
void *data);
|
||||
static void push_assert(s_glob_stats *stats,
|
||||
s_suite_stats *sstats,
|
||||
s_test_stats *tstats,
|
||||
void *data);
|
||||
static void push_post_test(s_glob_stats *stats,
|
||||
s_suite_stats *sstats,
|
||||
s_test_stats *tstats,
|
||||
void *data);
|
||||
static void push_test_crash(s_glob_stats *stats,
|
||||
s_suite_stats *sstats,
|
||||
s_test_stats *tstats,
|
||||
void *data);
|
||||
|
||||
static void nothing(UNUSED s_glob_stats *stats,
|
||||
UNUSED s_suite_stats *sstats,
|
||||
UNUSED s_test_stats *tstats,
|
||||
UNUSED void *data) {
|
||||
};
|
||||
|
||||
static void destroy_stats(void *ptr, UNUSED void *meta) {
|
||||
s_glob_stats *stats = ptr;
|
||||
for (s_suite_stats *s = stats->suites, *next; s; s = next) {
|
||||
|
@ -98,11 +118,13 @@ s_test_stats *test_stats_init(struct criterion_test *t) {
|
|||
return stats;
|
||||
}
|
||||
|
||||
typedef void (*f_handle)(s_glob_stats *, s_suite_stats *, s_test_stats *, void *);
|
||||
|
||||
void stat_push_event(s_glob_stats *stats,
|
||||
s_suite_stats *suite,
|
||||
s_test_stats *test,
|
||||
struct event *data) {
|
||||
static void (*const handles[])(s_glob_stats *, s_suite_stats *, s_test_stats *, void *) = {
|
||||
static const f_handle handles[] = {
|
||||
nothing, // PRE_ALL
|
||||
push_pre_suite, // PRE_SUITE
|
||||
push_pre_init, // PRE_INIT
|
||||
|
@ -155,7 +177,10 @@ static void push_pre_init(s_glob_stats *stats,
|
|||
static void push_assert(s_glob_stats *stats,
|
||||
s_suite_stats *suite,
|
||||
s_test_stats *test,
|
||||
s_assert_stats *data) {
|
||||
void *ptr) {
|
||||
|
||||
s_assert_stats *data = ptr;
|
||||
|
||||
s_assert_stats *dup = smalloc(sizeof (s_assert_stats));
|
||||
memcpy(dup, data, sizeof (s_assert_stats));
|
||||
|
||||
|
@ -179,8 +204,10 @@ static void push_assert(s_glob_stats *stats,
|
|||
static void push_post_test(s_glob_stats *stats,
|
||||
s_suite_stats *suite,
|
||||
s_test_stats *test,
|
||||
double *ptr) {
|
||||
test->elapsed_time = *ptr;
|
||||
void *ptr) {
|
||||
double *data = ptr;
|
||||
|
||||
test->elapsed_time = (float) *data;
|
||||
if (test->failed_asserts > 0
|
||||
|| test->signal != test->test->data->signal
|
||||
|| test->exit_code != test->test->data->exit_code) {
|
||||
|
|
Loading…
Add table
Reference in a new issue