aboutsummaryrefslogtreecommitdiff
path: root/include/tatl/macros.h
blob: 7b1cc27290a066436e8bfb6f916a8fd4fd435887 (plain) (blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * This file is part of Tatl <https://github.com/Fuwn/tatl>.
 * Copyright (C) 2022-2022 Fuwn <[email protected]>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright (C) 2022-2022 Fuwn <[email protected]>
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef TATL_MACROS
#define TATL_MACROS

#include <tatl/context.h>

/* Shorthand for creating and initialising a new Tatl context with safe defaults
 *
 * Creates a new tatl_context and calls tatl_new on that context
 */
#define TATL_NEW()                                                             \
  struct tatl_context __context;                                               \
                                                                               \
  __context._total = 0;                                                        \
                                                                               \
  tatl_new(&__context)

/* Shorthand for tatl_finish */
#define TATL_FINISH() tatl_finish(&__context)

/* Shorthand for tatl_add */
#define TATL_ADD(tag, test) tatl_add(&__context, tag, test)

/* Define and name a test */
#define TATL_TEST(reference)                                                   \
  int reference(void);                                                         \
                                                                               \
  int reference(void)

/* Access the Tatl macro context */
#define TATL_CONTEXT __context

/* Evaluate two values' equality */
#define TATL_IS(a, b) (a == b)

/* Evaluate two values' inequality */
#define TATL_IS_NOT(a, b) (a != b)

/* Evaluate two strings' equality */
#define TATL_STR_IS(a, b) (strcmp(a, b) == 0)

/* Evaluate two strings' inequality */
#define TATL_STR_IS_NOT(a, b) (strcmp(a, b) != 0)

#endif /* TATL_MACROS */