-
Notifications
You must be signed in to change notification settings - Fork 0
/
fizzbuzz-test
executable file
·99 lines (88 loc) · 1.99 KB
/
fizzbuzz-test
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
#==================================================================================
# Unit tests for fizzbuzz sample in bash
#
#==================================================================================
. ./bash_spec
. ./fizzbuzz-bash
function numbers_divisible_by_3 {
for i in 3 6 9 81
do
it "returns Fizz for $i"
fizz_it $i
expect $fizz_result to_be 'Fizz'
done
}
function numbers_divisible_by_5 {
for i in 5 10 20
do
it "returns Buzz for $i"
fizz_it $i
expect $fizz_result to_be 'Buzz'
done
}
function numbers_divisible_by_7 {
for i in 7 14 28
do
it "returns Baz for $i"
fizz_it $i
expect $fizz_result to_be 'Baz'
done
}
function numbers_divisible_by_3_and_5 {
for i in 15 60 900
do
it "returns FizzBuzz for $i"
fizz_it $i
expect $fizz_result to_be 'FizzBuzz'
done
}
function numbers_divisible_by_3_and_7 {
for i in 21 84
do
it "returns FizzBaz for $i"
fizz_it $i
expect $fizz_result to_be 'FizzBaz'
done
}
function numbers_divisible_by_5_and_7 {
for i in 35 70
do
it "returns BuzzBaz for $i"
fizz_it $i
expect $fizz_result to_be 'BuzzBaz'
done
}
function numbers_divisible_by_3_and_5_and_7 {
for i in 105 630
do
it "returns FizzBuzzBaz for $i"
fizz_it $i
expect $fizz_result to_be 'FizzBuzzBaz'
done
}
function numbers_not_divisible_by_3_or_5_or_7 {
for i in 2 8 811
do
it "returns $i for $i"
fizz_it $i
expect $fizz_result to_be "$i"
done
}
function zero_returns_zero {
it "returns zero when input is zero"
fizz_it 0
expect $fizz_result to_be '0'
}
print_header fizzbuzz_bash
numbers_divisible_by_3
numbers_divisible_by_5
numbers_divisible_by_7
numbers_divisible_by_3_and_5
numbers_divisible_by_3_and_7
numbers_divisible_by_5_and_7
numbers_divisible_by_3_and_5_and_7
numbers_not_divisible_by_3_or_5_or_7
zero_returns_zero
print_trailer
exit 0