Skip to content

Instantly share code, notes, and snippets.

@voronkovich
Created March 10, 2019 17:48
Show Gist options
  • Save voronkovich/15e779e665ebe5a1a3cc44fb42b6dc57 to your computer and use it in GitHub Desktop.
Save voronkovich/15e779e665ebe5a1a3cc44fb42b6dc57 to your computer and use it in GitHub Desktop.
#!/bin/sh
binary="${1:-./a.out}";
test() {
input="$1";
expected="$2";
actual="$(echo $input | $binary)";
if [ "$expected" = "$actual" ]; then
echo "\e[032mOK\e[0m";
return;
fi
echo "\n\e[31mFail!\e[0m";
echo "\e[33mInput\e[0m:\n";
echo "$input\n";
echo "\e[032mExpected\e[0m: $expected";
echo "\e[032mActual\e[0m: $actual";
}
test \
"4 59\nfGRR\nfGRRefGRRtfGRRuCfGRRXfGRRQfGRRpfGRRxofGRRwfGRRQQfGRRgfGRRqR" \
"0 5 10 16 21 26 31 37 42 48 53 ";
test \
"4 12\ntest\ntestestteste" \
"0 3 7 ";
test \
"1 1\na\nb" \
"";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment