MeterLogger
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
greatest.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
Include dependency graph for greatest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  greatest_suite_info
 
struct  greatest_run_info
 

Macros

#define GREATEST_VERSION_MAJOR   0
 
#define GREATEST_VERSION_MINOR   9
 
#define GREATEST_VERSION_PATCH   3
 
#define GREATEST_DEFAULT_WIDTH   72
 
#define GREATEST_STDOUT   stdout
 
#define GREATEST_USE_ABBREVS   1
 
#define GREATEST_SUITE(NAME)   void NAME(void)
 
#define GREATEST_TEST   static int
 
#define GREATEST_RUN_SUITE(S_NAME)   greatest_run_suite(S_NAME, #S_NAME)
 
#define GREATEST_RUN_TEST(TEST)
 
#define GREATEST_RUN_TEST1(TEST, ENV)
 
#define GREATEST_IS_VERBOSE()   (greatest_info.flags & GREATEST_FLAG_VERBOSE)
 
#define GREATEST_LIST_ONLY()   (greatest_info.flags & GREATEST_FLAG_LIST_ONLY)
 
#define GREATEST_FIRST_FAIL()   (greatest_info.flags & GREATEST_FLAG_FIRST_FAIL)
 
#define GREATEST_FAILURE_ABORT()   (greatest_info.suite.failed > 0 && GREATEST_FIRST_FAIL())
 
#define GREATEST_PASS()   GREATEST_PASSm(NULL)
 
#define GREATEST_FAIL()   GREATEST_FAILm(NULL)
 
#define GREATEST_SKIP()   GREATEST_SKIPm(NULL)
 
#define GREATEST_ASSERT(COND)   GREATEST_ASSERTm(#COND, COND)
 
#define GREATEST_ASSERT_FALSE(COND)   GREATEST_ASSERT_FALSEm(#COND, COND)
 
#define GREATEST_ASSERT_EQ(EXP, GOT)   GREATEST_ASSERT_EQm(#EXP " != " #GOT, EXP, GOT)
 
#define GREATEST_ASSERT_STR_EQ(EXP, GOT)   GREATEST_ASSERT_STR_EQm(#EXP " != " #GOT, EXP, GOT)
 
#define GREATEST_ASSERTm(MSG, COND)
 
#define GREATEST_ASSERT_FALSEm(MSG, COND)
 
#define GREATEST_ASSERT_EQm(MSG, EXP, GOT)
 
#define GREATEST_ASSERT_STR_EQm(MSG, EXP, GOT)
 
#define GREATEST_PASSm(MSG)
 
#define GREATEST_FAILm(MSG)
 
#define GREATEST_SKIPm(MSG)
 
#define GREATEST_SET_TIME(NAME)
 
#define GREATEST_CLOCK_DIFF(C1, C2)
 
#define GREATEST_MAIN_DEFS()
 
#define GREATEST_MAIN_BEGIN()
 
#define GREATEST_MAIN_END()
 
#define TEST   GREATEST_TEST
 
#define SUITE   GREATEST_SUITE
 
#define RUN_TEST   GREATEST_RUN_TEST
 
#define RUN_TEST1   GREATEST_RUN_TEST1
 
#define RUN_SUITE   GREATEST_RUN_SUITE
 
#define ASSERT   GREATEST_ASSERT
 
#define ASSERTm   GREATEST_ASSERTm
 
#define ASSERT_FALSE   GREATEST_ASSERT_FALSE
 
#define ASSERT_EQ   GREATEST_ASSERT_EQ
 
#define ASSERT_STR_EQ   GREATEST_ASSERT_STR_EQ
 
#define ASSERT_FALSEm   GREATEST_ASSERT_FALSEm
 
#define ASSERT_EQm   GREATEST_ASSERT_EQm
 
#define ASSERT_STR_EQm   GREATEST_ASSERT_STR_EQm
 
#define PASS   GREATEST_PASS
 
#define FAIL   GREATEST_FAIL
 
#define SKIP   GREATEST_SKIP
 
#define PASSm   GREATEST_PASSm
 
