1#!@SH_PROG@ 2# -*- shell-script -*- 3 4test_parse_list_args() 5{ 6 # Set up necessary vars 7 _Dbg_frame_last_filename='testing' 8 typeset -i _Dbg_frame_last_lineno 9 typeset -i _Dbg_set_listsize 10 _Dbg_set_listsize=12 11 typeset -i _Dbg_frame_last_lineno 12 _Dbg_frame_last_lineno=3 13 14 # Return vars 15 typeset filename 16 typeset end_line 17 18 # Some error conditions 19 _Dbg_parse_list_args 20 assertEquals 1 $? 21 _Dbg_parse_list_args "foo" 22 assertEquals 1 $? 23 24 25 # Try a simple parse 26 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" 27 assertEquals "$_Dbg_frame_last_filename" "$filename" 28 assertEquals 1 "$_Dbg_listline" 29 assertEquals 12 "$end_line" 30 31 # Try with a line number 32 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" 15 33 assertEquals "$_Dbg_frame_last_filename" "$filename" 34 assertEquals 9 "$_Dbg_listline" 35 assertEquals $((9+_Dbg_set_listsize-1)) "$end_line" 36 37 # Try with a line number and count 38 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" 20 3 39 assertEquals "$_Dbg_frame_last_filename" "$filename" 40 assertEquals 19 "$_Dbg_listline" 41 assertEquals $((19+3-1)) "$end_line" 42 43 # Try with start and end line number 44 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" 10+20 35 45 assertEquals "$_Dbg_frame_last_filename" "$filename" 46 assertEquals 30 "$_Dbg_listline" 47 assertEquals 35 "$end_line" 48 49 # Try with . and end line number 50 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" '.' 51 assertEquals 1 "$_Dbg_listline" 52 assertEquals 12 "$end_line" 53 54 # Try with line numbers from the end 55 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" -5 56 assertEquals 90 "$_Dbg_listline" 57 58 _Dbg_parse_list_args 0 100 "$_Dbg_frame_last_filename" 5 -5 59 assertEquals 96 "$end_line" 60 61 # Try with centered line numbers 62 _Dbg_parse_list_args 1 100 "$_Dbg_frame_last_filename" 10 63 assertEquals $((10-6)) "$_Dbg_listline" 64} 65 66abs_top_srcdir=@abs_top_srcdir@ 67# Make sure $abs_top_srcdir has a trailing slash 68abs_top_srcdir=${abs_top_srcdir%%/}/ 69. ${abs_top_srcdir}test/unit/helper.sh 70. $abs_top_srcdir/lib/list.sh 71set -- # reset $# so shunit2 doesn't get confused. 72 73[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file} 74