Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
complex.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2017 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#ifndef CRITERION_INTERNAL_COMPLEX_H_
25#define CRITERION_INTERNAL_COMPLEX_H_
26
27#if defined (__cplusplus)
28# include <complex>
29
30# define CRI_ASSERT_TEST_TAG_cx_flt ,
31# define CRI_ASSERT_TEST_TAGC_cx_flt() ,
32# define CRI_ASSERT_TYPE_TAG_cx_flt std::complex<float>
33# define CRI_ASSERT_TEST_TAG_ID_cx_flt cx_flt,
34
35# define CRI_ASSERT_TEST_TAG_cx_dbl ,
36# define CRI_ASSERT_TEST_TAGC_cx_dbl() ,
37# define CRI_ASSERT_TYPE_TAG_cx_dbl std::complex<double>
38# define CRI_ASSERT_TEST_TAG_ID_cx_dbl cx_dbl,
39
40# define CRI_ASSERT_TEST_TAG_cx_ldbl ,
41# define CRI_ASSERT_TEST_TAGC_cx_ldbl() ,
42# define CRI_ASSERT_TYPE_TAG_cx_ldbl std::complex<long double>
43# define CRI_ASSERT_TEST_TAG_ID_cx_ldbl cx_ldbl,
44
45#elif defined (__STDC__)
46# include <complex.h>
47
48# define CRI_ASSERT_TEST_TAG_cx_flt ,
49# define CRI_ASSERT_TEST_TAGC_cx_flt() ,
50# define CRI_ASSERT_TYPE_TAG_cx_flt _Complex float
51# define CRI_ASSERT_TEST_TAG_ID_cx_flt cx_flt,
52
53# define CRI_ASSERT_TEST_TAG_cx_dbl ,
54# define CRI_ASSERT_TEST_TAGC_cx_dbl() ,
55# define CRI_ASSERT_TYPE_TAG_cx_dbl _Complex double
56# define CRI_ASSERT_TEST_TAG_ID_cx_dbl cx_dbl,
57
58# define CRI_ASSERT_TEST_TAG_cx_ldbl ,
59# define CRI_ASSERT_TEST_TAGC_cx_ldbl() ,
60# if defined (CRI_CAPS_LDBL_IS_DBL)
61# define CRI_ASSERT_TYPE_TAG_cx_ldbl _Complex double
62# else
63# define CRI_ASSERT_TYPE_TAG_cx_ldbl _Complex long double
64# endif
65# define CRI_ASSERT_TEST_TAG_ID_cx_ldbl cx_ldbl,
66
67# define CRI_ASSERT_DECLARE_COMPLEX_FN(Tag, Fmt, S) \
68 static inline int CRI_USER_TAG_ID(eq, Tag)( \
69 CRI_ASSERT_TYPE_TAG(Tag) *actual, \
70 CRI_ASSERT_TYPE_TAG(Tag) *expected) \
71 { \
72 return *actual == *expected; \
73 } \
74 static inline char *CRI_USER_TAG_ID(tostr, Tag)( \
75 CRI_ASSERT_TYPE_TAG(Tag) *e) \
76 { \
77 char *str = NULL; \
78 cr_asprintf(&str, "%" Fmt " + i%" Fmt, creal ## S(*e), cimag ## S(*e)); \
79 return str; \
80 }
81
82CRI_ASSERT_DECLARE_COMPLEX_FN(cx_flt, "." CRI_FLT_DIG "g", f)
83CRI_ASSERT_DECLARE_COMPLEX_FN(cx_dbl, "." CRI_DBL_DIG "g", )
84
85# if defined (CRI_CAPS_LDBL_IS_DBL)
86CRI_ASSERT_DECLARE_COMPLEX_FN(cx_ldbl, "." CRI_DBL_DIG "g", )
87# else
88CRI_ASSERT_DECLARE_COMPLEX_FN(cx_ldbl, "." CRI_LDBL_DIG "Lg", l)
89# endif
90
91#endif
92
93#endif /* !CRITERION_INTERNAL_COMPLEX_H_ */
#define CRI_LDBL_DIG
Definition tag.h:344
#define CRI_DBL_DIG
Definition tag.h:332
#define CRI_FLT_DIG
Definition tag.h:322