#define FAILm   GREATEST_FAILm
 
#define SKIPm   GREATEST_SKIPm
 
#define SET_SETUP   GREATEST_SET_SETUP_CB
 
#define SET_TEARDOWN   GREATEST_SET_TEARDOWN_CB
 
#define RUN_TESTp   GREATEST_RUN_TESTp
 

Typedefs

typedef struct greatest_suite_info greatest_suite_info
 
typedef void() greatest_suite_cb(void)
 
typedef void() greatest_setup_cb(void *udata)
 
typedef void() greatest_teardown_cb(void *udata)
 
typedef struct greatest_run_info greatest_run_info
 

Enumerations

enum  GREATEST_FLAG { GREATEST_FLAG_VERBOSE = 0x01, GREATEST_FLAG_FIRST_FAIL = 0x02, GREATEST_FLAG_LIST_ONLY = 0x04 }
 

Functions

void greatest_do_pass (const char *name)
 
void greatest_do_fail (const char *name)
 
void greatest_do_skip (const char *name)
 
int greatest_pre_test (const char *name)
 
void greatest_post_test (const char *name, int res)
 
void greatest_usage (const char *name)
 
void GREATEST_SET_SETUP_CB (greatest_setup_cb *cb, void *udata)
 
void GREATEST_SET_TEARDOWN_CB (greatest_teardown_cb *cb, void *udata)
 

Variables

greatest_run_info greatest_info
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT   GREATEST_ASSERT

◆ ASSERT_EQ

#define ASSERT_EQ   GREATEST_ASSERT_EQ

Definition at line 572 of file greatest.h.

Referenced by compress_and_expand_and_check(), data_with_simple_repetition_should_match_with_absurdly_tiny_buffers(), data_without_duplication_should_match_with_absurdly_tiny_buffers(), decoder_alloc_should_reject_excessively_small_window(), decoder_alloc_should_reject_zero_byte_input_buffer(), decoder_finish_should_note_when_done(), decoder_finish_should_reject_null_input(), decoder_poll_should_expand_short_literal(), decoder_poll_should_expand_short_literal_and_backref(), decoder_poll_should_expand_short_literal_and_backref_when_fed_input_byte_by_byte(), decoder_poll_should_expand_short_self_overlapping_backref(), decoder_poll_should_reject_null_hsd(), decoder_poll_should_reject_null_output_buffer(), decoder_poll_should_reject_null_output_size_pointer(), decoder_poll_should_return_empty_if_empty(), decoder_poll_should_suspend_if_out_of_space_in_output_buffer_during_backref_expansion(), decoder_poll_should_suspend_if_out_of_space_in_output_buffer_during_literal_expansion(), decoder_should_not_get_stuck_with_finish_yielding_MORE_but_0_bytes_output_from_poll(), decoder_sink_should_reject_excessively_large_input(), decoder_sink_should_reject_null_count_pointer(), decoder_sink_should_reject_null_hsd_pointer(), decoder_sink_should_reject_null_input_pointer(), decoder_sink_should_sink_data_when_preconditions_hold(), encoder_alloc_should_reject_invalid_arguments(), encoder_finish_should_reject_nulls(), encoder_poll_should_detect_repeated_substring(), encoder_poll_should_detect_repeated_substring_and_preserve_trailing_literal(), encoder_poll_should_indicate_when_no_input_is_provided(), encoder_poll_should_reject_nulls(), encoder_should_emit_data_without_repetitions_as_literal_sequence(), encoder_should_emit_series_of_same_byte_as_literal_then_backref(), encoder_sink_should_accept_input_when_it_will_fit(), encoder_sink_should_accept_partial_input_when_some_will_fit(), encoder_sink_should_reject_nulls(), and gen().

◆ ASSERT_EQm

#define ASSERT_EQm   GREATEST_ASSERT_EQm

Definition at line 575 of file greatest.h.

◆ ASSERT_FALSE

#define ASSERT_FALSE   GREATEST_ASSERT_FALSE

Definition at line 571 of file greatest.h.

◆ ASSERT_FALSEm

