File: minunit.h

package info (click to toggle)
libhdr-histogram 0.11.8-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 796 kB
  • sloc: ansic: 5,642; cpp: 133; sh: 13; makefile: 6
file content (52 lines) | stat: -rw-r--r-- 1,162 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * minunit.h
 * Written by Michael Barker and released to the public domain,
 * as explained at http://creativecommons.org/publicdomain/zero/1.0/
 */

#ifndef MINUNIT_H
#define MINUNIT_H

#include <math.h>
#include <inttypes.h>
#include <stdbool.h>

struct mu_result
{
    char* test;
    char* message;
};

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

#define mu_run_test(name)        \
    do {                         \
        char *message = name();  \
        tests_run++;             \
        if (message) {           \
            struct mu_result r;  \
            r.test = #name;      \
            r.message = message; \
            return r;            \
        }                        \
    } while (0)

#define mu_ok               \
    do {                    \
        struct mu_result r; \
        r.test = 0;         \
        r.message = 0;      \
        return r;           \
    } while (0)

extern int tests_run;

bool compare_double(double a, double b, double delta);

bool compare_int64(int64_t a, int64_t b);

#endif