-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
45 lines (33 loc) · 1.01 KB
/
example_test.go
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
package polygon_test
import (
"testing"
"github.com/hamonangann/polygon"
"github.com/stretchr/testify/assert"
)
func TestExample(t *testing.T) {
t.Run("should return correct triangle", func(t *testing.T) {
pl := polygon.NewTriangle(3, 4)
assert.Equal(t, 6.0, pl.Area())
assert.Equal(t, 12.0, pl.Perimeter())
})
t.Run("should return correct square", func(t *testing.T) {
pl := polygon.NewSquare(3)
assert.Equal(t, 9.0, pl.Area())
assert.Equal(t, 12.0, pl.Perimeter())
})
t.Run("should return correct rectangle", func(t *testing.T) {
pl := polygon.NewRectangle(3, 4)
assert.Equal(t, 12.0, pl.Area())
assert.Equal(t, 14.0, pl.Perimeter())
})
t.Run("should return correct rhombus", func(t *testing.T) {
pl := polygon.NewRhombus(6, 8)
assert.Equal(t, 24.0, pl.Area())
assert.Equal(t, 20.0, pl.Perimeter())
})
t.Run("should return correct trapezoid", func(t *testing.T) {
pl := polygon.NewTrapezoid(7, 4, 4)
assert.Equal(t, 22.0, pl.Area())
assert.Equal(t, 20.0, pl.Perimeter())
})
}