set dshbak "$srcdir/../scripts/dshbak"

expect_after {
	timeout				{ unresolved "$test" }
	eof				{ unresolved "$test" }
}

set test "dshbak: -c does not coalesce different length output (gnats:36)"
spawn $dshbak -c
send "foo1: bar\n"
send "foo2: bar\n"
send "foo1: baz\n"
send \004
expect {
	-re "foo\\\[1-2\\\]"		{ fail "$test" }
	eof	 			{ pass "$test" }
}

set test "dshbak: -c properly compresses multi-digit hostname suffixes"
spawn $dshbak -c
send "foo8: bar\n"
send "foo9: bar\n"
send "foo10: bar\n"
send "foo11: bar\n"
send \004
expect {
	-re "foo\\\[8-11\\\]"		{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "dshbak: -c properly compresses prefix with embedded numerals"
spawn $dshbak -c
send "foo1x8: bar\n"
send "foo1x9: bar\n"
send "foo1x10: bar\n"
send "foo1x11: bar\n"
send \004
expect {
	-re "foo1x\\\[8-11\\\]"		{ pass "$test" }
	eof	 			{ fail "$test" }
}

set test "dshbak: -c does not strip leading zeros"
spawn $dshbak -c
send "foo00: bar\n"
send "foo03: bar\n"
send "foo01: bar\n"
send "foo02: bar\n"
send \004
expect {
	-re "foo\\\[00-03\\\]"		{ pass "$test" }
	eof	 			{ fail "$test" }
}