#define ASSERT_FALSEm   GREATEST_ASSERT_FALSEm

Definition at line 574 of file greatest.h.

◆ ASSERT_STR_EQ

#define ASSERT_STR_EQ   GREATEST_ASSERT_STR_EQ

Definition at line 573 of file greatest.h.

◆ ASSERT_STR_EQm

#define ASSERT_STR_EQm   GREATEST_ASSERT_STR_EQm

Definition at line 576 of file greatest.h.

◆ ASSERTm

#define ASSERTm   GREATEST_ASSERTm

Definition at line 570 of file greatest.h.

◆ FAIL

#define FAIL   GREATEST_FAIL

Definition at line 578 of file greatest.h.

◆ FAILm

#define FAILm   GREATEST_FAILm

Definition at line 581 of file greatest.h.

Referenced by compress_and_expand_and_check().

◆ GREATEST_ASSERT

#define GREATEST_ASSERT (   COND)    GREATEST_ASSERTm(#COND, COND)

Definition at line 246 of file greatest.h.

◆ GREATEST_ASSERT_EQ

#define GREATEST_ASSERT_EQ (   EXP,
  GOT 
)    GREATEST_ASSERT_EQm(#EXP " != " #GOT, EXP, GOT)

Definition at line 248 of file greatest.h.

◆ GREATEST_ASSERT_EQm

#define GREATEST_ASSERT_EQm (   MSG,
  EXP,
  GOT 
)
Value:
do { \
greatest_info.msg = MSG; \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
if ((EXP) != (GOT)) return -1; \
greatest_info.msg = NULL; \
} while (0)
#define NULL
Definition: def.h:47

Definition at line 273 of file greatest.h.

◆ GREATEST_ASSERT_FALSE

#define GREATEST_ASSERT_FALSE (   COND)    GREATEST_ASSERT_FALSEm(#COND, COND)

Definition at line 247 of file greatest.h.

◆ GREATEST_ASSERT_FALSEm

#define GREATEST_ASSERT_FALSEm (   MSG,
  COND 
)
Value:
do { \
greatest_info.msg = MSG; \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
if ((COND)) return -1; \
greatest_info.msg = NULL; \
} while (0)
#define NULL
Definition: def.h:47

Definition at line 264 of file greatest.h.

◆ GREATEST_ASSERT_STR_EQ

#define GREATEST_ASSERT_STR_EQ (   EXP,
  GOT 
)    GREATEST_ASSERT_STR_EQm(#EXP " != " #GOT, EXP, GOT)

Definition at line 249 of file greatest.h.

◆ GREATEST_ASSERT_STR_EQm

#define GREATEST_ASSERT_STR_EQm (   MSG,
  EXP,
  GOT 
)
Value:
do { \
const char *exp_s = (EXP); \
const char *got_s = (GOT); \
greatest_info.msg = MSG; \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
if (0 != strcmp(exp_s, got_s)) { \
fprintf(GREATEST_STDOUT, \
"Expected:\n####\n%s\n####\n", exp_s); \
fprintf(GREATEST_STDOUT, \
"Got:\n####\n%s\n####\n", got_s); \
return -1; \
} \
greatest_info.msg = NULL; \
} while (0)
#define NULL
Definition: def.h:47
#define GREATEST_STDOUT
Definition: greatest.h:88
#define strcmp(a, b)
Definition: platform.h:17

Definition at line 282 of file greatest.h.

◆ GREATEST_ASSERTm

#define GREATEST_ASSERTm (   MSG,
  COND 
)
Value:
do { \
greatest_info.msg = MSG; \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
if (!(COND)) return -1; \
greatest_info.msg = NULL; \
} while (0)
#define NULL
Definition: def.h:47

Definition at line 255 of file greatest.h.

◆ GREATEST_CLOCK_DIFF

#define GREATEST_CLOCK_DIFF (   C1,
  C2 
)
Value:
fprintf(GREATEST_STDOUT, " (%lu ticks, %.3f sec)", \
(long unsigned int) (C2) - (C1), \
(double)((C2) - (C1)) / (1.0 * (double)CLOCKS_PER_SEC)) \
#define GREATEST_STDOUT
Definition: greatest.h:88

