#!/bin/sh -efu

export LANG=C
export LANGUAGE=C
export LC_ALL=C

srcdir="$(readlink -ev ..)"
export PATH="$srcdir:$PATH"

unittest_use_color=1
unittest_hide_successful=1

[ -z "${VERBOSE:-${V:-}}" ] ||
	unittest_hide_successful=

. ../shell-unittest

WORKDIR=
setUpTests() {
	WORKDIR="$(mktemp -d "$PROG.XXXXXXXXX")"
}

tearDownTests() {
	rm -rf -- "$WORKDIR"
}

for s in \
	performance-check-string \
	performance-check-trim \
	performance-check-ip-address \
	quote_sed_regexp quote_shell quote_grep_regexp string_quote_remove \
	opt_check_dir opt_check_number opt_check_read \
	quote_sed_regexp_variable quote_shell_variable quote_grep_regexp_variable \
	getopt getsubopt getopts signal \
	fatal message verbose \
	quote_shell_args \
	ini_config_get ini_config_set ini_config_del ini_config_comment \
	git_config_foreach git_config_get git_config_count git_config_list git_config_set git_config_unset git_config_append \
	shell_var_unquote shell_var_trim \
	fill_mask \
	ip_address ip_address_mask \
	cmdline_foreach \
	cmdline_get \
	run_scripts \
	terminfo_init color_message color_text \
	create_temporary \
	json \
	integer_to_binary get_bit set_bit clear_bit toggle_bits \
	shell_config_get shell_config_set shell_config_del shell_config_comment \
	shell_array_append shell_array_set shell_array_get shell_array_pop shell_array_unset \
	;
do
	[ -z "${TEST-}" -o "${TEST-}" = "$s" ] ||
		continue
	. "./$s"
	registerTests "./$s"
done

runUnitTests
