2 * Copyright © 2021 Behdad Esfahbod
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
30 static const std::string invalid
{"invalid"};
33 main (int argc
, char **argv
)
36 /* Test copy constructor. */
41 assert (v1
.get_population () == 1);
42 assert (v2
.get_population () == 1);
47 /* Test copy assignment. */
52 assert (v1
.get_population () == 1);
53 assert (v2
.get_population () == 1);
58 /* Test move constructor. */
60 hb_map_t v
{hb_map_t
{}};
63 /* Test move assignment. */
69 /* Test initializing from iterable. */
78 assert (v
.get_population () == 2);
81 /* Test call fini() twice. */
84 for (int i
= 0; i
< 16; i
++)
89 /* Test initializing from iterator. */
96 hb_map_t
v (hb_iter (s
));
98 assert (v
.get_population () == 2);
101 /* Test initializing from initializer list and swapping. */
103 using pair_t
= hb_pair_t
<hb_codepoint_t
, hb_codepoint_t
>;
104 hb_map_t v1
{pair_t
{1,2}, pair_t
{4,5}};
105 hb_map_t v2
{pair_t
{3,4}};
107 assert (v1
.get_population () == 1);
108 assert (v2
.get_population () == 2);
111 /* Test class key / value types. */
113 hb_hashmap_t
<hb_bytes_t
, int, std::nullptr_t
, int, nullptr, 0> m1
;
114 hb_hashmap_t
<int, hb_bytes_t
, int, std::nullptr_t
, 0, nullptr> m2
;
115 hb_hashmap_t
<hb_bytes_t
, hb_bytes_t
, std::nullptr_t
, std::nullptr_t
, nullptr, nullptr> m3
;
116 assert (m1
.get_population () == 0);
117 assert (m2
.get_population () == 0);
118 assert (m3
.get_population () == 0);
122 hb_hashmap_t
<int, int, int, int, 0, 0> m0
;
123 hb_hashmap_t
<std::string
, int, const std::string
*, int, &invalid
, 0> m1
;
124 hb_hashmap_t
<int, std::string
, int, const std::string
*, 0, &invalid
> m2
;
125 hb_hashmap_t
<std::string
, std::string
, const std::string
*, const std::string
*, &invalid
, &invalid
> m3
;
128 for (unsigned i
= 1; i
< 1000; i
++)