xref: /illumos-gate/usr/src/test/util-tests/tests/libnvpair_json/json_01_boolean.ksh (revision 37e2cd25d56b334a2403f2540a0b0a1e6a40bcd1)
1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2014, Joyent, Inc.
15#
16
17DIR=$(dirname $(whence $0))
18. ${DIR}/json_common
19
20BASELINE="$(cat <<EOF
21{\
22"bool0":true,\
23"a fact":true,\
24"a fiction":false,\
25"1":true,\
26" ":true\
27}
28EOF)"
29
30OUTPUT="$(${DIR}/../../bin/print_json <<'EOF'
31/*
32 * add_boolean calls nvlist_add_boolean(), which the JSON formatter
33 * will emit as a true-valued boolean.
34 */
35add_boolean "bool0";
36add_boolean_value "a fact" "true";
37add_boolean_value "a fiction" "false";
38add_boolean "1";
39
40/*
41 * Test a key with a whitespace-only name:
42 */
43add_boolean " ";
44EOF)"
45
46complete
47