Definition at line 327 of file greatest.h.

◆ GREATEST_DEFAULT_WIDTH

#define GREATEST_DEFAULT_WIDTH   72

Definition at line 83 of file greatest.h.

◆ GREATEST_FAIL

#define GREATEST_FAIL ( )    GREATEST_FAILm(NULL)

Definition at line 244 of file greatest.h.

◆ GREATEST_FAILm

#define GREATEST_FAILm (   MSG)
Value:
do { \
greatest_info.fail_file = __FILE__; \
greatest_info.fail_line = __LINE__; \
greatest_info.msg = MSG; \
return -1; \
} while (0)

Definition at line 305 of file greatest.h.

◆ GREATEST_FAILURE_ABORT

#define GREATEST_FAILURE_ABORT ( )    (greatest_info.suite.failed > 0 && GREATEST_FIRST_FAIL())

Definition at line 240 of file greatest.h.

◆ GREATEST_FIRST_FAIL

#define GREATEST_FIRST_FAIL ( )    (greatest_info.flags & GREATEST_FLAG_FIRST_FAIL)

Definition at line 239 of file greatest.h.

◆ GREATEST_IS_VERBOSE

#define GREATEST_IS_VERBOSE ( )    (greatest_info.flags & GREATEST_FLAG_VERBOSE)

Definition at line 237 of file greatest.h.

Referenced by SUITE().

◆ GREATEST_LIST_ONLY

#define GREATEST_LIST_ONLY ( )    (greatest_info.flags & GREATEST_FLAG_LIST_ONLY)

Definition at line 238 of file greatest.h.

◆ GREATEST_MAIN_BEGIN

#define GREATEST_MAIN_BEGIN ( )

Definition at line 502 of file greatest.h.

Referenced by main().

◆ GREATEST_MAIN_DEFS

#define GREATEST_MAIN_DEFS ( )

Definition at line 333 of file greatest.h.

◆ GREATEST_MAIN_END

