|
@@ -75,7 +75,7 @@ func TestDataLayout(t *testing.T) { |
|
@@ -75,7 +75,7 @@ func TestDataLayout(t *testing.T) { |
75
|
Direction: domain.DirectionNone,
|
75
|
Direction: domain.DirectionNone,
|
76
|
},
|
76
|
},
|
77
|
|
77
|
|
78
|
- // 分组二 右平移10
|
78
|
+ //分组二 右平移10
|
79
|
{
|
79
|
{
|
80
|
X: 0,
|
80
|
X: 0,
|
81
|
Y: 10,
|
81
|
Y: 10,
|
|
@@ -133,7 +133,7 @@ func TestDataLayout(t *testing.T) { |
|
@@ -133,7 +133,7 @@ func TestDataLayout(t *testing.T) { |
133
|
Direction: domain.DirectionNone,
|
133
|
Direction: domain.DirectionNone,
|
134
|
},
|
134
|
},
|
135
|
},
|
135
|
},
|
136
|
- flag: Location{X: 3, Y: 2},
|
136
|
+ flag: Location{X: 2, Y: 2},
|
137
|
},
|
137
|
},
|
138
|
{
|
138
|
{
|
139
|
title: "正常多字段横排",
|
139
|
title: "正常多字段横排",
|
|
@@ -309,6 +309,106 @@ func TestDataLayout(t *testing.T) { |
|
@@ -309,6 +309,106 @@ func TestDataLayout(t *testing.T) { |
309
|
},
|
309
|
},
|
310
|
flag: Location{X: 2, Y: 1},
|
310
|
flag: Location{X: 2, Y: 1},
|
311
|
},
|
311
|
},
|
|
|
312
|
+
|
|
|
313
|
+ {
|
|
|
314
|
+ title: "正常多字段横排(长度不一样)+竖排",
|
|
|
315
|
+ cells: []*domain.LayoutCell{
|
|
|
316
|
+ // 分组一
|
|
|
317
|
+ {
|
|
|
318
|
+ X: 0,
|
|
|
319
|
+ Y: 0,
|
|
|
320
|
+ Length: 5,
|
|
|
321
|
+ ImageData: "a",
|
|
|
322
|
+ Direction: domain.DirectionRight,
|
|
|
323
|
+ },
|
|
|
324
|
+ {
|
|
|
325
|
+ X: 0,
|
|
|
326
|
+ Y: 1,
|
|
|
327
|
+ Length: 5,
|
|
|
328
|
+ ImageData: "b",
|
|
|
329
|
+ Direction: domain.DirectionDown,
|
|
|
330
|
+ },
|
|
|
331
|
+ {
|
|
|
332
|
+ X: 1,
|
|
|
333
|
+ Y: 0,
|
|
|
334
|
+ Length: 6,
|
|
|
335
|
+ ImageData: "c",
|
|
|
336
|
+ Direction: domain.DirectionRight,
|
|
|
337
|
+ },
|
|
|
338
|
+ {
|
|
|
339
|
+ X: 2,
|
|
|
340
|
+ Y: 0,
|
|
|
341
|
+ Length: 7,
|
|
|
342
|
+ ImageData: "d",
|
|
|
343
|
+ Direction: domain.DirectionRight,
|
|
|
344
|
+ },
|
|
|
345
|
+ },
|
|
|
346
|
+ flag: Location{X: 2, Y: 1},
|
|
|
347
|
+ },
|
|
|
348
|
+
|
|
|
349
|
+ {
|
|
|
350
|
+ title: "测试用例1",
|
|
|
351
|
+ cells: []*domain.LayoutCell{
|
|
|
352
|
+ // 分组一
|
|
|
353
|
+ {
|
|
|
354
|
+ X: 0,
|
|
|
355
|
+ Y: 0,
|
|
|
356
|
+ Length: 1,
|
|
|
357
|
+ ImageData: "a",
|
|
|
358
|
+ Direction: domain.DirectionNone,
|
|
|
359
|
+ },
|
|
|
360
|
+ {
|
|
|
361
|
+ X: 0,
|
|
|
362
|
+ Y: 1,
|
|
|
363
|
+ Length: 1,
|
|
|
364
|
+ ImageData: "b",
|
|
|
365
|
+ Direction: domain.DirectionNone,
|
|
|
366
|
+ },
|
|
|
367
|
+ {
|
|
|
368
|
+ X: 2,
|
|
|
369
|
+ Y: 2,
|
|
|
370
|
+ Length: 5,
|
|
|
371
|
+ ImageData: "c",
|
|
|
372
|
+ Direction: domain.DirectionRight,
|
|
|
373
|
+ },
|
|
|
374
|
+ },
|
|
|
375
|
+ flag: Location{X: 0, Y: 0},
|
|
|
376
|
+ },
|
|
|
377
|
+ {
|
|
|
378
|
+ title: "测试用例3",
|
|
|
379
|
+ cells: []*domain.LayoutCell{
|
|
|
380
|
+ // 分组一
|
|
|
381
|
+ {
|
|
|
382
|
+ X: 0,
|
|
|
383
|
+ Y: 0,
|
|
|
384
|
+ Length: 5,
|
|
|
385
|
+ ImageData: "a",
|
|
|
386
|
+ Direction: domain.DirectionRight,
|
|
|
387
|
+ },
|
|
|
388
|
+ {
|
|
|
389
|
+ X: 1,
|
|
|
390
|
+ Y: 0,
|
|
|
391
|
+ Length: 5,
|
|
|
392
|
+ ImageData: "b",
|
|
|
393
|
+ Direction: domain.DirectionDown,
|
|
|
394
|
+ },
|
|
|
395
|
+ {
|
|
|
396
|
+ X: 1,
|
|
|
397
|
+ Y: 1,
|
|
|
398
|
+ Length: 5,
|
|
|
399
|
+ ImageData: "c",
|
|
|
400
|
+ Direction: domain.DirectionRight,
|
|
|
401
|
+ },
|
|
|
402
|
+ {
|
|
|
403
|
+ X: 2,
|
|
|
404
|
+ Y: 1,
|
|
|
405
|
+ Length: 5,
|
|
|
406
|
+ ImageData: "d",
|
|
|
407
|
+ Direction: domain.DirectionRight,
|
|
|
408
|
+ },
|
|
|
409
|
+ },
|
|
|
410
|
+ flag: Location{X: 2, Y: 1},
|
|
|
411
|
+ },
|
312
|
}
|
412
|
}
|
313
|
padding := func(cells []*domain.LayoutCell) {
|
413
|
padding := func(cells []*domain.LayoutCell) {
|
314
|
for _, cell := range cells {
|
414
|
for _, cell := range cells {
|
|
@@ -328,10 +428,53 @@ func TestDataLayout(t *testing.T) { |
|
@@ -328,10 +428,53 @@ func TestDataLayout(t *testing.T) { |
328
|
assert.NoError(t, err)
|
428
|
assert.NoError(t, err)
|
329
|
}
|
429
|
}
|
330
|
printRes(res)
|
430
|
printRes(res)
|
331
|
- assert.NotEmptyf(t, res.Data[input.flag.X][input.flag.Y], "单元格有值")
|
431
|
+ if input.flag.X > 0 && input.flag.Y > 0 {
|
|
|
432
|
+ assert.NotEmptyf(t, res.Data[input.flag.X][input.flag.Y], "单元格有值")
|
|
|
433
|
+ }
|
332
|
}
|
434
|
}
|
333
|
}
|
435
|
}
|
334
|
|
436
|
|
|
|
437
|
+/*
|
|
|
438
|
+output
|
|
|
439
|
+
|
|
|
440
|
+2 | 2 | 3 | 3 | 3 | | | | | | | | | 2 | 2 | 3 | 3 | 3 | |
|
|
|
441
|
+a | | f | | | b | e | | | | | | | a | | f | | | b | e
|
|
|
442
|
+a | | f | | | b | e | | | | | | | a | | f | | | b | e
|
|
|
443
|
+c | | d | | | | | | | | | | | c | | d | | | |
|
|
|
444
|
+
|
|
|
445
|
+a | a | a | a | a | | | | | | | | | | a | a | a | a | a
|
|
|
446
|
+b | b | b | b | b | | | | | | | | | | b | b | b | b | b
|
|
|
447
|
+c | c | c | c | c | | | | | | | | | | c | c | c | c | c
|
|
|
448
|
+d | d | d | d | d | | | | | | | | | | d | d | d | d | d
|
|
|
449
|
+
|
|
|
450
|
+a | a | a | a | a | | | | | | | | | | a | | | | |
|
|
|
451
|
+b | b | b | b | b | | | | | | | | | | b | b | b | b | b |
|
|
|
452
|
+c | | | | | | | | | | | | | | c | | | | | e
|
|
|
453
|
+d | | | | | | | | | | | | | | d | | | | |
|
|
|
454
|
+
|
|
|
455
|
+a | a | a | a | a | b
|
|
|
456
|
+c | c | c | c | c | b
|
|
|
457
|
+d | d | d | d | d | b
|
|
|
458
|
+ | | | | | b
|
|
|
459
|
+ | | | | | b
|
|
|
460
|
+
|
|
|
461
|
+a | a | a | a | a | | | b
|
|
|
462
|
+c | c | c | c | c | c | | b
|
|
|
463
|
+d | d | d | d | d | d | d | b
|
|
|
464
|
+ | | | | | | | b
|
|
|
465
|
+ | | | | | | | b
|
|
|
466
|
+
|
|
|
467
|
+a | a | a | a | a | | | | |
|
|
|
468
|
+b | | | | | c | c | c | c | c
|
|
|
469
|
+b | | | | | | | | |
|
|
|
470
|
+b | | | | | | | | |
|
|
|
471
|
+b | | | | | | | | |
|
|
|
472
|
+b | | | | | | | | |
|
|
|
473
|
+ | | | | | d | d | d | d | d
|
|
|
474
|
+
|
|
|
475
|
+
|
|
|
476
|
+*/
|
|
|
477
|
+
|
335
|
func printRes(res *domain.DataTable) {
|
478
|
func printRes(res *domain.DataTable) {
|
336
|
strBuilder := strings.Builder{}
|
479
|
strBuilder := strings.Builder{}
|
337
|
for i := range res.Data {
|
480
|
for i := range res.Data {
|