1 /*
2 * Copyright © 2019 Facebook, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Facebook Author(s): Behdad Esfahbod
25 */
26
27 #include "hb.hh"
28 #include "hb-meta.hh"
29
30 #include <type_traits>
31
32 int
main(int argc,char ** argv)33 main (int argc, char **argv)
34 {
35 static_assert (hb_is_convertible (void, void), "");
36 static_assert (hb_is_convertible (void, const void), "");
37 static_assert (hb_is_convertible (const void, void), "");
38
39 static_assert (hb_is_convertible (int, int), "");
40 static_assert (hb_is_convertible (char, int), "");
41 static_assert (hb_is_convertible (long, int), "");
42
43 static_assert (hb_is_convertible (int, int), "");
44
45 static_assert (hb_is_convertible (const int, int), "");
46 static_assert (hb_is_convertible (int, const int), "");
47 static_assert (hb_is_convertible (const int, const int), "");
48
49 static_assert (hb_is_convertible (int&, int), "");
50 static_assert (!hb_is_convertible (int, int&), "");
51
52 static_assert (hb_is_convertible (int, const int&), "");
53 static_assert (!hb_is_convertible (const int, int&), "");
54 static_assert (hb_is_convertible (const int, const int&), "");
55 static_assert (hb_is_convertible (int&, const int), "");
56 static_assert (hb_is_convertible (const int&, int), "");
57 static_assert (hb_is_convertible (const int&, const int), "");
58 static_assert (hb_is_convertible (const int&, const int), "");
59
60 struct X {};
61 struct Y : X {};
62
63 static_assert (hb_is_convertible (const X &, const X), "");
64 static_assert (hb_is_convertible (X &, const X), "");
65 static_assert (hb_is_convertible (X &, const X &), "");
66 static_assert (hb_is_convertible (X, const X &), "");
67 static_assert (hb_is_convertible (const X, const X &), "");
68 static_assert (!hb_is_convertible (const X, X &), "");
69 static_assert (!hb_is_convertible (X, X &), "");
70 static_assert (hb_is_convertible (X &, X &), "");
71
72 static_assert (hb_is_convertible (int&, long), "");
73 static_assert (!hb_is_convertible (int&, long&), "");
74
75 static_assert (hb_is_convertible (int *, int *), "");
76 static_assert (hb_is_convertible (int *, const int *), "");
77 static_assert (!hb_is_convertible (const int *, int *), "");
78 static_assert (!hb_is_convertible (int *, long *), "");
79 static_assert (hb_is_convertible (int *, void *), "");
80 static_assert (!hb_is_convertible (void *, int *), "");
81
82 static_assert (hb_is_base_of (void, void), "");
83 static_assert (hb_is_base_of (void, int), "");
84 static_assert (!hb_is_base_of (int, void), "");
85
86 static_assert (hb_is_base_of (int, int), "");
87 static_assert (hb_is_base_of (const int, int), "");
88 static_assert (hb_is_base_of (int, const int), "");
89
90 static_assert (hb_is_base_of (X, X), "");
91 static_assert (hb_is_base_of (X, Y), "");
92 static_assert (hb_is_base_of (const X, Y), "");
93 static_assert (hb_is_base_of (X, const Y), "");
94 static_assert (!hb_is_base_of (Y, X), "");
95
96 static_assert (hb_is_constructible (int), "");
97 static_assert (hb_is_constructible (int, int), "");
98 static_assert (hb_is_constructible (int, char), "");
99 static_assert (hb_is_constructible (int, long), "");
100 static_assert (!hb_is_constructible (int, X), "");
101 static_assert (!hb_is_constructible (int, int, int), "");
102 static_assert (hb_is_constructible (X), "");
103 static_assert (!hb_is_constructible (X, int), "");
104 static_assert (hb_is_constructible (X, X), "");
105 static_assert (!hb_is_constructible (X, X, X), "");
106 static_assert (hb_is_constructible (X, Y), "");
107 static_assert (!hb_is_constructible (Y, X), "");
108
109 static_assert (hb_is_trivially_default_constructible (X), "");
110 static_assert (hb_is_trivially_default_constructible (Y), "");
111 static_assert (hb_is_trivially_copy_constructible (X), "");
112 static_assert (hb_is_trivially_copy_constructible (Y), "");
113 static_assert (hb_is_trivially_move_constructible (X), "");
114 static_assert (hb_is_trivially_move_constructible (Y), "");
115 static_assert (hb_is_trivially_destructible (Y), "");
116
117 static_assert (hb_is_trivially_copyable (int), "");
118 static_assert (hb_is_trivially_copyable (X), "");
119 static_assert (hb_is_trivially_copyable (Y), "");
120
121 static_assert (hb_is_trivial (int), "");
122 static_assert (hb_is_trivial (X), "");
123 static_assert (hb_is_trivial (Y), "");
124
125 /* TODO Add more meaningful tests. */
126
127 return 0;
128 }
129