xref: /netbsd-src/tests/lib/libprop/t_proplib.c (revision 492187ea097ff9fe25185b3c132ccfbd7da9831b)
1*492187eaSthorpej /* $NetBSD: t_proplib.c,v 1.4 2020/06/24 14:28:10 thorpej Exp $ */
2a792b843Sthorpej 
3a792b843Sthorpej /*
4a792b843Sthorpej  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
5a792b843Sthorpej  * All rights reserved.
6a792b843Sthorpej  *
7a792b843Sthorpej  * Redistribution and use in source and binary forms, with or without
8a792b843Sthorpej  * modification, are permitted provided that the following conditions
9a792b843Sthorpej  * are met:
10a792b843Sthorpej  * 1. Redistributions of source code must retain the above copyright
11a792b843Sthorpej  *    notice, this list of conditions and the following disclaimer.
12a792b843Sthorpej  * 2. Redistributions in binary form must reproduce the above copyright
13a792b843Sthorpej  *    notice, this list of conditions and the following disclaimer in the
14a792b843Sthorpej  *    documentation and/or other materials provided with the distribution.
15a792b843Sthorpej  *
16a792b843Sthorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17a792b843Sthorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18a792b843Sthorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19a792b843Sthorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20a792b843Sthorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21a792b843Sthorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22a792b843Sthorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23a792b843Sthorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24a792b843Sthorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25a792b843Sthorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26a792b843Sthorpej  * POSSIBILITY OF SUCH DAMAGE.
27a792b843Sthorpej  */
28a792b843Sthorpej 
29a792b843Sthorpej /*
30a792b843Sthorpej  * Written by Jason Thorpe 5/26/2006.
31a792b843Sthorpej  * Public domain.
32a792b843Sthorpej  */
33a792b843Sthorpej 
34a792b843Sthorpej #include <sys/cdefs.h>
35a792b843Sthorpej __COPYRIGHT("@(#) Copyright (c) 2008, 2020\
36a792b843Sthorpej  The NetBSD Foundation, inc. All rights reserved.");
37*492187eaSthorpej __RCSID("$NetBSD: t_proplib.c,v 1.4 2020/06/24 14:28:10 thorpej Exp $");
38a792b843Sthorpej 
39a792b843Sthorpej #include <limits.h>
40a792b843Sthorpej #include <stdlib.h>
41a792b843Sthorpej #include <string.h>
42a792b843Sthorpej #include <prop/proplib.h>
43a792b843Sthorpej 
44a792b843Sthorpej #include <atf-c.h>
45a792b843Sthorpej 
46a792b843Sthorpej static const char compare1[] =
47a792b843Sthorpej "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
48a792b843Sthorpej "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
49a792b843Sthorpej "<plist version=\"1.0\">\n"
50a792b843Sthorpej "<dict>\n"
51a792b843Sthorpej "	<key>false-val</key>\n"
52a792b843Sthorpej "	<false/>\n"
53a792b843Sthorpej "	<key>one</key>\n"
54a792b843Sthorpej "	<integer>1</integer>\n"
55a792b843Sthorpej "	<key>three</key>\n"
56a792b843Sthorpej "	<array>\n"
57a792b843Sthorpej "		<dict>\n"
58a792b843Sthorpej "			<key>one</key>\n"
59a792b843Sthorpej "			<integer>1</integer>\n"
60a792b843Sthorpej "			<key>two</key>\n"
61a792b843Sthorpej "			<string>number-two</string>\n"
62a792b843Sthorpej "		</dict>\n"
63a792b843Sthorpej "		<dict>\n"
64a792b843Sthorpej "			<key>one</key>\n"
65a792b843Sthorpej "			<integer>1</integer>\n"
66a792b843Sthorpej "			<key>two</key>\n"
67a792b843Sthorpej "			<string>number-two</string>\n"
68a792b843Sthorpej "		</dict>\n"
69a792b843Sthorpej "		<dict>\n"
70a792b843Sthorpej "			<key>one</key>\n"
71a792b843Sthorpej "			<integer>1</integer>\n"
72a792b843Sthorpej "			<key>two</key>\n"
73a792b843Sthorpej "			<string>number-two</string>\n"
74a792b843Sthorpej "		</dict>\n"
75a792b843Sthorpej "	</array>\n"
76a792b843Sthorpej "	<key>true-val</key>\n"
77a792b843Sthorpej "	<true/>\n"
78a792b843Sthorpej "	<key>two</key>\n"
79a792b843Sthorpej "	<string>number-two</string>\n"
80a792b843Sthorpej "</dict>\n"
81a792b843Sthorpej "</plist>\n";
82a792b843Sthorpej 
83a792b843Sthorpej static const char const_data1[] = {
84a792b843Sthorpej 	0xde, 0xad, 0xbe, 0xef
85a792b843Sthorpej };
86a792b843Sthorpej 
87a792b843Sthorpej static const char const_data2[] = {
88a792b843Sthorpej 	0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55
89a792b843Sthorpej };
90a792b843Sthorpej 
91a792b843Sthorpej static const char const_string1[] =
92a792b843Sthorpej     "The quick brown fox jumps over the lazy dog.";
93a792b843Sthorpej 
94a792b843Sthorpej static const char const_string2[] =
95a792b843Sthorpej     "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
96a792b843Sthorpej     "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
97a792b843Sthorpej 
98a792b843Sthorpej ATF_TC(prop_basic);
ATF_TC_HEAD(prop_basic,tc)99a792b843Sthorpej ATF_TC_HEAD(prop_basic, tc)
100a792b843Sthorpej {
101a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "A basic test of proplib(3)");
102a792b843Sthorpej }
103a792b843Sthorpej 
ATF_TC_BODY(prop_basic,tc)104a792b843Sthorpej ATF_TC_BODY(prop_basic, tc)
105a792b843Sthorpej {
106a792b843Sthorpej 	prop_dictionary_t dict;
107a792b843Sthorpej 	char *ext1;
108a792b843Sthorpej 
109a792b843Sthorpej 	dict = prop_dictionary_create();
110a792b843Sthorpej 	ATF_REQUIRE(dict != NULL);
111a792b843Sthorpej 
112a792b843Sthorpej 	{
1139bc38ca6Sthorpej 		prop_number_t num = prop_number_create_signed(1);
114a792b843Sthorpej 		ATF_REQUIRE(num != NULL);
115a792b843Sthorpej 
116a792b843Sthorpej 		ATF_REQUIRE_EQ(prop_dictionary_set(dict, "one", num), true);
117a792b843Sthorpej 		prop_object_release(num);
118a792b843Sthorpej 	}
119a792b843Sthorpej 
120a792b843Sthorpej 	{
1219bc38ca6Sthorpej 		prop_string_t str = prop_string_create_copy("number-two");
122a792b843Sthorpej 		ATF_REQUIRE(str != NULL);
123a792b843Sthorpej 
124a792b843Sthorpej 		ATF_REQUIRE_EQ(prop_dictionary_set(dict, "two", str), true);
125a792b843Sthorpej 		prop_object_release(str);
126a792b843Sthorpej 	}
127a792b843Sthorpej 
128a792b843Sthorpej 	{
129a792b843Sthorpej 		prop_array_t arr;
130a792b843Sthorpej 		prop_dictionary_t dict_copy;
131a792b843Sthorpej 		int i;
132a792b843Sthorpej 
133a792b843Sthorpej 		arr = prop_array_create();
134a792b843Sthorpej 		ATF_REQUIRE(arr != NULL);
135a792b843Sthorpej 
136a792b843Sthorpej 		for (i = 0; i < 3; ++i) {
137a792b843Sthorpej 			dict_copy = prop_dictionary_copy(dict);
138a792b843Sthorpej 			ATF_REQUIRE(dict_copy != NULL);
139a792b843Sthorpej 			ATF_REQUIRE_EQ(prop_array_add(arr, dict_copy), true);
140a792b843Sthorpej 			prop_object_release(dict_copy);
141a792b843Sthorpej 		}
142a792b843Sthorpej 
143a792b843Sthorpej 		ATF_REQUIRE_EQ(prop_dictionary_set(dict, "three", arr), true);
144a792b843Sthorpej 		prop_object_release(arr);
145a792b843Sthorpej 	}
146a792b843Sthorpej 
147a792b843Sthorpej 	{
148a792b843Sthorpej 		prop_bool_t val = prop_bool_create(true);
149a792b843Sthorpej 		ATF_REQUIRE(val != NULL);
150a792b843Sthorpej 		ATF_REQUIRE_EQ(prop_dictionary_set(dict, "true-val", val), true);
151a792b843Sthorpej 		prop_object_release(val);
152a792b843Sthorpej 
153a792b843Sthorpej 		val = prop_bool_create(false);
154a792b843Sthorpej 		ATF_REQUIRE(val != NULL);
155a792b843Sthorpej 		ATF_REQUIRE_EQ(prop_dictionary_set(dict, "false-val", val), true);
156a792b843Sthorpej 		prop_object_release(val);
157a792b843Sthorpej 	}
158a792b843Sthorpej 
159a792b843Sthorpej 	ext1 = prop_dictionary_externalize(dict);
160a792b843Sthorpej 	ATF_REQUIRE(ext1 != NULL);
161a792b843Sthorpej 	ATF_REQUIRE_STREQ(compare1, ext1);
162a792b843Sthorpej 
163a792b843Sthorpej 	{
164a792b843Sthorpej 		prop_dictionary_t dict2;
165a792b843Sthorpej 		char *ext2;
166a792b843Sthorpej 
167a792b843Sthorpej 		dict2 = prop_dictionary_internalize(ext1);
168a792b843Sthorpej 		ATF_REQUIRE(dict2 != NULL);
169a792b843Sthorpej 		ext2 = prop_dictionary_externalize(dict2);
170a792b843Sthorpej 		ATF_REQUIRE(ext2 != NULL);
171a792b843Sthorpej 		ATF_REQUIRE_STREQ(ext1, ext2);
172a792b843Sthorpej 		prop_object_release(dict2);
173a792b843Sthorpej 		free(ext2);
174a792b843Sthorpej 	}
175a792b843Sthorpej 
176a792b843Sthorpej 	prop_object_release(dict);
177a792b843Sthorpej 	free(ext1);
178a792b843Sthorpej }
179a792b843Sthorpej 
180a792b843Sthorpej ATF_TC(prop_dictionary_equals);
ATF_TC_HEAD(prop_dictionary_equals,tc)181a792b843Sthorpej ATF_TC_HEAD(prop_dictionary_equals, tc)
182a792b843Sthorpej {
183a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "Test prop_dictionary_equals(3)");
184a792b843Sthorpej }
185a792b843Sthorpej 
ATF_TC_BODY(prop_dictionary_equals,tc)186a792b843Sthorpej ATF_TC_BODY(prop_dictionary_equals, tc)
187a792b843Sthorpej {
188a792b843Sthorpej 	prop_dictionary_t c, d;
189a792b843Sthorpej 
190a792b843Sthorpej 	/*
191a792b843Sthorpej 	 * Fixed, should not fail any more...
192a792b843Sthorpej 	 *
193a792b843Sthorpej 	atf_tc_expect_death("PR lib/43964");
194a792b843Sthorpej 	 *
195a792b843Sthorpej 	 */
196a792b843Sthorpej 
197a792b843Sthorpej 	d = prop_dictionary_internalize(compare1);
198a792b843Sthorpej 
199a792b843Sthorpej 	ATF_REQUIRE(d != NULL);
200a792b843Sthorpej 
201a792b843Sthorpej 	c = prop_dictionary_copy(d);
202a792b843Sthorpej 
203a792b843Sthorpej 	ATF_REQUIRE(c != NULL);
204a792b843Sthorpej 
205a792b843Sthorpej 	if (prop_dictionary_equals(c, d) != true)
206a792b843Sthorpej 		atf_tc_fail("dictionaries are not equal");
207a792b843Sthorpej 
208a792b843Sthorpej 	prop_object_release(c);
209a792b843Sthorpej 	prop_object_release(d);
210a792b843Sthorpej }
211a792b843Sthorpej 
212a792b843Sthorpej ATF_TC(prop_data_basic);
ATF_TC_HEAD(prop_data_basic,tc)213a792b843Sthorpej ATF_TC_HEAD(prop_data_basic, tc)
214a792b843Sthorpej {
215a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "tests prop_data basics");
216a792b843Sthorpej }
ATF_TC_BODY(prop_data_basic,tc)217a792b843Sthorpej ATF_TC_BODY(prop_data_basic, tc)
218a792b843Sthorpej {
219a792b843Sthorpej 	prop_data_t d1, d2;
220a792b843Sthorpej 	char buf[sizeof(const_data1)];
221a792b843Sthorpej 
222a792b843Sthorpej 	/*
223a792b843Sthorpej 	 * This test exercises implementation details, not only
224a792b843Sthorpej 	 * API contract.
225a792b843Sthorpej 	 */
226a792b843Sthorpej 
2279a0cd196Sthorpej 	d1 = prop_data_create_copy(const_data1, 0);
2289a0cd196Sthorpej 	ATF_REQUIRE(d1 != NULL);
2299a0cd196Sthorpej 	ATF_REQUIRE(prop_data_value(d1) == NULL);
2309a0cd196Sthorpej 	prop_object_release(d1);
2319a0cd196Sthorpej 
2329a0cd196Sthorpej 	d1 = prop_data_create_copy(NULL, sizeof(const_data1));
2339a0cd196Sthorpej 	ATF_REQUIRE(d1 != NULL);
2349a0cd196Sthorpej 	ATF_REQUIRE(prop_data_value(d1) == NULL);
2359a0cd196Sthorpej 	prop_object_release(d1);
2369a0cd196Sthorpej 
2379a0cd196Sthorpej 	d1 = prop_data_create_nocopy(const_data1, 0);
2389a0cd196Sthorpej 	ATF_REQUIRE(d1 != NULL);
2399a0cd196Sthorpej 	ATF_REQUIRE(prop_data_value(d1) == NULL);
2409a0cd196Sthorpej 	prop_object_release(d1);
2419a0cd196Sthorpej 
2429a0cd196Sthorpej 	d1 = prop_data_create_nocopy(NULL, sizeof(const_data1));
2439a0cd196Sthorpej 	ATF_REQUIRE(d1 != NULL);
2449a0cd196Sthorpej 	ATF_REQUIRE(prop_data_value(d1) == NULL);
2459a0cd196Sthorpej 	prop_object_release(d1);
2469a0cd196Sthorpej 
247a792b843Sthorpej 	d1 = prop_data_create_nocopy(const_data1, sizeof(const_data1));
248a792b843Sthorpej 	ATF_REQUIRE(d1 != NULL);
249a792b843Sthorpej 	ATF_REQUIRE(prop_data_value(d1) == const_data1);
250a792b843Sthorpej 	d2 = prop_data_copy(d1);
251a792b843Sthorpej 	ATF_REQUIRE(d2 != NULL);
252a792b843Sthorpej 	ATF_REQUIRE(d2 == d1);
253a792b843Sthorpej 	prop_object_release(d1);
254a792b843Sthorpej 	prop_object_release(d2);
255a792b843Sthorpej 
256a792b843Sthorpej 	d1 = prop_data_create_copy(const_data1, sizeof(const_data1));
257a792b843Sthorpej 	ATF_REQUIRE(d1 != NULL);
258a792b843Sthorpej 	ATF_REQUIRE(prop_data_value(d1) != const_data1);
259a792b843Sthorpej 	d2 = prop_data_copy(d1);
260a792b843Sthorpej 	ATF_REQUIRE(d2 != NULL);
261a792b843Sthorpej 	ATF_REQUIRE(d2 == d1);
262a792b843Sthorpej 	ATF_REQUIRE(prop_data_equals(d1, d2));
263a792b843Sthorpej 	prop_object_release(d2);
264a792b843Sthorpej 
265a792b843Sthorpej 	d2 = prop_data_create_copy(const_data2, sizeof(const_data2));
266a792b843Sthorpej 	ATF_REQUIRE(d2 != NULL);
267a792b843Sthorpej 	ATF_REQUIRE(prop_data_value(d2) != const_data2);
268a792b843Sthorpej 	ATF_REQUIRE(!prop_data_equals(d1, d2));
269a792b843Sthorpej 
270a792b843Sthorpej 	ATF_REQUIRE(prop_data_size(d1) == sizeof(const_data1));
271a792b843Sthorpej 	ATF_REQUIRE(prop_data_size(d2) == sizeof(const_data2));
272a792b843Sthorpej 
273a792b843Sthorpej 	ATF_REQUIRE(prop_data_copy_value(d1, buf, sizeof(buf)));
274a792b843Sthorpej 	ATF_REQUIRE(memcmp(buf, const_data1, sizeof(buf)) == 0);
275a792b843Sthorpej 	ATF_REQUIRE(!prop_data_copy_value(d2, buf, sizeof(buf)));
276a792b843Sthorpej 
277a792b843Sthorpej 	prop_object_release(d1);
278a792b843Sthorpej 	prop_object_release(d2);
279a792b843Sthorpej }
280a792b843Sthorpej 
281a792b843Sthorpej ATF_TC(prop_number_basic);
ATF_TC_HEAD(prop_number_basic,tc)282a792b843Sthorpej ATF_TC_HEAD(prop_number_basic, tc)
283a792b843Sthorpej {
284a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "tests prop_number basics");
285a792b843Sthorpej }
ATF_TC_BODY(prop_number_basic,tc)286a792b843Sthorpej ATF_TC_BODY(prop_number_basic, tc)
287a792b843Sthorpej {
288a792b843Sthorpej 	prop_number_t s1, s2, u1, u2, u3, u4;
289a792b843Sthorpej 
290a792b843Sthorpej 	/*
291a792b843Sthorpej 	 * This test exercises implementation details, not only
292a792b843Sthorpej 	 * API contract.
293a792b843Sthorpej 	 */
294a792b843Sthorpej 
295a792b843Sthorpej 	s1 = prop_number_create_signed(INTMAX_MAX);
296a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
297a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned(s1) == false);
298a792b843Sthorpej 	ATF_REQUIRE(prop_number_signed_value(s1) == INTMAX_MAX);
299a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned_value(s1) == INTMAX_MAX);
300a792b843Sthorpej 	ATF_REQUIRE(prop_number_equals_signed(s1, INTMAX_MAX) == true);
301a792b843Sthorpej 
302a792b843Sthorpej 	s2 = prop_number_create_signed(INTMAX_MAX);
303a792b843Sthorpej 	ATF_REQUIRE(s2 == s1);
304a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned(s2) == false);
305a792b843Sthorpej 
306a792b843Sthorpej 	u1 = prop_number_create_unsigned(UINTMAX_MAX);
307a792b843Sthorpej 	ATF_REQUIRE(u1 != NULL);
308a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned(u1) == true);
309a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned_value(u1) == UINTMAX_MAX);
310a792b843Sthorpej 	ATF_REQUIRE(prop_number_equals_unsigned(u1, UINTMAX_MAX) == true);
311a792b843Sthorpej 
312a792b843Sthorpej 	u2 = prop_number_create_unsigned(0);
313a792b843Sthorpej 	ATF_REQUIRE(u2 != NULL);
314a792b843Sthorpej 	ATF_REQUIRE(u2 != u1);
315a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned(u2) == true);
316a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned_value(u2) == 0);
317a792b843Sthorpej 
318a792b843Sthorpej 	u3 = prop_number_copy(u1);
319a792b843Sthorpej 	ATF_REQUIRE(u3 == u1);
320a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned(u3) == true);
321a792b843Sthorpej 	ATF_REQUIRE(prop_number_unsigned_value(u3) == UINTMAX_MAX);
322a792b843Sthorpej 
323a792b843Sthorpej 	u4 = prop_number_create_unsigned(INTMAX_MAX);
324a792b843Sthorpej 	ATF_REQUIRE(u4 != NULL);
325a792b843Sthorpej 	ATF_REQUIRE(u4 != s1);
326a792b843Sthorpej 	ATF_REQUIRE(prop_number_equals_signed(u4, INTMAX_MAX) == true);
327a792b843Sthorpej 	ATF_REQUIRE(prop_number_equals_unsigned(u4, INTMAX_MAX) == true);
328a792b843Sthorpej 
329a792b843Sthorpej 	prop_object_release(s1);
330a792b843Sthorpej 	prop_object_release(s2);
331a792b843Sthorpej 
332a792b843Sthorpej 	prop_object_release(u1);
333a792b843Sthorpej 	prop_object_release(u2);
334a792b843Sthorpej 	prop_object_release(u3);
335a792b843Sthorpej 	prop_object_release(u4);
336a792b843Sthorpej }
337a792b843Sthorpej 
338a792b843Sthorpej ATF_TC(prop_number_range_check);
ATF_TC_HEAD(prop_number_range_check,tc)339a792b843Sthorpej ATF_TC_HEAD(prop_number_range_check, tc)
340a792b843Sthorpej {
341a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "tests prop_number range checking");
342a792b843Sthorpej }
ATF_TC_BODY(prop_number_range_check,tc)343a792b843Sthorpej ATF_TC_BODY(prop_number_range_check, tc)
344a792b843Sthorpej {
345a792b843Sthorpej 	union {
346a792b843Sthorpej 		signed char v_schar;
347a792b843Sthorpej 		short v_shrt;
348a792b843Sthorpej 		int v_int;
349a792b843Sthorpej 		long v_long;
350a792b843Sthorpej 		long long v_llong;
351a792b843Sthorpej 		intptr_t v_intptr;
352a792b843Sthorpej 		int8_t v_int8;
353a792b843Sthorpej 		int16_t v_int16;
354a792b843Sthorpej 		int32_t v_int32;
355a792b843Sthorpej 		int64_t v_int64;
356a792b843Sthorpej 
357a792b843Sthorpej 		unsigned char v_uchar;
358a792b843Sthorpej 		unsigned short v_ushrt;
359a792b843Sthorpej 		unsigned int v_uint;
360a792b843Sthorpej 		unsigned long v_ulong;
361a792b843Sthorpej 		unsigned long long v_ullong;
362a792b843Sthorpej 		uintptr_t v_uintptr;
363a792b843Sthorpej 		uint8_t v_uint8;
364a792b843Sthorpej 		uint16_t v_uint16;
365a792b843Sthorpej 		uint32_t v_uint32;
366a792b843Sthorpej 		uint64_t v_uint64;
367a792b843Sthorpej 	} val;
368a792b843Sthorpej 
369a792b843Sthorpej 	prop_number_t n_schar_max = prop_number_create_signed(SCHAR_MAX);
370a792b843Sthorpej 	prop_number_t n_schar_min = prop_number_create_signed(SCHAR_MIN);
371a792b843Sthorpej 	prop_number_t n_uchar_max = prop_number_create_unsigned(UCHAR_MAX);
372a792b843Sthorpej 	ATF_REQUIRE(n_schar_max != NULL);
373a792b843Sthorpej 	ATF_REQUIRE(n_schar_min != NULL);
374a792b843Sthorpej 	ATF_REQUIRE(n_uchar_max != NULL);
375a792b843Sthorpej 
376a792b843Sthorpej 	prop_number_t n_shrt_max = prop_number_create_signed(SHRT_MAX);
377a792b843Sthorpej 	prop_number_t n_shrt_min = prop_number_create_signed(SHRT_MIN);
378a792b843Sthorpej 	prop_number_t n_ushrt_max = prop_number_create_unsigned(USHRT_MAX);
379a792b843Sthorpej 	ATF_REQUIRE(n_shrt_max != NULL);
380a792b843Sthorpej 	ATF_REQUIRE(n_shrt_min != NULL);
381a792b843Sthorpej 	ATF_REQUIRE(n_ushrt_max != NULL);
382a792b843Sthorpej 
383a792b843Sthorpej 	prop_number_t n_int_max = prop_number_create_signed(INT_MAX);
384a792b843Sthorpej 	prop_number_t n_int_min = prop_number_create_signed(INT_MIN);
385a792b843Sthorpej 	prop_number_t n_uint_max = prop_number_create_unsigned(UINT_MAX);
386a792b843Sthorpej 	ATF_REQUIRE(n_int_max != NULL);
387a792b843Sthorpej 	ATF_REQUIRE(n_int_min != NULL);
388a792b843Sthorpej 	ATF_REQUIRE(n_uint_max != NULL);
389a792b843Sthorpej 
390a792b843Sthorpej 	prop_number_t n_long_max = prop_number_create_signed(LONG_MAX);
391a792b843Sthorpej 	prop_number_t n_long_min = prop_number_create_signed(LONG_MIN);
392a792b843Sthorpej 	prop_number_t n_ulong_max = prop_number_create_unsigned(ULONG_MAX);
393a792b843Sthorpej 	ATF_REQUIRE(n_long_max != NULL);
394a792b843Sthorpej 	ATF_REQUIRE(n_long_min != NULL);
395a792b843Sthorpej 	ATF_REQUIRE(n_ulong_max != NULL);
396a792b843Sthorpej 
397a792b843Sthorpej 	prop_number_t n_llong_max = prop_number_create_signed(LLONG_MAX);
398a792b843Sthorpej 	prop_number_t n_llong_min = prop_number_create_signed(LLONG_MIN);
399a792b843Sthorpej 	prop_number_t n_ullong_max = prop_number_create_unsigned(ULLONG_MAX);
400a792b843Sthorpej 	ATF_REQUIRE(n_llong_max != NULL);
401a792b843Sthorpej 	ATF_REQUIRE(n_llong_min != NULL);
402a792b843Sthorpej 	ATF_REQUIRE(n_ullong_max != NULL);
403a792b843Sthorpej 
404a792b843Sthorpej 	prop_number_t n_intptr_max = prop_number_create_signed(INTPTR_MAX);
405a792b843Sthorpej 	prop_number_t n_intptr_min = prop_number_create_signed(INTPTR_MIN);
406a792b843Sthorpej 	prop_number_t n_uintptr_max = prop_number_create_unsigned(UINTPTR_MAX);
407a792b843Sthorpej 	ATF_REQUIRE(n_intptr_max != NULL);
408a792b843Sthorpej 	ATF_REQUIRE(n_intptr_min != NULL);
409a792b843Sthorpej 	ATF_REQUIRE(n_uintptr_max != NULL);
410a792b843Sthorpej 
411a792b843Sthorpej 	prop_number_t n_int8_max = prop_number_create_signed(INT8_MAX);
412a792b843Sthorpej 	prop_number_t n_int8_min = prop_number_create_signed(INT8_MIN);
413a792b843Sthorpej 	prop_number_t n_uint8_max = prop_number_create_unsigned(UINT8_MAX);
414a792b843Sthorpej 	ATF_REQUIRE(n_int8_max != NULL);
415a792b843Sthorpej 	ATF_REQUIRE(n_int8_min != NULL);
416a792b843Sthorpej 	ATF_REQUIRE(n_uint8_max != NULL);
417a792b843Sthorpej 
418a792b843Sthorpej 	prop_number_t n_int16_max = prop_number_create_signed(INT16_MAX);
419a792b843Sthorpej 	prop_number_t n_int16_min = prop_number_create_signed(INT16_MIN);
420a792b843Sthorpej 	prop_number_t n_uint16_max = prop_number_create_unsigned(UINT16_MAX);
421a792b843Sthorpej 	ATF_REQUIRE(n_int16_max != NULL);
422a792b843Sthorpej 	ATF_REQUIRE(n_int16_min != NULL);
423a792b843Sthorpej 	ATF_REQUIRE(n_uint16_max != NULL);
424a792b843Sthorpej 
425a792b843Sthorpej 	prop_number_t n_int32_max = prop_number_create_signed(INT32_MAX);
426a792b843Sthorpej 	prop_number_t n_int32_min = prop_number_create_signed(INT32_MIN);
427a792b843Sthorpej 	prop_number_t n_uint32_max = prop_number_create_unsigned(UINT32_MAX);
428a792b843Sthorpej 	ATF_REQUIRE(n_int32_max != NULL);
429a792b843Sthorpej 	ATF_REQUIRE(n_int32_min != NULL);
430a792b843Sthorpej 	ATF_REQUIRE(n_uint32_max != NULL);
431a792b843Sthorpej 
432a792b843Sthorpej 	prop_number_t n_int64_max = prop_number_create_signed(INT64_MAX);
433a792b843Sthorpej 	prop_number_t n_int64_min = prop_number_create_signed(INT64_MIN);
434a792b843Sthorpej 	prop_number_t n_uint64_max = prop_number_create_unsigned(UINT64_MAX);
435a792b843Sthorpej 	ATF_REQUIRE(n_int64_max != NULL);
436a792b843Sthorpej 	ATF_REQUIRE(n_int64_min != NULL);
437a792b843Sthorpej 	ATF_REQUIRE(n_uint64_max != NULL);
438a792b843Sthorpej 
439a792b843Sthorpej 	/* signed / unsigned char */
440a792b843Sthorpej 	ATF_REQUIRE(prop_number_schar_value(n_schar_max, &val.v_schar) &&
441a792b843Sthorpej 		    val.v_schar == SCHAR_MAX);
442a792b843Sthorpej 	ATF_REQUIRE(prop_number_schar_value(n_schar_min, &val.v_schar) &&
443a792b843Sthorpej 		    val.v_schar == SCHAR_MIN);
444a792b843Sthorpej 	ATF_REQUIRE(!prop_number_schar_value(n_uchar_max, &val.v_schar));
445a792b843Sthorpej 
446a792b843Sthorpej 	ATF_REQUIRE(prop_number_uchar_value(n_schar_max, &val.v_uchar) &&
447a792b843Sthorpej 		    val.v_uchar == SCHAR_MAX);
448a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uchar_value(n_schar_min, &val.v_uchar));
449a792b843Sthorpej 	ATF_REQUIRE(prop_number_uchar_value(n_uchar_max, &val.v_uchar) &&
450a792b843Sthorpej 		    val.v_uchar == UCHAR_MAX);
451a792b843Sthorpej 
452a792b843Sthorpej 	ATF_REQUIRE(!prop_number_schar_value(n_shrt_min, &val.v_schar));
453a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uchar_value(n_shrt_max, &val.v_uchar));
454a792b843Sthorpej 
455a792b843Sthorpej 	/* short / unsigned short */
456a792b843Sthorpej 	ATF_REQUIRE(prop_number_short_value(n_uchar_max, &val.v_shrt) &&
457a792b843Sthorpej 		    val.v_shrt == UCHAR_MAX);
458a792b843Sthorpej 
459a792b843Sthorpej 	ATF_REQUIRE(prop_number_short_value(n_shrt_max, &val.v_shrt) &&
460a792b843Sthorpej 		    val.v_shrt == SHRT_MAX);
461a792b843Sthorpej 	ATF_REQUIRE(prop_number_short_value(n_shrt_min, &val.v_shrt) &&
462a792b843Sthorpej 		    val.v_shrt == SHRT_MIN);
463a792b843Sthorpej 	ATF_REQUIRE(!prop_number_short_value(n_ushrt_max, &val.v_shrt));
464a792b843Sthorpej 
465a792b843Sthorpej 	ATF_REQUIRE(prop_number_ushort_value(n_shrt_max, &val.v_ushrt) &&
466a792b843Sthorpej 		    val.v_ushrt == SHRT_MAX);
467a792b843Sthorpej 	ATF_REQUIRE(!prop_number_ushort_value(n_shrt_min, &val.v_ushrt));
468a792b843Sthorpej 	ATF_REQUIRE(prop_number_ushort_value(n_ushrt_max, &val.v_ushrt) &&
469a792b843Sthorpej 		    val.v_ushrt == USHRT_MAX);
470a792b843Sthorpej 
471a792b843Sthorpej 	ATF_REQUIRE(!prop_number_short_value(n_int_min, &val.v_shrt));
472a792b843Sthorpej 	ATF_REQUIRE(!prop_number_ushort_value(n_int_max, &val.v_ushrt));
473a792b843Sthorpej 
474a792b843Sthorpej 	/* int / unsigned int */
475a792b843Sthorpej 	ATF_REQUIRE(prop_number_int_value(n_ushrt_max, &val.v_int) &&
476a792b843Sthorpej 		    val.v_int == USHRT_MAX);
477a792b843Sthorpej 
478a792b843Sthorpej 	ATF_REQUIRE(prop_number_int_value(n_int_max, &val.v_int) &&
479a792b843Sthorpej 		    val.v_int == INT_MAX);
480a792b843Sthorpej 	ATF_REQUIRE(prop_number_int_value(n_int_min, &val.v_int) &&
481a792b843Sthorpej 		    val.v_int == INT_MIN);
482a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int_value(n_uint_max, &val.v_int));
483a792b843Sthorpej 
484a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint_value(n_int_max, &val.v_uint) &&
485a792b843Sthorpej 		    val.v_uint == INT_MAX);
486a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint_value(n_int_min, &val.v_uint));
487a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint_value(n_uint_max, &val.v_uint) &&
488a792b843Sthorpej 		    val.v_uint == UINT_MAX);
489a792b843Sthorpej 
490a792b843Sthorpej #ifdef _LP64
491a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int_value(n_long_min, &val.v_int));
492a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint_value(n_long_max, &val.v_uint));
493a792b843Sthorpej #else
494a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int_value(n_llong_min, &val.v_int));
495a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint_value(n_llong_max, &val.v_uint));
496a792b843Sthorpej #endif /* _LP64 */
497a792b843Sthorpej 
498a792b843Sthorpej 	/* long / unsigned long */
499a792b843Sthorpej #ifdef _LP64
500a792b843Sthorpej 	ATF_REQUIRE(prop_number_long_value(n_uint_max, &val.v_long) &&
501a792b843Sthorpej 		    val.v_long == UINT_MAX);
502a792b843Sthorpej #endif
503a792b843Sthorpej 
504a792b843Sthorpej 	ATF_REQUIRE(prop_number_long_value(n_long_max, &val.v_long) &&
505a792b843Sthorpej 		    val.v_long == LONG_MAX);
506a792b843Sthorpej 	ATF_REQUIRE(prop_number_long_value(n_long_min, &val.v_long) &&
507a792b843Sthorpej 		    val.v_long == LONG_MIN);
508a792b843Sthorpej 	ATF_REQUIRE(!prop_number_long_value(n_ulong_max, &val.v_long));
509a792b843Sthorpej 
510a792b843Sthorpej 	ATF_REQUIRE(prop_number_ulong_value(n_long_max, &val.v_ulong) &&
511a792b843Sthorpej 		    val.v_ulong == LONG_MAX);
512a792b843Sthorpej 	ATF_REQUIRE(!prop_number_ulong_value(n_long_min, &val.v_ulong));
513a792b843Sthorpej 	ATF_REQUIRE(prop_number_ulong_value(n_ulong_max, &val.v_ulong) &&
514a792b843Sthorpej 		    val.v_ulong == ULONG_MAX);
515a792b843Sthorpej 
516a792b843Sthorpej #ifndef _LP64
517a792b843Sthorpej 	ATF_REQUIRE(!prop_number_long_value(n_llong_min, &val.v_long));
518a792b843Sthorpej 	ATF_REQUIRE(!prop_number_ulong_value(n_llong_max, &val.v_ulong));
519a792b843Sthorpej #endif
520a792b843Sthorpej 
521a792b843Sthorpej 	/* intptr_t / uintptr_t */
522a792b843Sthorpej #ifdef _LP64
523a792b843Sthorpej 	ATF_REQUIRE(prop_number_intptr_value(n_uint_max, &val.v_intptr) &&
524a792b843Sthorpej 		    val.v_intptr == UINT_MAX);
525a792b843Sthorpej #endif
526a792b843Sthorpej 
527a792b843Sthorpej 	ATF_REQUIRE(prop_number_intptr_value(n_intptr_max, &val.v_intptr) &&
528a792b843Sthorpej 		    val.v_intptr == INTPTR_MAX);
529a792b843Sthorpej 	ATF_REQUIRE(prop_number_intptr_value(n_intptr_min, &val.v_intptr) &&
530a792b843Sthorpej 		    val.v_intptr == INTPTR_MIN);
531a792b843Sthorpej 	ATF_REQUIRE(!prop_number_intptr_value(n_uintptr_max, &val.v_intptr));
532a792b843Sthorpej 
533a792b843Sthorpej 	ATF_REQUIRE(prop_number_uintptr_value(n_intptr_max, &val.v_uintptr) &&
534a792b843Sthorpej 		    val.v_uintptr == INTPTR_MAX);
535a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uintptr_value(n_intptr_min, &val.v_uintptr));
536a792b843Sthorpej 	ATF_REQUIRE(prop_number_uintptr_value(n_uintptr_max, &val.v_uintptr) &&
537a792b843Sthorpej 		    val.v_uintptr == UINTPTR_MAX);
538a792b843Sthorpej 
539a792b843Sthorpej #ifndef _LP64
540a792b843Sthorpej 	ATF_REQUIRE(!prop_number_intptr_value(n_llong_min, &val.v_intptr));
541a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uintptr_value(n_llong_max, &val.v_uintptr));
542a792b843Sthorpej #endif
543a792b843Sthorpej 
544a792b843Sthorpej 	/* long long / unsigned long long */
545a792b843Sthorpej #ifdef _LP64
546a792b843Sthorpej 	ATF_REQUIRE(prop_number_longlong_value(n_uint_max, &val.v_llong) &&
547a792b843Sthorpej 		    val.v_llong == UINT_MAX);
548a792b843Sthorpej #else
549a792b843Sthorpej 	ATF_REQUIRE(prop_number_longlong_value(n_ulong_max, &val.v_llong) &&
550a792b843Sthorpej 		    val.v_llong == ULONG_MAX);
551a792b843Sthorpej #endif
552a792b843Sthorpej 
553a792b843Sthorpej 	ATF_REQUIRE(prop_number_longlong_value(n_llong_max, &val.v_llong) &&
554*492187eaSthorpej 		    val.v_llong == LLONG_MAX);
555a792b843Sthorpej 	ATF_REQUIRE(prop_number_longlong_value(n_llong_min, &val.v_llong) &&
556*492187eaSthorpej 		    val.v_llong == LLONG_MIN);
557a792b843Sthorpej 	ATF_REQUIRE(!prop_number_longlong_value(n_ullong_max, &val.v_llong));
558a792b843Sthorpej 
559a792b843Sthorpej 	ATF_REQUIRE(prop_number_ulonglong_value(n_llong_max, &val.v_ullong) &&
560*492187eaSthorpej 		    val.v_ullong == LLONG_MAX);
561a792b843Sthorpej 	ATF_REQUIRE(!prop_number_ulonglong_value(n_llong_min, &val.v_ullong));
562a792b843Sthorpej 	ATF_REQUIRE(prop_number_ulonglong_value(n_ullong_max, &val.v_ullong) &&
563*492187eaSthorpej 		    val.v_ullong == ULLONG_MAX);
564a792b843Sthorpej 
565a792b843Sthorpej 	/* int8_t / uint8_t */
566a792b843Sthorpej 	ATF_REQUIRE(prop_number_int8_value(n_int8_max, &val.v_int8) &&
567a792b843Sthorpej 		    val.v_int8 == INT8_MAX);
568a792b843Sthorpej 	ATF_REQUIRE(prop_number_int8_value(n_int8_min, &val.v_int8) &&
569a792b843Sthorpej 		    val.v_int8 == INT8_MIN);
570a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int8_value(n_uint8_max, &val.v_int8));
571a792b843Sthorpej 
572a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint8_value(n_int8_max, &val.v_uint8) &&
573a792b843Sthorpej 		    val.v_uint8 == INT8_MAX);
574a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint8_value(n_int8_min, &val.v_uint8));
575a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint8_value(n_uint8_max, &val.v_uint8) &&
576a792b843Sthorpej 		    val.v_uint8 == UINT8_MAX);
577a792b843Sthorpej 
578a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int8_value(n_int16_min, &val.v_int8));
579a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint8_value(n_int16_max, &val.v_uint8));
580a792b843Sthorpej 
581a792b843Sthorpej 	/* int16_t / uint16_t */
582a792b843Sthorpej 	ATF_REQUIRE(prop_number_int16_value(n_uint8_max, &val.v_int16) &&
583a792b843Sthorpej 		    val.v_int16 == UINT8_MAX);
584a792b843Sthorpej 
585a792b843Sthorpej 	ATF_REQUIRE(prop_number_int16_value(n_int16_max, &val.v_int16) &&
586a792b843Sthorpej 		    val.v_int16 == INT16_MAX);
587a792b843Sthorpej 	ATF_REQUIRE(prop_number_int16_value(n_int16_min, &val.v_int16) &&
588a792b843Sthorpej 		    val.v_int16 == INT16_MIN);
589a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int16_value(n_uint16_max, &val.v_int16));
590a792b843Sthorpej 
591a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint16_value(n_int16_max, &val.v_uint16) &&
592a792b843Sthorpej 		    val.v_uint16 == INT16_MAX);
593a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint16_value(n_int16_min, &val.v_uint16));
594a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint16_value(n_uint16_max, &val.v_uint16) &&
595a792b843Sthorpej 		    val.v_uint16 == UINT16_MAX);
596a792b843Sthorpej 
597a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int16_value(n_int32_min, &val.v_int16));
598a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint16_value(n_int32_max, &val.v_uint16));
599a792b843Sthorpej 
600a792b843Sthorpej 	/* int32_t / uint32_t */
601a792b843Sthorpej 	ATF_REQUIRE(prop_number_int32_value(n_uint16_max, &val.v_int32) &&
602a792b843Sthorpej 		    val.v_int32 == UINT16_MAX);
603a792b843Sthorpej 
604a792b843Sthorpej 	ATF_REQUIRE(prop_number_int32_value(n_int32_max, &val.v_int32) &&
605a792b843Sthorpej 		    val.v_int32 == INT32_MAX);
606a792b843Sthorpej 	ATF_REQUIRE(prop_number_int32_value(n_int32_min, &val.v_int32) &&
607a792b843Sthorpej 		    val.v_int32 == INT32_MIN);
608a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int32_value(n_uint32_max, &val.v_int32));
609a792b843Sthorpej 
610a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint32_value(n_int32_max, &val.v_uint32) &&
611a792b843Sthorpej 		    val.v_uint32 == INT32_MAX);
612a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint32_value(n_int32_min, &val.v_uint32));
613a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint32_value(n_uint32_max, &val.v_uint32) &&
614a792b843Sthorpej 		    val.v_uint32 == UINT32_MAX);
615a792b843Sthorpej 
616a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int32_value(n_int64_min, &val.v_int32));
617a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint32_value(n_int64_max, &val.v_uint32));
618a792b843Sthorpej 
619a792b843Sthorpej 	/* int64_t / uint64_t */
620a792b843Sthorpej 	ATF_REQUIRE(prop_number_int64_value(n_uint32_max, &val.v_int64) &&
621a792b843Sthorpej 		    val.v_int64 == UINT32_MAX);
622a792b843Sthorpej 
623a792b843Sthorpej 	ATF_REQUIRE(prop_number_int64_value(n_int64_max, &val.v_int64) &&
624a792b843Sthorpej 		    val.v_int64 == INT64_MAX);
625a792b843Sthorpej 	ATF_REQUIRE(prop_number_int64_value(n_int64_min, &val.v_int64) &&
626a792b843Sthorpej 		    val.v_int64 == INT64_MIN);
627a792b843Sthorpej 	ATF_REQUIRE(!prop_number_int64_value(n_uint64_max, &val.v_int64));
628a792b843Sthorpej 
629a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint64_value(n_int64_max, &val.v_uint64) &&
630a792b843Sthorpej 		    val.v_uint64 == INT64_MAX);
631a792b843Sthorpej 	ATF_REQUIRE(!prop_number_uint64_value(n_int64_min, &val.v_uint64));
632a792b843Sthorpej 	ATF_REQUIRE(prop_number_uint64_value(n_uint64_max, &val.v_uint64) &&
633a792b843Sthorpej 		    val.v_uint64 == UINT64_MAX);
634a792b843Sthorpej 
635a792b843Sthorpej 	prop_object_release(n_schar_max);
636a792b843Sthorpej 	prop_object_release(n_schar_min);
637a792b843Sthorpej 	prop_object_release(n_uchar_max);
638a792b843Sthorpej 
639a792b843Sthorpej 	prop_object_release(n_shrt_max);
640a792b843Sthorpej 	prop_object_release(n_shrt_min);
641a792b843Sthorpej 	prop_object_release(n_ushrt_max);
642a792b843Sthorpej 
643a792b843Sthorpej 	prop_object_release(n_int_max);
644a792b843Sthorpej 	prop_object_release(n_int_min);
645a792b843Sthorpej 	prop_object_release(n_uint_max);
646a792b843Sthorpej 
647a792b843Sthorpej 	prop_object_release(n_long_max);
648a792b843Sthorpej 	prop_object_release(n_long_min);
649a792b843Sthorpej 	prop_object_release(n_ulong_max);
650a792b843Sthorpej 
651a792b843Sthorpej 	prop_object_release(n_llong_max);
652a792b843Sthorpej 	prop_object_release(n_llong_min);
653a792b843Sthorpej 	prop_object_release(n_ullong_max);
654a792b843Sthorpej 
655a792b843Sthorpej 	prop_object_release(n_intptr_max);
656a792b843Sthorpej 	prop_object_release(n_intptr_min);
657a792b843Sthorpej 	prop_object_release(n_uintptr_max);
658a792b843Sthorpej 
659a792b843Sthorpej 	prop_object_release(n_int8_max);
660a792b843Sthorpej 	prop_object_release(n_int8_min);
661a792b843Sthorpej 	prop_object_release(n_uint8_max);
662a792b843Sthorpej 
663a792b843Sthorpej 	prop_object_release(n_int16_max);
664a792b843Sthorpej 	prop_object_release(n_int16_min);
665a792b843Sthorpej 	prop_object_release(n_uint16_max);
666a792b843Sthorpej 
667a792b843Sthorpej 	prop_object_release(n_int32_max);
668a792b843Sthorpej 	prop_object_release(n_int32_min);
669a792b843Sthorpej 	prop_object_release(n_uint32_max);
670a792b843Sthorpej 
671a792b843Sthorpej 	prop_object_release(n_int64_max);
672a792b843Sthorpej 	prop_object_release(n_int64_min);
673a792b843Sthorpej 	prop_object_release(n_uint64_max);
674a792b843Sthorpej }
675a792b843Sthorpej 
676a792b843Sthorpej ATF_TC(prop_string_basic);
ATF_TC_HEAD(prop_string_basic,tc)677a792b843Sthorpej ATF_TC_HEAD(prop_string_basic, tc)
678a792b843Sthorpej {
679a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "tests prop_string basics");
680a792b843Sthorpej }
ATF_TC_BODY(prop_string_basic,tc)681a792b843Sthorpej ATF_TC_BODY(prop_string_basic, tc)
682a792b843Sthorpej {
683a792b843Sthorpej 	prop_string_t s1, s2, s3;
684a792b843Sthorpej 	prop_number_t num;
685a792b843Sthorpej 	char buf[sizeof(const_string1)];
686a792b843Sthorpej 
687a792b843Sthorpej 	/*
688a792b843Sthorpej 	 * This test exercises implementation details, not only
689a792b843Sthorpej 	 * API contract.
690a792b843Sthorpej 	 */
691a792b843Sthorpej 
692a792b843Sthorpej 	s1 = prop_string_create_nocopy(const_string1);
693a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
694a792b843Sthorpej 	s2 = prop_string_create_copy(const_string1);
695a792b843Sthorpej 	ATF_REQUIRE(s2 != NULL);
696a792b843Sthorpej 	ATF_REQUIRE(s2 == s1);
697a792b843Sthorpej 	ATF_REQUIRE(prop_string_value(s1) == const_string1);
698a792b843Sthorpej 	prop_object_release(s1);
699a792b843Sthorpej 	prop_object_release(s2);
700a792b843Sthorpej 
701a792b843Sthorpej 	s1 = prop_string_create_copy(const_string1);
702a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
703a792b843Sthorpej 	s2 = prop_string_create_nocopy(const_string1);
704a792b843Sthorpej 	ATF_REQUIRE(s2 != NULL);
705a792b843Sthorpej 	ATF_REQUIRE(s2 == s1);
706a792b843Sthorpej 	ATF_REQUIRE(prop_string_value(s1) != const_string1);
707a792b843Sthorpej 	prop_object_release(s1);
708a792b843Sthorpej 	prop_object_release(s2);
709a792b843Sthorpej 
710a792b843Sthorpej 	s1 = prop_string_create_format("%d-%d", 12345, 67890);
711a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
712a792b843Sthorpej 	ATF_REQUIRE(strcmp(prop_string_value(s1), "12345-67890") == 0);
713a792b843Sthorpej 	ATF_REQUIRE(prop_string_equals_string(s1, "12345-67890"));
714a792b843Sthorpej 	prop_object_release(s1);
715a792b843Sthorpej 
716a792b843Sthorpej 	s1 = prop_string_create_nocopy(const_string1);
717a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
718a792b843Sthorpej 	s2 = prop_string_create_nocopy(const_string2);
719a792b843Sthorpej 	ATF_REQUIRE(s2 != NULL);
720a792b843Sthorpej 	ATF_REQUIRE(prop_string_size(s1) == strlen(const_string1));
721a792b843Sthorpej 	ATF_REQUIRE(prop_string_size(s2) == strlen(const_string2));
722a792b843Sthorpej 	ATF_REQUIRE(prop_string_copy_value(s1, buf, sizeof(buf)));
723a792b843Sthorpej 	ATF_REQUIRE(!prop_string_copy_value(s2, buf, sizeof(buf)));
724a792b843Sthorpej 	prop_object_release(s1);
725a792b843Sthorpej 	prop_object_release(s2);
726a792b843Sthorpej 
727a792b843Sthorpej 	s1 = prop_string_create_copy("a");
728a792b843Sthorpej 	ATF_REQUIRE(s1 != NULL);
729a792b843Sthorpej 	s2 = prop_string_create_copy("b");
730a792b843Sthorpej 	ATF_REQUIRE(s2 != NULL);
731a792b843Sthorpej 	s3 = prop_string_copy(s2);
732a792b843Sthorpej 	ATF_REQUIRE(s3 != NULL);
733a792b843Sthorpej 	ATF_REQUIRE(s3 == s2);
734a792b843Sthorpej 	num = prop_number_create_signed(666);
735a792b843Sthorpej 	ATF_REQUIRE(num != NULL);
736a792b843Sthorpej 	ATF_REQUIRE(!prop_string_equals(s1, s2));
737a792b843Sthorpej 	ATF_REQUIRE(prop_string_equals(s2, s3));
738a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare(s1, s2) < 0);
739a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare(s2, s1) > 0);
740a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare(s2, s3) == 0);
741a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare_string(s1, "b") < 0);
742a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare_string(s2, "a") > 0);
743a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare_string(s3, "b") == 0);
744a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare(s1, (prop_string_t)num) != 0);
745a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare((prop_string_t)num, s1) != 0);
746a792b843Sthorpej 	ATF_REQUIRE(prop_string_compare_string((prop_string_t)num, "666") != 0);
747a792b843Sthorpej 	prop_object_release(s1);
748a792b843Sthorpej 	prop_object_release(s2);
749a792b843Sthorpej 	prop_object_release(s3);
750a792b843Sthorpej 	prop_object_release(num);
751a792b843Sthorpej }
752a792b843Sthorpej 
753a792b843Sthorpej ATF_TC(prop_dict_util);
ATF_TC_HEAD(prop_dict_util,tc)754a792b843Sthorpej ATF_TC_HEAD(prop_dict_util, tc)
755a792b843Sthorpej {
756a792b843Sthorpej 	atf_tc_set_md_var(tc, "descr", "tests prop_dictionary_util basics");
757a792b843Sthorpej }
ATF_TC_BODY(prop_dict_util,tc)758a792b843Sthorpej ATF_TC_BODY(prop_dict_util, tc)
759a792b843Sthorpej {
760a792b843Sthorpej 	union {
761a792b843Sthorpej 		signed char v_schar;
762a792b843Sthorpej 		short v_shrt;
763a792b843Sthorpej 		int v_int;
764a792b843Sthorpej 		long v_long;
765a792b843Sthorpej 		long long v_llong;
766a792b843Sthorpej 		intptr_t v_intptr;
767a792b843Sthorpej 		int8_t v_int8;
768a792b843Sthorpej 		int16_t v_int16;
769a792b843Sthorpej 		int32_t v_int32;
770a792b843Sthorpej 		int64_t v_int64;
771a792b843Sthorpej 
772a792b843Sthorpej 		unsigned char v_uchar;
773a792b843Sthorpej 		unsigned short v_ushrt;
774a792b843Sthorpej 		unsigned int v_uint;
775a792b843Sthorpej 		unsigned long v_ulong;
776a792b843Sthorpej 		unsigned long long v_ullong;
777a792b843Sthorpej 		uintptr_t v_uintptr;
778a792b843Sthorpej 		uint8_t v_uint8;
779a792b843Sthorpej 		uint16_t v_uint16;
780a792b843Sthorpej 		uint32_t v_uint32;
781a792b843Sthorpej 		uint64_t v_uint64;
782a792b843Sthorpej 	} val;
783a792b843Sthorpej 	prop_dictionary_t dict;
784a792b843Sthorpej 	const char *cp;
785a792b843Sthorpej 	const void *v;
786a792b843Sthorpej 	size_t size;
787a792b843Sthorpej 
788a792b843Sthorpej 	dict = prop_dictionary_create();
789a792b843Sthorpej 	ATF_REQUIRE(dict != NULL);
790a792b843Sthorpej 
791a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_schar(dict, "schar", SCHAR_MIN));
792a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_schar(dict, "schar", &val.v_schar));
793a792b843Sthorpej 	ATF_REQUIRE(val.v_schar == SCHAR_MIN);
794a792b843Sthorpej 
795a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_short(dict, "shrt", SHRT_MIN));
796a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_short(dict, "shrt", &val.v_shrt));
797a792b843Sthorpej 	ATF_REQUIRE(val.v_shrt == SHRT_MIN);
798a792b843Sthorpej 
799a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_int(dict, "int", INT_MIN));
800a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_int(dict, "int", &val.v_int));
801a792b843Sthorpej 	ATF_REQUIRE(val.v_int == INT_MIN);
802a792b843Sthorpej 
803a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_long(dict, "long", LONG_MIN));
804a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_long(dict, "long", &val.v_long));
805a792b843Sthorpej 	ATF_REQUIRE(val.v_long == LONG_MIN);
806a792b843Sthorpej 
807a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_longlong(dict, "longlong", LLONG_MIN));
808a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_longlong(dict, "longlong",
809a792b843Sthorpej 						 &val.v_llong));
810a792b843Sthorpej 	ATF_REQUIRE(val.v_llong == LLONG_MIN);
811a792b843Sthorpej 
812a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_intptr(dict, "intptr", INTPTR_MIN));
813a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_intptr(dict, "intptr", &val.v_intptr));
814a792b843Sthorpej 	ATF_REQUIRE(val.v_intptr == INTPTR_MIN);
815a792b843Sthorpej 
816a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_int8(dict, "int8", INT8_MIN));
817a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_int8(dict, "int8", &val.v_int8));
818a792b843Sthorpej 	ATF_REQUIRE(val.v_int8 == INT8_MIN);
819a792b843Sthorpej 
820a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_int16(dict, "int16", INT16_MIN));
821a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_int16(dict, "int16", &val.v_int16));
822a792b843Sthorpej 	ATF_REQUIRE(val.v_int16 == INT16_MIN);
823a792b843Sthorpej 
824a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_int32(dict, "int32", INT32_MIN));
825a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_int32(dict, "int32", &val.v_int32));
826a792b843Sthorpej 	ATF_REQUIRE(val.v_int32 == INT32_MIN);
827a792b843Sthorpej 
828a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_int64(dict, "int64", INT64_MIN));
829a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_int64(dict, "int64", &val.v_int64));
830a792b843Sthorpej 	ATF_REQUIRE(val.v_int64 == INT64_MIN);
831a792b843Sthorpej 
832a792b843Sthorpej 
833a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uchar(dict, "uchar", UCHAR_MAX));
834a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uchar(dict, "uchar", &val.v_uchar));
835a792b843Sthorpej 	ATF_REQUIRE(val.v_uchar == UCHAR_MAX);
836a792b843Sthorpej 
837a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_ushort(dict, "ushrt", USHRT_MAX));
838a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_ushort(dict, "ushrt", &val.v_ushrt));
839a792b843Sthorpej 	ATF_REQUIRE(val.v_ushrt == USHRT_MAX);
840a792b843Sthorpej 
841a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uint(dict, "uint", UINT_MAX));
842a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uint(dict, "uint", &val.v_uint));
843a792b843Sthorpej 	ATF_REQUIRE(val.v_uint == UINT_MAX);
844a792b843Sthorpej 
845a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_ulong(dict, "ulong", ULONG_MAX));
846a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_ulong(dict, "ulong", &val.v_ulong));
847a792b843Sthorpej 	ATF_REQUIRE(val.v_ulong == ULONG_MAX);
848a792b843Sthorpej 
849a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_ulonglong(dict, "ulonglong",
850a792b843Sthorpej 						  ULLONG_MAX));
851a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_ulonglong(dict, "ulonglong",
852a792b843Sthorpej 						  &val.v_ullong));
853a792b843Sthorpej 	ATF_REQUIRE(val.v_ullong == ULLONG_MAX);
854a792b843Sthorpej 
855a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uintptr(dict, "uintptr", UINTPTR_MAX));
856a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uintptr(dict, "uintptr",
857a792b843Sthorpej 						&val.v_uintptr));
858a792b843Sthorpej 	ATF_REQUIRE(val.v_uintptr == UINTPTR_MAX);
859a792b843Sthorpej 
860a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uint8(dict, "uint8", UINT8_MAX));
861a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uint8(dict, "uint8", &val.v_uint8));
862a792b843Sthorpej 	ATF_REQUIRE(val.v_uint8 == UINT8_MAX);
863a792b843Sthorpej 
864a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uint16(dict, "uint16", UINT16_MAX));
865a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uint16(dict, "uint16", &val.v_uint16));
866a792b843Sthorpej 	ATF_REQUIRE(val.v_uint16 == UINT16_MAX);
867a792b843Sthorpej 
868a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uint32(dict, "uint32", UINT32_MAX));
869a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uint32(dict, "uint32", &val.v_uint32));
870a792b843Sthorpej 	ATF_REQUIRE(val.v_uint32 == UINT32_MAX);
871a792b843Sthorpej 
872a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_uint64(dict, "uint64", UINT64_MAX));
873a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_uint64(dict, "uint64", &val.v_uint64));
874a792b843Sthorpej 	ATF_REQUIRE(val.v_uint64 == UINT64_MAX);
875a792b843Sthorpej 
876a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_string_nocopy(dict, "string",
877a792b843Sthorpej 						      const_string1));
878a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_string(dict, "string", &cp));
879a792b843Sthorpej 	ATF_REQUIRE(cp == const_string1);
880a792b843Sthorpej 	prop_dictionary_remove(dict, "string");
881a792b843Sthorpej 
882a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_string(dict, "string", const_string1));
883a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_string(dict, "string", &cp));
884a792b843Sthorpej 	ATF_REQUIRE(cp != const_string1);
885a792b843Sthorpej 	ATF_REQUIRE(strcmp(cp, const_string1) == 0);
886a792b843Sthorpej 
887a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_data_nocopy(dict, "data",
888a792b843Sthorpej 						    const_data1,
889a792b843Sthorpej 						    sizeof(const_data1)));
890a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_data(dict, "data", &v, NULL));
891a792b843Sthorpej 	ATF_REQUIRE(v == const_data1);
892a792b843Sthorpej 	prop_dictionary_remove(dict, "data");
893a792b843Sthorpej 
894a792b843Sthorpej 	size = 0xdeadbeef;
895a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_set_data(dict, "data", const_data1,
896a792b843Sthorpej 					     sizeof(const_data1)));
897a792b843Sthorpej 	ATF_REQUIRE(prop_dictionary_get_data(dict, "data", &v, &size));
898a792b843Sthorpej 	ATF_REQUIRE(v != const_data1);
899a792b843Sthorpej 	ATF_REQUIRE(size == sizeof(const_data1));
900a792b843Sthorpej 	ATF_REQUIRE(memcmp(v, const_data1, size) == 0);
901a792b843Sthorpej 
902a792b843Sthorpej 	prop_object_release(dict);
903a792b843Sthorpej }
904a792b843Sthorpej 
ATF_TP_ADD_TCS(tp)905a792b843Sthorpej ATF_TP_ADD_TCS(tp)
906a792b843Sthorpej {
907a792b843Sthorpej 
908a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_basic);
909a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_dictionary_equals);
910a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_dict_util);
911a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_data_basic);
912a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_number_basic);
913a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_number_range_check);
914a792b843Sthorpej 	ATF_TP_ADD_TC(tp, prop_string_basic);
915a792b843Sthorpej 
916a792b843Sthorpej 	return atf_no_error();
917a792b843Sthorpej }
918