#
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
#
#
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
#
print "TEST STARTING ${1}: ${2}"
}
print "TEST PASS: ${1}"
}
print "TEST FAIL: ${1}: ${2}"
exit -1
}
if [[ $? -ne 0 ]]; then
test_fail $1 "exit failure"
fi
}
if [[ "$2" != "$3" ]]; then
test_fail $1 "compare mismatch, got [$2] expected [$3]"
fi
}
t=test1
test_start $t "-I handling"
checkrv $t
good='** foo bar baz other **'
test_pass $t
}
t=test2
test_start $t "-n 1 handling"
checkrv $t
good='*** foo
*** bar
*** baz
*** other'
test_pass $t
}
t=test3
test_start $t "-I before -n 1"
checkrv $t
good='** THING ** foo
** THING ** bar
** THING ** baz
** THING ** other'
test_pass $t
}
t=test4
test_start $t "-n 1 before -I"
checkrv $t
good='** foo bar baz other **'
test_pass $t
}
t=test5
test_start $t "-i multiple lines handling"
checkrv $t
good='[abc def]
[xyz]
[123]'
test_pass $t
}
t=test6
test_start $t "-E handling"
checkrv $t
good='abc'
test_pass $t
}
t=test7
test_start $t "newlines in arguments"
checkrv $t
good='abc def xyz 123 456 789'
test_pass $t
}
t=test8
test_start $t "limited counts via -n3"
checkrv $t
good='** abc def ghi
** jkl mno 123
** 456 789'
test_pass $t
}
t=test9
test_start $t "multiple lines via -L2"
checkrv $t
good='** abc def 123 456
** peterpiper'
test_pass $t
}
t=test10
test_start $t "argument sizes"
checkrv $t
good='abc def
123 456
peter
alpha'
test_pass $t
}
t=test11
test_start $t "bare -e"
checkrv $t
good='** abc def _ end of string'
test_pass $t
}
t=test12
test_start $t "-E ''"
checkrv $t
good='** abc def _ end of string'
test_pass $t
}
t=test13
test_start $t "end of string (no -E or -e)"
checkrv $t
good='** abc def'
test_pass $t
}
t=test14
test_start $t "trailing blank with -L"
checkrv $t
good='** abc def 123 456 peter
** bogus'
test_pass $t
}
t=test15
test_start $t "leading and embedded blanks with -i"
checkrv $t
good='** abc def
** xyz bogus
** next'
test_pass $t
}
t=test16
test_start $t "single character replstring"
checkrv $t
good='** foo bar baz other **'
test_pass $t
}
t=test17
test_start $t "null byte separators"
checkrv $t
good='** foo bar baz
** more data'
test_pass $t
}
t=test18
test_start $t "escape characters"
checkrv $t
good='** foo bar
** second arg
** third'
test_pass $t
}