Add test/tct_common.bats 89/79689/18
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Mon, 11 Jul 2016 14:51:21 +0000 (16:51 +0200)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 6 Dec 2016 15:37:13 +0000 (16:37 +0100)
Change-Id: I80c9ae848873742a0521e6c4aa29c8f8d138bb69
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
test/tct_common.bats [new file with mode: 0755]

diff --git a/test/tct_common.bats b/test/tct_common.bats
new file mode 100755 (executable)
index 0000000..a526b7a
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env bats
+
+. ./tct/common.sh
+
+@test "no arguments" {
+    RES="$(die 2>&1)" || RET="$?"
+    [ -z "$RES" ]
+    [ "$RET" -eq 1 ]
+}
+
+@test "1st argument" {
+    RES="$(die "foo" 2>&1)" || RET="$?"
+    [ "$RES" = "foo" ]
+    [ "$RET" -eq 1 ]
+}
+
+@test "2nd argument" {
+    RES="$(die "" 2)" || RET="$?"
+    [ -z "$RES" ]
+    [ "$RET" -eq 2 ]
+}
+
+@test "both arguments" {
+    RES="$(die "foo" 3 2>&1)" || RET="$?"
+    [ "$RES" = "foo" ]
+    [ "$RET" -eq 3 ]
+}