作者 linmadan

添加新的布局算法

module gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion
go 1.16
go 1.19
require (
github.com/ajg/form v1.5.1 // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible
github.com/beego/beego/v2 v2.0.1
github.com/bwmarrin/snowflake v0.3.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/extrame/xls v0.0.1
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible
github.com/go-gota/gota v0.12.0
github.com/go-pg/pg/v10 v10.10.6
github.com/go-redis/redis v6.15.9+incompatible
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0
github.com/google/uuid v1.3.0
github.com/gookit/event v1.0.6
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7
github.com/moul/http2curl v1.0.0 // indirect
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.18.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1
github.com/silenceper/wechat/v2 v2.1.4 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/stretchr/testify v1.7.1
github.com/xuri/excelize/v2 v2.6.0
github.com/zeromicro/go-zero v1.3.4
golang.org/x/text v0.3.7
gorm.io/driver/mysql v1.3.6
gorm.io/driver/postgres v1.3.9
gorm.io/gorm v1.23.8
)
require (
github.com/Shopify/sarama v1.30.0 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/extrame/goyymmdd v0.0.0-20210114090516-7cc815f00d1a // indirect
github.com/extrame/ole2 v0.0.0-20160812065207-d69429661ad7 // indirect
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-pg/zerochecker v0.2.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.12.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.11.0 // indirect
github.com/jackc/pgx/v4 v4.16.1 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.15.0 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/moul/http2curl v1.0.0 // indirect
github.com/mozillazg/go-pinyin v0.19.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/openzipkin/zipkin-go v0.4.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.1 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/tealeg/xlsx v1.0.5 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.38.0 // indirect
github.com/vmihailenco/bufpool v0.1.11 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect
github.com/xuri/excelize/v2 v2.6.0
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
github.com/zeromicro/go-zero v1.3.4
golang.org/x/text v0.3.7
gorm.io/driver/mysql v1.3.6
gorm.io/driver/postgres v1.3.9
gorm.io/gorm v1.23.8
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.7.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.7.0 // indirect
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/automaxprocs v1.5.1 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gonum.org/v1/gonum v0.9.1 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
mellium.im/sasl v0.2.1 // indirect
)
replace (
... ...
... ... @@ -59,6 +59,38 @@ func (ptr *QuerySetService) LoadCalculateSetData(ctx *domain.Context, qs *domain
}
func CellsLocationAdjust(cells []*domain.LayoutCell) {
if len(cells) > 0 {
addedRows := 0
addedColumns := 0
preRowMaxDownLength := 0
preRawCellX := 0
for _, cell := range cells {
if preRawCellX != cell.X {
addedColumns = 0
addedRows = addedRows + preRowMaxDownLength - 1
preRowMaxDownLength = 0
preRawCellX = cell.X
}
switch cell.Direction {
case domain.DirectionRight:
cell.X = addedRows + cell.X
cell.Y = addedColumns + cell.Y
addedColumns = addedColumns + cell.Length - 1
case domain.DirectionDown:
cell.X = addedRows + cell.X
cell.Y = addedColumns + cell.Y
if cell.Length > preRowMaxDownLength {
preRowMaxDownLength = cell.Length
}
case domain.DirectionNone:
cell.X = addedRows + cell.X
cell.Y = addedColumns + cell.Y
}
}
}
}
func CellsLocationAdjustOld(cells []*domain.LayoutCell) {
xMin := 0
xMax := 0
yMin := 0
... ...
package domainService
import (
"github.com/stretchr/testify/assert"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"testing"
)
func TestNewDataLayout(t *testing.T) {
inputs := []struct {
cells []*domain.LayoutCell
flag Location
title string
debug bool
}{
{
title: "配置组多组混合",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 2,
ImageData: "2",
Direction: domain.DirectionRight,
},
{
X: 0,
Y: 1,
Length: 3,
ImageData: "3",
Direction: domain.DirectionRight,
},
{
X: 0,
Y: 2,
Length: 1,
ImageData: "",
Direction: domain.DirectionRight,
},
{
X: 0,
Y: 4,
Length: 5,
ImageData: "5",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 1,
Length: 2,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 2,
Length: 2,
ImageData: "f",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 3,
Length: 2,
ImageData: "b",
Direction: domain.DirectionDown,
},
{
X: 2,
Y: 0,
Length: 2,
ImageData: "e",
Direction: domain.DirectionDown,
},
{
X: 2,
Y: 1,
Length: 1,
ImageData: "c",
Direction: domain.DirectionNone,
},
{
X: 2,
Y: 2,
Length: 1,
ImageData: "d",
Direction: domain.DirectionNone,
},
{
X: 5,
Y: 0,
Length: 6,
ImageData: "g",
Direction: domain.DirectionDown,
},
},
flag: Location{X: 2, Y: 2},
},
}
padding := func(cells []*domain.LayoutCell) {
for _, cell := range cells {
for i := 0; i < cell.Length; i++ {
cell.BlockData = append(cell.BlockData, cell.ImageData)
}
}
}
debugItem := false
for _, input := range inputs {
if debugItem && !input.debug {
continue
}
padding(input.cells)
// 根据数据修改位移
CellsLocationAdjust(input.cells)
// 数据布局
res := &domain.DataTable{}
res, err := DataLayout(res, input.cells)
if err != nil {
assert.NoError(t, err)
}
printRes(res)
}
}
... ...
... ... @@ -75,360 +75,266 @@ func TestDataLayout(t *testing.T) {
ImageData: "d",
Direction: domain.DirectionNone,
},
//分组二 右平移10
{
X: 0,
Y: 10,
Length: 2,
ImageData: "2",
Direction: domain.DirectionRight,
},
{
X: 0,
Y: 11,
Length: 3,
ImageData: "3",
Direction: domain.DirectionRight,
},
{
X: 1,
Y: 10,
Length: 2,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 11,
Length: 2,
ImageData: "f",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 12,
Length: 2,
ImageData: "b",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 13,
Length: 2,
ImageData: "e",
Direction: domain.DirectionDown,
},
{
X: 2,
Y: 10,
Length: 1,
ImageData: "c",
Direction: domain.DirectionNone,
},
{
X: 2,
Y: 11,
Length: 1,
ImageData: "d",
Direction: domain.DirectionNone,
},
},
flag: Location{X: 2, Y: 2},
},
{
title: "正常多字段横排",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionRight,
},
{
X: 1,
Y: 0,
Length: 5,
ImageData: "b",
Direction: domain.DirectionRight,
},
{
X: 2,
Y: 0,
Length: 5,
ImageData: "c",
Direction: domain.DirectionRight,
},
{
X: 3,
Y: 0,
Length: 5,
ImageData: "d",
Direction: domain.DirectionRight,
},
// 分组二 平移10
{
X: 0,
Y: 10,
Length: 5,
ImageData: "a",
Direction: domain.DirectionRight,
},
{
X: 1,
Y: 10,
Length: 5,
ImageData: "b",
Direction: domain.DirectionRight,
},
{
X: 2,
Y: 10,
Length: 5,
ImageData: "c",
Direction: domain.DirectionRight,
},
{
X: 3,
Y: 10,
Length: 5,
ImageData: "d",
Direction: domain.DirectionRight,
},
},
flag: Location{X: 3, Y: 4},
},
{
title: "正常多字段横排+计算项目",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionRight,
},
{
X: 1,
Y: 0,
Length: 5,
ImageData: "b",
Direction: domain.DirectionRight,
},
{
X: 2,
Y: 0,
Length: 1,
ImageData: "c",
Direction: domain.DirectionNone,
},
{
X: 3,
Y: 0,
Length: 1,
ImageData: "d",
Direction: domain.DirectionNone,
},
// 分组二 平移10
{
X: 0,
Y: 10,
Length: 1,
ImageData: "a",
Direction: domain.DirectionRight,
},
{
X: 1,
Y: 10,
Length: 5,
ImageData: "b",
Direction: domain.DirectionRight,
},
{
X: 2,
Y: 10,
Length: 1,
ImageData: "c",
Direction: domain.DirectionNone,
},
{
X: 2,
Y: 11,
Length: 1,
ImageData: "e",
Direction: domain.DirectionNone,
},
{
X: 3,
Y: 10,
Length: 1,
ImageData: "d",
Direction: domain.DirectionNone,
},
},
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: 5,
ImageData: "c",
Direction: domain.DirectionRight,
},
{
X: 2,
Y: 0,
Length: 5,
ImageData: "d",
Direction: domain.DirectionRight,
},
},
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},
},
{
title: "测试用例4",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 0,
Y: 1,
Length: 5,
ImageData: "b",
Direction: domain.DirectionDown,
},
// ,
//{
// title: "正常多字段横排",
// cells: []*domain.LayoutCell{
// // 分组一
// {
// X: 0,
// Y: 0,
// Length: 5,
// ImageData: "a",
// Direction: domain.DirectionRight,
// },
// {
// X: 1,
// Y: 0,
// Length: 5,
// ImageData: "b",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 0,
// Length: 5,
// ImageData: "c",
// Direction: domain.DirectionRight,
// },
// {
// X: 3,
// Y: 0,
// Length: 5,
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
//
// // 分组二 平移10
// {
// X: 0,
// Y: 10,
// Length: 5,
// ImageData: "a",
// Direction: domain.DirectionRight,
// },
// {
// X: 1,
// Y: 10,
// Length: 5,
// ImageData: "b",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 10,
// Length: 5,
// ImageData: "c",
// Direction: domain.DirectionRight,
// },
// {
// X: 3,
// Y: 10,
// Length: 5,
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
// },
// flag: Location{X: 3, Y: 4},
//},
//
//{
// title: "正常多字段横排+计算项目",
// cells: []*domain.LayoutCell{
// // 分组一
// {
// X: 0,
// Y: 0,
// Length: 5,
// ImageData: "a",
// Direction: domain.DirectionRight,
// },
// {
// X: 1,
// Y: 0,
// Length: 5,
// ImageData: "b",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 0,
// Length: 1,
// ImageData: "c",
// Direction: domain.DirectionNone,
// },
// {
// X: 3,
// Y: 0,
// Length: 1,
// ImageData: "d",
// Direction: domain.DirectionNone,
// },
//
// // 分组二 平移10
// {
// X: 0,
// Y: 10,
// Length: 1,
// ImageData: "a",
// Direction: domain.DirectionRight,
// },
// {
// X: 1,
// Y: 10,
// Length: 5,
// ImageData: "b",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 10,
// Length: 1,
// ImageData: "c",
// Direction: domain.DirectionNone,
// },
// {
// X: 2,
// Y: 11,
// Length: 1,
// ImageData: "e",
// Direction: domain.DirectionNone,
// },
// {
// X: 3,
// Y: 10,
// Length: 1,
// ImageData: "d",
// Direction: domain.DirectionNone,
// },
// },
// 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: 5,
// ImageData: "c",
// Direction: domain.DirectionRight,
// },
// {
// X: 2,
// Y: 0,
// Length: 5,
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
// },
// 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,
... ... @@ -443,42 +349,107 @@ func TestDataLayout(t *testing.T) {
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
},
flag: Location{X: 0, Y: 0},
},
{
title: "测试用例5",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 5,
ImageData: "a",
Direction: domain.DirectionDown,
},
{
X: 0,
Y: 1,
Length: 6,
ImageData: "b",
Direction: domain.DirectionDown,
},
{
X: 1,
Y: 0,
Length: 1,
ImageData: "t",
Direction: domain.DirectionNone,
},
{
X: 1,
Y: 1,
Length: 1,
ImageData: "x",
Direction: domain.DirectionNone,
},
// ,
// },
// flag: Location{X: 2, Y: 1},
//},
//{
// title: "测试用例4",
// cells: []*domain.LayoutCell{
// // 分组一
// {
// X: 0,
// Y: 0,
// Length: 5,
// ImageData: "a",
// Direction: domain.DirectionDown,
// },
// {
// X: 0,
// Y: 1,
// 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: 0, Y: 0},
//},
//{
// title: "测试用例5",
// cells: []*domain.LayoutCell{
// // 分组一
// {
// X: 0,
// Y: 0,
// Length: 5,
// ImageData: "a",
// Direction: domain.DirectionDown,
// },
// {
// X: 0,
// Y: 1,
// Length: 6,
// ImageData: "b",
// Direction: domain.DirectionDown,
// },
// {
// X: 1,
// Y: 0,
// Length: 1,
// ImageData: "t",
// Direction: domain.DirectionNone,
// },
// {
// X: 1,
// Y: 1,
// Length: 1,
// ImageData: "x",
// Direction: domain.DirectionNone,
// },
// // ,
// // {
// // 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: 0, Y: 0},
// debug:true,
//},
//{
// title: "测试用例6",
// cells: []*domain.LayoutCell{
// // 分组一
// {
// X: 0,
// Y: 0,
// Length: 1,
// ImageData: "a",
// Direction: domain.DirectionNone,
// },
// {
// X: 1,
// Y: 1,
... ... @@ -493,38 +464,9 @@ func TestDataLayout(t *testing.T) {
// ImageData: "d",
// Direction: domain.DirectionRight,
// },
},
flag: Location{X: 0, Y: 0},
debug:true,
},
{
title: "测试用例6",
cells: []*domain.LayoutCell{
// 分组一
{
X: 0,
Y: 0,
Length: 1,
ImageData: "a",
Direction: domain.DirectionNone,
},
{
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: 0, Y: 0},
},
// },
// flag: Location{X: 0, Y: 0},
//},
}
padding := func(cells []*domain.LayoutCell) {
for _, cell := range cells {
... ... @@ -533,9 +475,9 @@ func TestDataLayout(t *testing.T) {
}
}
}
debugItem:= false
debugItem := false
for _, input := range inputs {
if debugItem && !input.debug{
if debugItem && !input.debug {
continue
}
padding(input.cells)
... ...