forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry_test.go
60 lines (42 loc) · 1.19 KB
/
geometry_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package fyne
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSizeAdd(t *testing.T) {
size1 := NewSize(10, 10)
size2 := NewSize(25, 25)
size3 := size1.Add(size2)
assert.Equal(t, size3.Width, size1.Width+size2.Width)
assert.Equal(t, size3.Height, size1.Height+size2.Height)
}
func TestSizeSubtract(t *testing.T) {
size1 := NewSize(25, 25)
size2 := NewSize(10, 10)
size3 := size1.Subtract(size2)
assert.Equal(t, size3.Width, size1.Width-size2.Width)
assert.Equal(t, size3.Height, size1.Height-size2.Height)
}
func TestSizeUnion(t *testing.T) {
size1 := NewSize(10, 100)
size2 := NewSize(100, 10)
size3 := size1.Union(size2)
maxW := Max(size1.Width, size2.Width)
maxH := Max(size1.Height, size2.Height)
assert.Equal(t, size3.Width, maxW)
assert.Equal(t, size3.Height, maxH)
}
func TestPosition_Add(t *testing.T) {
pos1 := NewPos(10, 10)
pos2 := NewPos(25, 25)
pos3 := pos1.Add(pos2)
assert.Equal(t, pos3.X, pos1.X+pos2.X)
assert.Equal(t, pos3.Y, pos1.Y+pos2.Y)
}
func TestPosition_Subtract(t *testing.T) {
pos1 := NewPos(25, 25)
pos2 := NewPos(10, 10)
pos3 := pos1.Subtract(pos2)
assert.Equal(t, pos3.X, pos1.X-pos2.X)
assert.Equal(t, pos3.Y, pos1.Y-pos2.Y)
}