...
|
...
|
@@ -75,7 +75,7 @@ func TestDataLayout(t *testing.T) { |
|
|
Direction: domain.DirectionNone,
|
|
|
},
|
|
|
|
|
|
// 分组二 右平移10
|
|
|
//分组二 右平移10
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 10,
|
...
|
...
|
@@ -133,7 +133,7 @@ func TestDataLayout(t *testing.T) { |
|
|
Direction: domain.DirectionNone,
|
|
|
},
|
|
|
},
|
|
|
flag: Location{X: 3, Y: 2},
|
|
|
flag: Location{X: 2, Y: 2},
|
|
|
},
|
|
|
{
|
|
|
title: "正常多字段横排",
|
...
|
...
|
@@ -309,6 +309,106 @@ func TestDataLayout(t *testing.T) { |
|
|
},
|
|
|
flag: Location{X: 2, Y: 1},
|
|
|
},
|
|
|
|
|
|
{
|
|
|
title: "正常多字段横排(长度不一样)+竖排",
|
|
|
cells: []*domain.LayoutCell{
|
|
|
// 分组一
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 0,
|
|
|
Length: 5,
|
|
|
ImageData: "a",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 1,
|
|
|
Length: 5,
|
|
|
ImageData: "b",
|
|
|
Direction: domain.DirectionDown,
|
|
|
},
|
|
|
{
|
|
|
X: 1,
|
|
|
Y: 0,
|
|
|
Length: 6,
|
|
|
ImageData: "c",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
{
|
|
|
X: 2,
|
|
|
Y: 0,
|
|
|
Length: 7,
|
|
|
ImageData: "d",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
},
|
|
|
flag: Location{X: 2, Y: 1},
|
|
|
},
|
|
|
|
|
|
{
|
|
|
title: "测试用例1",
|
|
|
cells: []*domain.LayoutCell{
|
|
|
// 分组一
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 0,
|
|
|
Length: 1,
|
|
|
ImageData: "a",
|
|
|
Direction: domain.DirectionNone,
|
|
|
},
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 1,
|
|
|
Length: 1,
|
|
|
ImageData: "b",
|
|
|
Direction: domain.DirectionNone,
|
|
|
},
|
|
|
{
|
|
|
X: 2,
|
|
|
Y: 2,
|
|
|
Length: 5,
|
|
|
ImageData: "c",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
},
|
|
|
flag: Location{X: 0, Y: 0},
|
|
|
},
|
|
|
{
|
|
|
title: "测试用例3",
|
|
|
cells: []*domain.LayoutCell{
|
|
|
// 分组一
|
|
|
{
|
|
|
X: 0,
|
|
|
Y: 0,
|
|
|
Length: 5,
|
|
|
ImageData: "a",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
{
|
|
|
X: 1,
|
|
|
Y: 0,
|
|
|
Length: 5,
|
|
|
ImageData: "b",
|
|
|
Direction: domain.DirectionDown,
|
|
|
},
|
|
|
{
|
|
|
X: 1,
|
|
|
Y: 1,
|
|
|
Length: 5,
|
|
|
ImageData: "c",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
{
|
|
|
X: 2,
|
|
|
Y: 1,
|
|
|
Length: 5,
|
|
|
ImageData: "d",
|
|
|
Direction: domain.DirectionRight,
|
|
|
},
|
|
|
},
|
|
|
flag: Location{X: 2, Y: 1},
|
|
|
},
|
|
|
}
|
|
|
padding := func(cells []*domain.LayoutCell) {
|
|
|
for _, cell := range cells {
|
...
|
...
|
@@ -328,10 +428,53 @@ func TestDataLayout(t *testing.T) { |
|
|
assert.NoError(t, err)
|
|
|
}
|
|
|
printRes(res)
|
|
|
assert.NotEmptyf(t, res.Data[input.flag.X][input.flag.Y], "单元格有值")
|
|
|
if input.flag.X > 0 && input.flag.Y > 0 {
|
|
|
assert.NotEmptyf(t, res.Data[input.flag.X][input.flag.Y], "单元格有值")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
output
|
|
|
|
|
|
2 | 2 | 3 | 3 | 3 | | | | | | | | | 2 | 2 | 3 | 3 | 3 | |
|
|
|
a | | f | | | b | e | | | | | | | a | | f | | | b | e
|
|
|
a | | f | | | b | e | | | | | | | a | | f | | | b | e
|
|
|
c | | d | | | | | | | | | | | c | | d | | | |
|
|
|
|
|
|
a | a | a | a | a | | | | | | | | | | a | a | a | a | a
|
|
|
b | b | b | b | b | | | | | | | | | | b | b | b | b | b
|
|
|
c | c | c | c | c | | | | | | | | | | c | c | c | c | c
|
|
|
d | d | d | d | d | | | | | | | | | | d | d | d | d | d
|
|
|
|
|
|
a | a | a | a | a | | | | | | | | | | a | | | | |
|
|
|
b | b | b | b | b | | | | | | | | | | b | b | b | b | b |
|
|
|
c | | | | | | | | | | | | | | c | | | | | e
|
|
|
d | | | | | | | | | | | | | | d | | | | |
|
|
|
|
|
|
a | a | a | a | a | b
|
|
|
c | c | c | c | c | b
|
|
|
d | d | d | d | d | b
|
|
|
| | | | | b
|
|
|
| | | | | b
|
|
|
|
|
|
a | a | a | a | a | | | b
|
|
|
c | c | c | c | c | c | | b
|
|
|
d | d | d | d | d | d | d | b
|
|
|
| | | | | | | b
|
|
|
| | | | | | | b
|
|
|
|
|
|
a | a | a | a | a | | | | |
|
|
|
b | | | | | c | c | c | c | c
|
|
|
b | | | | | | | | |
|
|
|
b | | | | | | | | |
|
|
|
b | | | | | | | | |
|
|
|
b | | | | | | | | |
|
|
|
| | | | | d | d | d | d | d
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
func printRes(res *domain.DataTable) {
|
|
|
strBuilder := strings.Builder{}
|
|
|
for i := range res.Data {
|
...
|
...
|
|