summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rwxr-xr-xtest.sh20
2 files changed, 30 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 73f8388..ebe2e2d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,16 +3,25 @@ CFLAGS=-Wall -Wextra -Wpedantic -O3 -D_POSIX_C_SOURCE=200809L
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
+
all: nt
+
clean:
rm -f nt
+
+test: all
+ @./test.sh
+
+
install: all
install -Dm755 nt -t $(DESTDIR)$(BINDIR)/
+
uninstall:
rm -f $(DESTDIR)$(BINDIR)/nt
+
.POSIX:
-.PHONY: clean install uninstall
+.PHONY: all clean test install uninstall
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..14874b4
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+nt_() {
+ ./nt "$@"
+} >/dev/null
+
+
+fail() {
+ echo "$@"
+ exit 1
+} >&2
+
+
+nt_ && fail "shall return non-zero exit code on no args"
+nt_ 0 && fail "shall return non-zero exit code on just one arg"
+nt_ 0 - && fail "shall return non-zero exit code on zero reps"
+nt_ -1 - && fail "shall return non-zero exit code on negative reps"
+nt_ abc - && fail "shall return non-zero exit code on invalid number"
+nt_ 20 - || fail "shall return zero exit code with one component to repeat"
+nt_ 10 - = + || fail "shall return zero exit code with more components"
+echo ok