diff --git a/implement-shell-tools/cat/check.sh b/implement-shell-tools/cat/check.sh new file mode 100755 index 000000000..ec8b0a64a --- /dev/null +++ b/implement-shell-tools/cat/check.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +user_command=(${USER_COMMAND:-"node cat.js"}) + +function test() { + args=${@} + echo "======" + echo "Testing cat ${args}" + echo "=======" + diff -y <(cat ${args[@]}) <(${user_command[@]} ${args[@]}) + echo "" + echo "" +} + +test 'sample-files/1.txt' +test '-n' 'sample-files/1.txt' +test 'sample-files/*.txt' +test '-n' 'sample-files/*.txt' +test '-b' 'sample-files/3.txt' diff --git a/implement-shell-tools/ls/check.sh b/implement-shell-tools/ls/check.sh new file mode 100755 index 000000000..34490cf21 --- /dev/null +++ b/implement-shell-tools/ls/check.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +user_command=(${USER_COMMAND:-"node ls.js"}) + +function test() { + args=${@} + echo "======" + echo "Testing ls ${args}" + echo "=======" + diff -y <(/bin/ls ${args[@]}) <(${user_command[@]} ${args[@]}) + echo "" + echo "" +} + +test +test '-1' +test '-1' 'sample-files' +test '-1' '-a' 'sample-files' diff --git a/implement-shell-tools/wc/check.sh b/implement-shell-tools/wc/check.sh new file mode 100755 index 000000000..46761bf17 --- /dev/null +++ b/implement-shell-tools/wc/check.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +user_command=(${USER_COMMAND:-"node wc.js"}) + +function test() { + args=${@} + echo "======" + echo "Testing wc ${args}" + echo "=======" + diff -y <(wc ${args[@]}) <(${user_command[@]} ${args[@]}) + echo "" + echo "" +} + +test 'sample-files/*' +test '-l' 'sample-files/3.txt' +test '-w' 'sample-files/3.txt' +test '-c' 'sample-files/3.txt' +test '-l' 'sample-files/*'