|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+#!/usr/bin/env bats
|
|
|
2
|
+
|
|
|
3
|
+load test_helper
|
|
|
4
|
+
|
|
|
5
|
+
|
|
|
6
|
+@test "task1: Check that we have a debug output" {
|
|
|
7
|
+ run stat "$BATS_TEST_DIRNAME/../target/debug/task1"
|
|
|
8
|
+ [ "$status" -eq 0 ]
|
|
|
9
|
+}
|
|
|
10
|
+
|
|
|
11
|
+# Check lines of output
|
|
|
12
|
+
|
|
|
13
|
+# wc output with white spaces is trimmed by xargs
|
|
|
14
|
+@test "task1: Error Output must at least 8 Lines long" {
|
|
|
15
|
+ run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 2>&1 | wc -l | xargs"
|
|
|
16
|
+ assert_range 8 6 10
|
|
|
17
|
+
|
|
|
18
|
+}
|
|
|
19
|
+
|
|
|
20
|
+# wc output with white correct input is trimmed by xargs
|
|
|
21
|
+@test "task1: Normal Output must be at least 4 line long" {
|
|
|
22
|
+ run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 42 123 | wc -l | xargs"
|
|
|
23
|
+ assert_range 4 4 6
|
|
|
24
|
+}
|
|
|
25
|
+
|
|
|
26
|
+# wc output with white correct input is trimmed by xargs
|
|
|
27
|
+@test "task1: Help Output must be at least 18 line long" {
|
|
|
28
|
+ run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' -- --help | wc -l | xargs"
|
|
|
29
|
+ assert_range 18 18 20
|
|
|
30
|
+}
|
|
|
31
|
+
|
|
|
32
|
+# timeout loop
|
|
|
33
|
+@test "task1: Output with wrong pattern" {
|
|
|
34
|
+ run timeout 2 bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 42 j "
|
|
|
35
|
+ no_timeout_fail
|
|
|
36
|
+
|
|
|
37
|
+}
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+# Status checks
|
|
|
41
|
+@test "task1: Output with wrong input paras does not crash" {
|
|
|
42
|
+ run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' x y z "
|
|
|
43
|
+ assert_fail
|
|
|
44
|
+}
|
|
|
45
|
+
|
|
|
46
|
+@test "task1: Output with wrong PARAM does not crash" {
|
|
|
47
|
+ run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' a a"
|
|
|
48
|
+ assert_fail
|
|
|
49
|
+}
|
|
|
50
|
+
|
|
|
51
|
+#@test "task1: Output with wrong pattern does not crash" {
|
|
|
52
|
+# run bash -c "'$BATS_TEST_DIRNAME/../target/debug/task1' 2 a "
|
|
|
53
|
+# assert_fail
|
|
|
54
|
+#}
|
|
|
55
|
+
|
|
|
56
|
+
|
|
|
57
|
+
|
|
|
58
|
+
|
|
|
59
|
+
|