ircbot.c  0.3.0
Multi-platform IRC bot in pure C
minunit.h File Reference

Custom minimal unit testing header file. Inspired by http://www.jera.com/techinfo/jtns/jtn002.html. More...

Go to the source code of this file.

Macros

#define mu_assert(message, test)
 Assert truth or return an error message. More...
 
#define mu_assert_or_disconnect(bot, message, test)
 Same as mu_assert, but disconnects the bot before returning on failure. More...
 
#define mu_run_test(name, test)
 Execute a test case. More...
 

Variables

int tests_run
 Total number of tests executed. More...
 
int tests_failed
 Number of tests that failed. More...
 
char ** messages
 List of messages from failed tests, for printing. More...
 
ANSI color codes

Color codes or empty strings, determined by isatty() in main().

char RED []
 
char GREEN []
 
char YELLOW []
 
char COLOR_END []
 

Detailed Description

Custom minimal unit testing header file. Inspired by http://www.jera.com/techinfo/jtns/jtn002.html.

Author
Mateusz Makowski
Date
14.09.2018

Macro Definition Documentation

◆ mu_assert

#define mu_assert (   message,
  test 
)
Value:
do { \
if (!(test)) \
return message; \
} while (0)

Assert truth or return an error message.

Parameters
messagestring to be returned on failure
testan expression that evaluates to 0 (false) or any other number (true)

◆ mu_assert_or_disconnect

#define mu_assert_or_disconnect (   bot,
  message,
  test 
)
Value:
do { \
if (!(test)) { \
bot_disconnect(bot); \
return message; \
} \
} while (0)

Same as mu_assert, but disconnects the bot before returning on failure.

Parameters
botpointer to IRC_Bot
messagestring to be returned on failure
testan expression that evaluates to 0 (false) or any other number (true)

◆ mu_run_test

#define mu_run_test (   name,
  test 
)
Value:
do { \
printf("%sTEST: %s%s\n", YELLOW, name, COLOR_END); \
char *message = test(); \
tests_run++; \
if (message) { \
strcpy(messages[tests_failed], message); \
tests_failed++; \
} \
} while (0)
char ** messages
List of messages from failed tests, for printing.
Definition: test_main.c:19
int tests_failed
Number of tests that failed.
Definition: test_main.c:18

Execute a test case.

Parameters
namestring containing the test name, can be anything
testfunction pointer to the test case

Variable Documentation

◆ messages

char** messages

List of messages from failed tests, for printing.

◆ tests_failed

int tests_failed

Number of tests that failed.

◆ tests_run

int tests_run

Total number of tests executed.