#define GREATEST_MAIN_END ( )
Value:
do { \
if (!GREATEST_LIST_ONLY()) { \
GREATEST_SET_TIME(greatest_info.end); \
fprintf(GREATEST_STDOUT, \
"\nTotal: %u tests", greatest_info.tests_run); \
GREATEST_CLOCK_DIFF(greatest_info.begin, \
fprintf(GREATEST_STDOUT, "\n"); \
fprintf(GREATEST_STDOUT, \
"Pass: %u, fail: %u, skip: %u.\n", \
} \
return (greatest_info.failed > 0 \
? EXIT_FAILURE : EXIT_SUCCESS); \
} while (0)
unsigned int skipped
Definition: greatest.h:136
greatest_run_info greatest_info
#define GREATEST_STDOUT
Definition: greatest.h:88
unsigned int passed
Definition: greatest.h:134
unsigned int tests_run
Definition: greatest.h:131
unsigned int failed
Definition: greatest.h:135
#define GREATEST_LIST_ONLY()
Definition: greatest.h:238

Definition at line 543 of file greatest.h.

Referenced by main().

◆ GREATEST_PASS

#define GREATEST_PASS ( )    GREATEST_PASSm(NULL)

Definition at line 243 of file greatest.h.

◆ GREATEST_PASSm

#define GREATEST_PASSm (   MSG)
Value:
do { \
greatest_info.msg = MSG; \
return 0; \
} while (0)

Definition at line 299 of file greatest.h.

◆ GREATEST_RUN_SUITE

#define GREATEST_RUN_SUITE (   S_NAME)    greatest_run_suite(S_NAME, #S_NAME)

Definition at line 196 of file greatest.h.

◆ GREATEST_RUN_TEST

#define GREATEST_RUN_TEST (   TEST)
Value:
do { \
if (greatest_pre_test(#TEST) == 1) { \
int res = TEST(); \
greatest_post_test(#TEST, res); \
} else if (GREATEST_LIST_ONLY()) { \
fprintf(GREATEST_STDOUT, " %s\n", #TEST); \
} \
} while (0)
int greatest_pre_test(const char *name)
#define TEST
Definition: greatest.h:564
#define GREATEST_STDOUT
Definition: greatest.h:88
#define GREATEST_LIST_ONLY()
Definition: greatest.h:238

Definition at line 199 of file greatest.h.

◆ GREATEST_RUN_TEST1

#define GREATEST_RUN_TEST1 (   TEST,
  ENV 
)
Value:
do { \
if (greatest_pre_test(#TEST) == 1) { \
int res = TEST(ENV); \
greatest_post_test(#TEST, res); \
} else if (GREATEST_LIST_ONLY()) { \
fprintf(GREATEST_STDOUT, " %s\n", #TEST); \
} \
} while (0)
int greatest_pre_test(const char *name)
#define TEST
Definition: greatest.h:564
#define GREATEST_STDOUT
Definition: greatest.h:88
#define GREATEST_LIST_ONLY()
Definition: greatest.h:238

Definition at line 211 of file greatest.h.

◆ GREATEST_SET_TIME

#define GREATEST_SET_TIME (   NAME)
Value:
NAME = clock(); \
if (NAME == (clock_t) -1) { \
fprintf(GREATEST_STDOUT, \
"clock error: %s\n", #NAME); \
exit(EXIT_FAILURE); \
}
#define GREATEST_STDOUT
Definition: greatest.h:88

Definition at line 319 of file greatest.h.

◆ GREATEST_SKIP

#define GREATEST_SKIP ( )    GREATEST_SKIPm(NULL)

Definition at line 245 of file greatest.h.

◆ GREATEST_SKIPm

#define GREATEST_SKIPm (   MSG)
Value:
do { \
greatest_info.msg = MSG; \
return 1; \
} while (0)

Definition at line 313 of file greatest.h.

◆ GREATEST_STDOUT

#define GREATEST_STDOUT   stdout

Definition at line 88 of file greatest.h.

◆ GREATEST_SUITE

#define GREATEST_SUITE (   NAME)    void NAME(void)

Definition at line 189 of file greatest.h.

◆ GREATEST_TEST

#define GREATEST_TEST   static int

Definition at line 193 of file greatest.h.

◆ GREATEST_USE_ABBREVS

#define GREATEST_USE_ABBREVS   1

Definition at line 93 of file greatest.h.

◆ GREATEST_VERSION_MAJOR

#define GREATEST_VERSION_MAJOR   0

Definition at line 20 of file greatest.h.

◆ GREATEST_VERSION_MINOR

#define GREATEST_VERSION_MINOR   9

Definition at line 21 of file greatest.h.

◆ GREATEST_VERSION_PATCH

#define GREATEST_VERSION_PATCH   3

Definition at line 22 of file greatest.h.

◆ PASS

#define PASS   GREATEST_PASS

Definition at line 577 of file greatest.h.

Referenced by compress_and_expand_and_check(), data_with_simple_repetition_should_match_with_absurdly_tiny_buffers(), data_without_duplication_should_match_with_absurdly_tiny_buffers(), decoder_alloc_should_reject_excessively_small_window(), decoder_alloc_should_reject_zero_byte_input_buffer(), decoder_finish_should_note_when_done(), decoder_finish_should_reject_null_input(), decoder_poll_should_expand_short_literal(), decoder_poll_should_expand_short_literal_and_backref(), decoder_poll_should_expand_short_literal_and_backref_when_fed_input_byte_by_byte(), decoder_poll_should_expand_short_self_overlapping_backref(), decoder_poll_should_reject_null_hsd(), decoder_poll_should_reject_null_output_buffer(), decoder_poll_should_reject_null_output_size_pointer(), decoder_poll_should_return_empty_if_empty(), decoder_poll_should_suspend_if_out_of_space_in_output_buffer_during_backref_expansion(), decoder_poll_should_suspend_if_out_of_space_in_output_buffer_during_literal_expansion(), decoder_should_not_get_stuck_with_finish_yielding_MORE_but_0_bytes_output_from_poll(), decoder_sink_should_reject_excessively_large_input(), decoder_sink_should_reject_null_count_pointer(), decoder_sink_should_reject_null_hsd_pointer(), decoder_sink_should_reject_null_input_pointer(), decoder_sink_should_sink_data_when_preconditions_hold(), encoder_alloc_should_reject_invalid_arguments(), encoder_finish_should_reject_nulls(), encoder_poll_should_detect_repeated_substring(), encoder_poll_should_detect_repeated_substring_and_preserve_trailing_literal(), encoder_poll_should_indicate_when_no_input_is_provided(), encoder_poll_should_reject_nulls(), encoder_should_emit_data_without_repetitions_as_literal_sequence(), encoder_should_emit_series_of_same_byte_as_literal_then_backref(), encoder_sink_should_accept_input_when_it_will_fit(), encoder_sink_should_accept_partial_input_when_some_will_fit(), encoder_sink_should_reject_nulls(), gen(), and small_input_buffer_should_not_impact_decoder_correctness().

◆ PASSm

#define PASSm   GREATEST_PASSm

Definition at line 580 of file greatest.h.

◆ RUN_SUITE

#define RUN_SUITE   GREATEST_RUN_SUITE

Definition at line 568 of file greatest.h.

Referenced by main().

◆ RUN_TEST

#define RUN_TEST   GREATEST_RUN_TEST

Definition at line 566 of file greatest.h.

Referenced by SUITE().

◆ RUN_TEST1

#define RUN_TEST1   GREATEST_RUN_TEST1

Definition at line 567 of file greatest.h.

◆ RUN_TESTp

#define RUN_TESTp   GREATEST_RUN_TESTp

Definition at line 588 of file greatest.h.

Referenced by SUITE().

◆ SET_SETUP

#define SET_SETUP   GREATEST_SET_SETUP_CB

Definition at line 583 of file greatest.h.

◆ SET_TEARDOWN

#define SET_TEARDOWN   GREATEST_SET_TEARDOWN_CB

Definition at line 584 of file greatest.h.

◆ SKIP

#define SKIP   GREATEST_SKIP

Definition at line 579 of file greatest.h.

◆ SKIPm

#define SKIPm   GREATEST_SKIPm

Definition at line 582 of file greatest.h.

◆ SUITE

#define SUITE   GREATEST_SUITE

Definition at line 565 of file greatest.h.

◆ TEST

#define TEST   GREATEST_TEST

Definition at line 564 of file greatest.h.

Typedef Documentation

◆ greatest_run_info

◆ greatest_setup_cb

typedef void() greatest_setup_cb(void *udata)

Definition at line 120 of file greatest.h.

◆ greatest_suite_cb

typedef void() greatest_suite_cb(void)

Definition at line 116 of file greatest.h.

◆ greatest_suite_info

◆ greatest_teardown_cb

typedef void() greatest_teardown_cb(void *udata)

Definition at line 121 of file greatest.h.

Enumeration Type Documentation

◆ GREATEST_FLAG

Enumerator
GREATEST_FLAG_VERBOSE 
GREATEST_FLAG_FIRST_FAIL 
GREATEST_FLAG_LIST_ONLY 

Definition at line 123 of file greatest.h.

Function Documentation

◆ greatest_do_fail()

void greatest_do_fail ( const char *  name)

◆ greatest_do_pass()

void greatest_do_pass ( const char *  name)

◆ greatest_do_skip()

void greatest_do_skip ( const char *  name)

◆ greatest_post_test()

void greatest_post_test ( const char *  name,
int  res 
)

◆ greatest_pre_test()

int greatest_pre_test ( const char *  name)

◆ GREATEST_SET_SETUP_CB()

void GREATEST_SET_SETUP_CB ( greatest_setup_cb cb,
void *  udata 
)

◆ GREATEST_SET_TEARDOWN_CB()

void GREATEST_SET_TEARDOWN_CB ( greatest_teardown_cb cb,
void *  udata 
)

◆ greatest_usage()

void greatest_usage ( const char *  name)

Variable Documentation

◆ greatest_info

greatest_run_info greatest_info