#!/bin/ash -efu

quote_sed_regexp_test1() { # UnitTest
	. ../shell-quote
	local string='.*'
	local regexp="$(quote_sed_regexp "$string")"
	local result="$(printf '%s\n' "$string passed" |sed -e "s/^$regexp/test/")"
	assertEquals "$string" "$result" 'test passed'
}

quote_sed_regexp_test2() { # UnitTest
	. ../shell-quote
	local string='[[:space:]]'
	local regexp="$(quote_sed_regexp "$string")"
	local result="$(printf '%s\n' "test $string" |sed -e "s/$regexp/passed/")"
	assertEquals "$string" "$result" 'test passed'
}

quote_sed_regexp_test3() { # UnitTest
	. ../shell-quote
	local string='t{1,3}'
	local regexp="$(quote_sed_regexp "$string")"
	local result="$(printf '%s\n' "test$string passed" |sed -e "s/$regexp//")"
	assertEquals "$string" "$result" 'test passed'
}

quote_sed_regexp_test4() { # UnitTest
	. ../shell-quote
	local string='&\1'
	local regexp="$(quote_sed_regexp "$string")"
	local result="$(printf '%s\n' "test not passed" |sed -e "s/\(not\)/$regexp/")" #"
	assertEquals "$string" "$result" 'test &\1 passed'
}
