-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
first.bats
75 lines (61 loc) · 1.33 KB
/
first.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bats
setup_fixture
@test "l.first (a asd bcd d)" {
local arr=(a asd bcd d)
run l.first arr
assert_success
assert_output 'a'
}
@test "l.first ('a asd' bcd d)" {
local arr=('a asd' bcd d)
run l.first arr
assert_success
assert_output 'a asd'
}
@test "l.first ()" {
local arr=()
run l.first arr
assert_success
assert_equal "${#lines[@]}" 0
assert_output ''
}
@test "l.first (a asd bcd d) 2" {
local arr=(a asd bcd d)
local expect=(a asd)
run l.first arr 2
assert_success
assert_equal "${#lines[@]}" "${#expect[@]}"
local i
for (( i = 0; i < ${#expect[@]}; i++ )); do
assert_line -n "$i" "${expect[$i]}"
done
}
@test "l.first (a asd bcd d) 5" {
local arr=(a asd bcd d)
local expect=(a asd bcd d)
run l.first arr 5
assert_success
assert_equal "${#lines[@]}" "${#expect[@]}"
local i
for (( i = 0; i < ${#expect[@]}; i++ )); do
assert_line -n "$i" "${expect[$i]}"
done
}
@test "l.first ('a asd' bcd d) 2" {
local arr=('a asd' bcd d)
local expect=('a asd' bcd)
run l.first arr 2
assert_success
assert_equal "${#lines[@]}" "${#expect[@]}"
local i
for (( i = 0; i < ${#expect[@]}; i++ )); do
assert_line -n "$i" "${expect[$i]}"
done
}
@test "l.first () 2" {
local arr=()
run l.first arr 2
assert_success
assert_equal "${#lines[@]}" 0
assert_output ''
}