添加 structures

This commit is contained in:
YDZ
2020-08-06 23:19:28 +08:00
parent ef3da5d363
commit 1934e384d2
18 changed files with 1079 additions and 0 deletions

78
structures/Point_test.go Normal file
View File

@ -0,0 +1,78 @@
package structures
import (
"reflect"
"testing"
)
func Test_Intss2Points(t *testing.T) {
type args struct {
points [][]int
}
tests := []struct {
name string
args args
want []Point
}{
{
"测试 [][]int 转换成 []Point ",
args{
[][]int{
{1, 0},
{2, 0},
{3, 0},
{4, 0},
{5, 0},
},
},
[]Point{
Point{X: 1, Y: 0},
Point{X: 2, Y: 0},
Point{X: 3, Y: 0},
Point{X: 4, Y: 0},
Point{X: 5, Y: 0},
},
},
}
for _, tt := range tests {
if got := Intss2Points(tt.args.points); !reflect.DeepEqual(got, tt.want) {
t.Errorf("%q. intss2Points() = %v, want %v", tt.name, got, tt.want)
}
}
}
func Test_Points2Intss(t *testing.T) {
type args struct {
points []Point
}
tests := []struct {
name string
args args
want [][]int
}{
{
"测试 [][]int 转换成 []Point ",
args{
[]Point{
Point{X: 1, Y: 0},
Point{X: 2, Y: 0},
Point{X: 3, Y: 0},
Point{X: 4, Y: 0},
Point{X: 5, Y: 0},
},
},
[][]int{
{1, 0},
{2, 0},
{3, 0},
{4, 0},
{5, 0},
},
},
}
for _, tt := range tests {
if got := Points2Intss(tt.args.points); !reflect.DeepEqual(got, tt.want) {
t.Errorf("%q. Points2Intss() = %v, want %v", tt.name, got, tt.want)
}
}
}