xref: /titanic_52/usr/src/test/util-tests/tests/libnvpair_json/json_02_numbers.ksh (revision 37c79205ad46187f54b2edbf6a468160935f14d9)
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"byte":255,\
23"uint8_0":0,\
24"uint8_100":100,\
25"uint8_255":255,\
26"uint16":12345,\
27"uint32":23423423,\
28"uint64":19850709000000,\
29"int16_small":-32768,\
30"int8_neg":-128,\
31"int8_pos":127,\
32"int16_big":32767,\
33"int32":-1270000,\
34"int64":-12700000000001,\
35"double_small":0.000023,\
36"double_big":2342300000000.000000\
37}
38EOF)"
39
40OUTPUT="$(${DIR}/../../bin/print_json <<'EOF'
41add_byte "byte" "0";
42add_byte "byte" "255";
43
44add_uint8 "uint8_0" "0";
45add_uint8 "uint8_100" "100";
46add_uint8 "uint8_255" "255";
47
48add_uint16 "uint16" "12345";
49add_uint32 "uint32" "23423423";
50add_uint64 "uint64" "19850709000000";
51
52add_int16 "int16_small" "-32768";
53add_int8 "int8_neg" "-128";
54add_int8 "int8_pos" "127";
55add_int16 "int16_big" "32767";
56
57add_int32 "int32" "-1270000";
58add_int64 "int64" "-12700000000001";
59
60add_double "double_small" "0.000023423";
61add_double "double_big" "0.000023423e17";
62EOF)"
63
64complete
65