The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
acutest_helpers.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /** Type specific TEST_CHECK macros for acutest
19  *
20  * @file src/lib/util/acutest_helpers.h
21  *
22  * @copyright 2020 Arran Cudbard-Bell
23  */
24 RCSIDH(acutest_helpers_h, "$Id: 4218ec7df6f779aaebf934b72565210e2b7b7578 $")
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define TEST_CHECK_LEN(_got, _exp) \
31 do { \
32  size_t _our_got = (_got); \
33  TEST_CHECK_(_exp == _our_got, "%s", #_got); \
34  TEST_MSG("Expected length : %zu", (size_t)_exp); \
35  TEST_MSG("Got length : %zu", (size_t)_our_got); \
36 } while(0)
37 
38 #define TEST_CHECK_SLEN(_got, _exp) \
39 do { \
40  ssize_t _our_got = (_got); \
41  TEST_CHECK_(_exp == _our_got, "%s", #_got); \
42  TEST_MSG("Expected length : %zd", (ssize_t)_exp); \
43  TEST_MSG("Got length : %zd", (ssize_t)_our_got); \
44 } while(0)
45 
46 #define TEST_CHECK_SLEN_RETURN(_got, _exp) \
47 do { \
48  ssize_t _our_got = (_got); \
49  TEST_CHECK_(_exp == _our_got, "%s", #_got); \
50  TEST_MSG("Expected length : %zd", (ssize_t)_exp); \
51  TEST_MSG("Got length : %zd", (ssize_t)_our_got); \
52  if (_exp != _our_got) return; \
53 } while(0)
54 
55 #define TEST_CHECK_RET(_got, _exp) \
56 do { \
57  int _our_got = (_got); \
58  TEST_CHECK_(_exp == _our_got, "%s", #_got); \
59  TEST_MSG("Expected ret : %"PRId64, (int64_t)_exp); \
60  TEST_MSG("Got ret : %"PRId64, (int64_t)_our_got); \
61 } while(0)
62 
63 #define TEST_CHECK_STRCMP(_got, _exp) \
64 do { \
65  char const *_our_got = (_got); \
66  TEST_CHECK_(((_exp) != NULL) && ((_got) != NULL) && (strcmp(_exp, _our_got) == 0), "%s", #_got); \
67  TEST_MSG("Expected : \"%s\"", _exp); \
68  TEST_MSG("Got : \"%s\"", _our_got); \
69 } while(0)
70 
71 #ifdef __cplusplus
72 }
73 #endif
#define RCSIDH(h, id)
Definition: build.h:482