代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Fyne 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package fyne
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPosition_Add(t *testing.T) {
pos1 := NewPos(10, 10)
pos2 := NewPos(25, 25)
pos3 := pos1.Add(pos2)
assert.Equal(t, float32(35), pos3.X)
assert.Equal(t, float32(35), pos3.Y)
}
func TestPosition_Add_Size(t *testing.T) {
pos1 := NewPos(10, 10)
s := NewSize(25, 25)
pos2 := pos1.Add(s)
assert.Equal(t, float32(35), pos2.X)
assert.Equal(t, float32(35), pos2.Y)
}
func TestPosition_Add_Vector(t *testing.T) {
pos1 := NewPos(10, 10)
v := NewDelta(25, 25)
pos2 := pos1.Add(v)
assert.Equal(t, float32(35), pos2.X)
assert.Equal(t, float32(35), pos2.Y)
}
func TestPosition_IsZero(t *testing.T) {
for name, tt := range map[string]struct {
p Position
want bool
}{
"zero value": {Position{}, true},
"0,0": {NewPos(0, 0), true},
"zero X": {NewPos(0, 42), false},
"zero Y": {NewPos(17, 0), false},
"non-zero X and Y": {NewPos(6, 9), false},
} {
t.Run(name, func(t *testing.T) {
assert.Equal(t, tt.want, tt.p.IsZero())
})
}
}
func TestPosition_Subtract(t *testing.T) {
pos1 := NewPos(25, 25)
pos2 := NewPos(10, 10)
pos3 := pos1.Subtract(pos2)
assert.Equal(t, float32(15), pos3.X)
assert.Equal(t, float32(15), pos3.Y)
}
func TestSize_Add(t *testing.T) {
size1 := NewSize(10, 10)
size2 := NewSize(25, 25)
size3 := size1.Add(size2)
assert.Equal(t, float32(35), size3.Width)
assert.Equal(t, float32(35), size3.Height)
}
func TestSize_Add_Position(t *testing.T) {
size1 := NewSize(10, 10)
p := NewSize(25, 25)
size2 := size1.Add(p)
assert.Equal(t, float32(35), size2.Width)
assert.Equal(t, float32(35), size2.Height)
}
func TestSize_Add_Vector(t *testing.T) {
size1 := NewSize(10, 10)
v := NewDelta(25, 25)
size2 := size1.Add(v)
assert.Equal(t, float32(35), size2.Width)
assert.Equal(t, float32(35), size2.Height)
}
func TestSize_IsZero(t *testing.T) {
for name, tt := range map[string]struct {
s Size
want bool
}{
"zero value": {Size{}, true},
"0x0": {NewSize(0, 0), true},
"zero width": {NewSize(0, 42), false},
"zero height": {NewSize(17, 0), false},
"non-zero area": {NewSize(6, 9), false},
} {
t.Run(name, func(t *testing.T) {
assert.Equal(t, tt.want, tt.s.IsZero())
})
}
}
func TestSize_Max(t *testing.T) {
size1 := NewSize(10, 100)
size2 := NewSize(100, 10)
size3 := size1.Max(size2)
assert.Equal(t, float32(100), size3.Width)
assert.Equal(t, float32(100), size3.Height)
}
func TestSize_Min(t *testing.T) {
size1 := NewSize(10, 100)
size2 := NewSize(100, 10)
size3 := size1.Min(size2)
assert.Equal(t, float32(10), size3.Width)
assert.Equal(t, float32(10), size3.Height)
}
func TestSize_Subtract(t *testing.T) {
size1 := NewSize(25, 25)
size2 := NewSize(10, 10)
size3 := size1.Subtract(size2)
assert.Equal(t, float32(15), size3.Width)
assert.Equal(t, float32(15), size3.Height)
}
func TestVector_IsZero(t *testing.T) {
v := NewDelta(0, 0)
assert.True(t, v.IsZero())
v.DX = 1
assert.False(t, v.IsZero())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。