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
| // main_test.go
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_Division(t *testing.T) {
// Arrange
testCases := []struct {
name string
p numbers
expected float64
}{
{
name: "9/3 = 3",
p: numbers{
A: 9,
B: 3,
},
expected: 3,
},
{
name: "6/3 = 2",
p: numbers{
A: 6,
B: 3,
},
expected: 2,
},
{
name: "3/3 = 1",
p: numbers{
A: 3,
B: 3,
},
expected: 1,
},
}
for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
// Act
r, _ := Division(c.p)
// Assert
assert.Equal(t, r, c.expected)
})
}
}
|