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 
  17 DIR=$(dirname $(whence $0))
  18 . ${DIR}/json_common
  19 
  20 BASELINE="$(cat <<EOF
  21 {\
  22 "event_store":{\
  23 "name":"Occurences",\
  24 "events":[\
  25 {"time":489715200,"desc":"inception"},\
  26 {"time":1057708800,"desc":"maturation"},\
  27 {"time":1344816000,"desc":"migration"},\
  28 {"time":1405296000,"desc":"integration"},\
  29 {}\
  30 ]\
  31 },\
  32 "first level":[\
  33 {"second_level_0":[{\
  34 "sl0_a":true,\
  35 "sl0_b":"aaaa"\
  36 },\
  37 {"x":1234}\
  38 ],\
  39 "second_level_1":[{}],\
  40 "second_level_2":[\
  41 {"alpha":"a"},\
  42 {"beta":"b"},\
  43 {"gamma":"c"},\
  44 {"delta":"d"},\
  45 {"order":["a","b","c","d"]}\
  46 ]\
  47 }\
  48 ]\
  49 }
  50 EOF)"
  51 
  52 OUTPUT="$(${DIR}/../../bin/print_json <<'EOF'
  53 add_object "event_store";
  54         add_string "name" "Occurences";
  55         add_object_array "events";
  56                 add_uint32 "time" "489715200";
  57                 add_string "desc" "inception";
  58                 next;
  59 
  60                 add_uint32 "time" "1057708800";
  61                 add_string "desc" "maturation";
  62                 next;
  63 
  64                 add_uint32 "time" "1344816000";
  65                 add_string "desc" "migration";
  66                 next;
  67 
  68                 add_uint32 "time" "1405296000";
  69                 add_string "desc" "integration";
  70                 next;
  71         end;
  72 end;
  73 add_object_array "first level";
  74         add_object_array "second_level_0";
  75                 add_boolean "sl0_a";
  76                 add_string "sl0_b" "aaaa";
  77                 next;
  78                 add_int32 "x" "1234";
  79         end;
  80         add_object_array "second_level_1";
  81         end;
  82         add_object_array "second_level_2";
  83                 add_string "alpha" "a";
  84                 next;
  85                 add_string "beta" "b";
  86                 next;
  87                 add_string "gamma" "c";
  88                 next;
  89                 add_string "delta" "d";
  90                 next;
  91                 add_string_array "order" "a" "b" "c" "d";
  92         end;
  93 end;
  94 EOF)"
  95 
  96 complete