Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- . /usr/share/bsdconfig/strings.subr || exit
- N=1
- EXIT=${SUCCESS:-0}
- HR="--------------------"
- VERBOSE=
- hrprint() { printf "%s #%03u %s\n" "$HR" "$N" "$HR"; }
- hr() { [ "$VERBOSE" ] && hrprint; }
- xt()
- {
- local testvalue="$1"
- shift 2 # testvalue ==
- hr
- f_snprintf result "$@"
- if [ "$result" = "$testvalue" ]; then
- [ "$VERBOSE" ] && echo f_snprintf "$@" == "$result"
- else
- [ "$VERBOSE" ] || hrprint
- echo f_snprintf "$@" == "$result [bad; expected $testvalue]"
- EXIT=${FAILURE:-1}
- fi
- N=$(( $N + 1 ))
- }
- : 001 ; xt "" == 0 "abc123"
- : 002 ; xt "a" == 1 "abc123"
- : 003 ; xt "ab" == 2 "abc123"
- : 004 ; xt "abc" == 3 "abc123"
- : 005 ; xt "abc1" == 4 "abc123"
- : 006 ; xt "abc12" == 5 "abc123"
- : 007 ; xt "abc123" == 6 "abc123"
- : 008 ; xt "abc123" == 7 "abc123"
- : 009 ; xt "" == 9 ""
- : 010 ; xt "a" == 1 "abc123def456"
- : 011 ; xt "ab" == 2 "abc123def456"
- : 012 ; xt "abc" == 3 "abc123def456"
- : 013 ; xt "abc1" == 4 "abc123def456"
- : 014 ; xt "abc12" == 5 "abc123def456"
- : 015 ; xt "abc123" == 6 "abc123def456"
- : 016 ; xt "abc123d" == 7 "abc123def456"
- : 017 ; xt "abc123de" == 8 "abc123def456"
- : 018 ; xt "abc123def" == 9 "abc123def456"
- : 019 ; xt "abc123def4" == 10 "abc123def456"
- : 020 ; xt "abc123def45" == 11 "abc123def456"
- : 021 ; xt "abc123def456" == 12 "abc123def456"
- : 022 ; xt "abc123def456" == 13 "abc123def456"
- : 023 ; xt "abc123def456" == 1025 "abc123def456"
- : 024 ; xt "abc12" == 5 "abc123def456ghi789jkl0./"
- : 025 ; xt "abc123d" == 7 "abc123def456ghi789jkl0./"
- : 026 ; xt "abc123def" == 9 "abc123def456ghi789jkl0./"
- : 027 ; xt "abc123def4" == 10 "abc123def456ghi789jkl0./"
- : 028 ; xt "abc123def45" == 11 "abc123def456ghi789jkl0./"
- : 029 ; xt "abc123def456" == 12 "abc123def456ghi789jkl0./"
- : 030 ; xt "abc123def456g" == 13 "abc123def456ghi789jkl0./"
- : 031 ; xt "abc123def456gh" == 14 "abc123def456ghi789jkl0./"
- : 032 ; xt "abc123def456ghi" == 15 "abc123def456ghi789jkl0./"
- : 033 ; xt "abc123def456ghi7" == 16 "abc123def456ghi789jkl0./"
- : 034 ; xt "abc123def456ghi78" == 17 "abc123def456ghi789jkl0./"
- : 035 ; xt "abc123def456ghi789" == 18 "abc123def456ghi789jkl0./"
- : 036 ; xt "abc123def456ghi789j" == 19 "abc123def456ghi789jkl0./"
- : 037 ; xt "abc123def456ghi789jk" == 20 "abc123def456ghi789jkl0./"
- : 038 ; xt "abc123def456ghi789jkl" == 21 "abc123def456ghi789jkl0./"
- : 039 ; xt "abc123def456ghi789jkl0" == 22 "abc123def456ghi789jkl0./"
- : 040 ; xt "abc123def456ghi789jkl0." == 23 "abc123def456ghi789jkl0./"
- : 041 ; xt "abc123def456ghi789jkl0./" == 24 "abc123def456ghi789jkl0./"
- : 042 ; xt "abc123def456ghi789jkl0./" == 25 "abc123def456ghi789jkl0./"
- exit $EXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement