Skip to content

Commit

Permalink
Merge branch 'features/refactor' into bleeding
Browse files Browse the repository at this point in the history
  • Loading branch information
Snaipe committed Nov 19, 2015
2 parents eeb7ab2 + a7d5ecf commit 34fb71d
Show file tree
Hide file tree
Showing 17 changed files with 928 additions and 855 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
!*.m
!*.cc
!*.h
!*.hxx
!*.rst
!*.po
!*.in
Expand Down
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,20 @@ set(INTERFACE_FILES
include/criterion/parameterized.h
include/criterion/redirect.h
include/criterion/output.h
include/criterion/internal/assert.h
include/criterion/internal/test.h
include/criterion/internal/common.h
include/criterion/internal/ordered-set.h
include/criterion/internal/asprintf-compat.h
include/criterion/internal/designated-initializer-compat.h
include/criterion/internal/preprocess.h
include/criterion/internal/theories.h
include/criterion/internal/parameterized.h
include/criterion/internal/stdio_filebuf.hxx
include/criterion/internal/stream.hxx
include/criterion/internal/hooks.h
include/criterion/internal/redirect.h
include/criterion/internal/stdio_filebuf.hxx
)

# Generate the configure file
Expand Down Expand Up @@ -243,7 +252,11 @@ if (COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
endif()

install(FILES ${INTERFACE_FILES} DESTINATION include/criterion)
foreach (F ${INTERFACE_FILES})
get_filename_component(DEST "${F}" PATH)
install(FILES "${F}" DESTINATION "${DEST}")
endforeach ()

install(TARGETS criterion
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
Expand Down
274 changes: 18 additions & 256 deletions include/criterion/assert.h

Large diffs are not rendered by default.

70 changes: 3 additions & 67 deletions include/criterion/criterion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,15 @@
#ifndef CRITERION_H_
# define CRITERION_H_

# include "internal/designated-initializer-compat.h"
# include "internal/common.h"
# include "types.h"
# include "assert.h"
# include "alloc.h"

# define CR_IDENTIFIER_(Category, Name, Suffix) \
Category ## _ ## Name ## _ ## Suffix
# include "internal/test.h"

# ifdef __cplusplus
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJCXX
# else
# define CR_LANG CR_LANG_CXX
# endif
# else
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJC
# else
# define CR_LANG CR_LANG_C
# endif
# endif
# define Test(...) CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))

# ifdef __cplusplus
# define CR_TEST_PROTOTYPE_(Category, Name) \
extern "C" void CR_IDENTIFIER_(Category, Name, impl)(void)
# else
# define CR_TEST_PROTOTYPE_(Category, Name) \
void CR_IDENTIFIER_(Category, Name, impl)(void)
# endif

# define CR_SUITE_IDENTIFIER_(Name, Suffix) \
suite_ ## Name ## _ ## Suffix

# define Test(...) CR_EXPAND(Test_(__VA_ARGS__, .sentinel_ = 0))
# define Test_(Category, Name, ...) \
CR_TEST_PROTOTYPE_(Category, Name); \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_NORMAL, \
.param_ = (struct criterion_test_params(*)(void)) NULL, \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
CR_IDENTIFIER_(Category, Name, impl), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
CR_TEST_PROTOTYPE_(Category, Name)

# define TestSuite(...) CR_EXPAND(TestSuite_(__VA_ARGS__, .sentinel_ = 0))
# define TestSuite_(Name, ...) \
struct criterion_test_extra_data CR_SUITE_IDENTIFIER_(Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.file_ = __FILE__, \
.line_ = 0, \
__VA_ARGS__ \
)); \
struct criterion_suite CR_SUITE_IDENTIFIER_(Name, meta) = { \
#Name, \
&CR_SUITE_IDENTIFIER_(Name, extra), \
}; \
CR_SECTION_("cr_sts") \
struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \
= &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_
# define TestSuite(...) CR_EXPAND(CR_SUITE_BASE(__VA_ARGS__, .sentinel_ = 0))

CR_BEGIN_C_API

Expand Down
56 changes: 2 additions & 54 deletions include/criterion/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#ifndef CRITERION_HOOKS_H_
# define CRITERION_HOOKS_H_

# include "internal/common.h"
# include "types.h"
# include "internal/hooks.h"

typedef enum {
PRE_ALL,
Expand All @@ -43,57 +42,6 @@ typedef enum {

typedef void (*f_report_hook)();

# define CR_HOOK_IDENTIFIER_(Suffix) CR_HOOK_IDENTIFIER__(__LINE__, Suffix)
# define CR_HOOK_IDENTIFIER__(Line, Suffix) CR_HOOK_IDENTIFIER___(Line, Suffix)
# define CR_HOOK_IDENTIFIER___(Line, Suffix) hook_l ## Line ## _ ## Suffix

# ifdef __cplusplus
# define CR_HOOK_PROTOTYPE_ \
extern "C" void CR_HOOK_IDENTIFIER_(impl)
# else
# define CR_HOOK_PROTOTYPE_ \
void CR_HOOK_IDENTIFIER_(impl)
# endif

// Section abbreviations
# define CR_HOOK_SECTION_PRE_ALL cr_pra
# define CR_HOOK_SECTION_PRE_SUITE cr_prs
# define CR_HOOK_SECTION_PRE_INIT cr_pri
# define CR_HOOK_SECTION_PRE_TEST cr_prt
# define CR_HOOK_SECTION_ASSERT cr_ast
# define CR_HOOK_SECTION_THEORY_FAIL cr_thf
# define CR_HOOK_SECTION_TEST_CRASH cr_tsc
# define CR_HOOK_SECTION_POST_TEST cr_pot
# define CR_HOOK_SECTION_POST_FINI cr_pof
# define CR_HOOK_SECTION_POST_SUITE cr_pos
# define CR_HOOK_SECTION_POST_ALL cr_poa

# define CR_HOOK_SECTION(Kind) CR_HOOK_SECTION_ ## Kind

# define CR_HOOK_SECTION_STRINGIFY__(Sec) #Sec
# define CR_HOOK_SECTION_STRINGIFY_(Sec) CR_HOOK_SECTION_STRINGIFY__(Sec)
# define CR_HOOK_SECTION_STRINGIFY(Kind) CR_HOOK_SECTION_STRINGIFY_(CR_HOOK_SECTION(Kind))

# define CR_HOOK_PARAM_TYPE_PRE_ALL struct criterion_test_set *
# define CR_HOOK_PARAM_TYPE_PRE_SUITE struct criterion_suite_set *
# define CR_HOOK_PARAM_TYPE_PRE_INIT struct criterion_test *
# define CR_HOOK_PARAM_TYPE_PRE_TEST struct criterion_test *
# define CR_HOOK_PARAM_TYPE_ASSERT struct criterion_assert_stats *
# define CR_HOOK_PARAM_TYPE_THEORY_FAIL struct criterion_theory_stats *
# define CR_HOOK_PARAM_TYPE_TEST_CRASH struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_TEST struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_FINI struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_SUITE struct criterion_suite_stats *
# define CR_HOOK_PARAM_TYPE_POST_ALL struct criterion_global_stats *

# define CR_HOOK_PARAM_TYPE(Kind) CR_HOOK_PARAM_TYPE_ ## Kind

# define ReportHook(Kind) \
CR_HOOK_PROTOTYPE_(CR_HOOK_PARAM_TYPE(Kind)); \
CR_SECTION_(CR_HOOK_SECTION_STRINGIFY(Kind)) \
f_report_hook CR_HOOK_IDENTIFIER_(func) = \
(f_report_hook) CR_HOOK_IDENTIFIER_(impl) \
CR_SECTION_SUFFIX_; \
CR_HOOK_PROTOTYPE_
# define ReportHook(Kind) CR_REPORT_HOOK_IMPL(Kind)

#endif /* !CRITERION_HOOKS_H_ */
Loading

0 comments on commit 34fb71d

Please sign in to comment.