File: usrdef_two.sh

package info (click to toggle)
liblognorm 2.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,696 kB
  • sloc: ansic: 11,634; sh: 2,639; makefile: 255; python: 34
file content (19 lines) | stat: -rwxr-xr-x 640 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# added 2015-10-30 by Rainer Gerhards
# This file is part of the liblognorm project, released under ASL 2.0

. $srcdir/exec.sh

test_def $0 "user-defined type with two alternatives"
add_rule 'version=2'
add_rule 'type=@hex-byte:%f1:hexnumber{"maxval": "255"}%'
add_rule 'type=@hex-byte:%f1:word%'
add_rule 'rule=:a word %w1:word% a byte %   .:@hex-byte   % another word %w2:word%'

execute 'a word w1 a byte 0xff another word w2'
assert_output_json_eq '{ "w2": "w2", "f1": "0xff", "w1": "w1" }'

execute 'a word w1 a byte TEST another word w2'
assert_output_json_eq '{ "w2": "w2", "f1": "TEST", "w1": "w1" }'

cleanup_tmp_files