-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautolayout_options_test.go
73 lines (67 loc) · 2.69 KB
/
autolayout_options_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package autog
import (
"testing"
"github.com/nulab/autog/internal/graph"
"github.com/nulab/autog/internal/phase1"
"github.com/nulab/autog/internal/phase2"
"github.com/nulab/autog/internal/phase3"
"github.com/nulab/autog/internal/phase4"
"github.com/nulab/autog/internal/phase5"
"github.com/stretchr/testify/assert"
)
func TestOptions(t *testing.T) {
// set some random options that are different from the defaults
opts := testOptions(
WithCycleBreaking(CycleBreakingDepthFirst),
WithLayering(LayeringLongestPath),
WithOrdering(OrderingNoop),
WithPositioning(PositioningVAlign),
WithEdgeRouting(EdgeRoutingStraight),
WithNetworkSimplexThoroughness(30),
WithLayerSpacing(75.5),
WithNodeSpacing(10.0),
WithBrandesKoepfLayout(2),
WithNodeFixedSize(100.0, 100.0),
WithNodeSize(map[string]graph.Size{"N1": {W: 20, H: 20}}),
WithVirtualNodeFixedSize(50.0),
WithNonDeterministicGreedyCycleBreaker(),
)
assert.Equal(t, phase1.DepthFirst, opts.p1)
assert.Equal(t, phase2.LongestPath, opts.p2)
assert.Equal(t, phase3.NoOrdering, opts.p3)
assert.Equal(t, phase4.VerticalAlign, opts.p4)
assert.Equal(t, phase5.Straight, opts.p5)
assert.Equal(t, uint(30), opts.params.NetworkSimplexThoroughness)
assert.Equal(t, graph.OptionNsBalanceV, opts.params.NetworkSimplexBalance)
assert.Equal(t, 75.5, opts.params.LayerSpacing)
assert.Equal(t, 10.0, opts.params.NodeSpacing)
assert.Equal(t, 2, opts.params.BrandesKoepfLayout)
assert.Nil(t, opts.monitor)
assert.NotNil(t, opts.params.NodeFixedSizeFunc)
assert.NotNil(t, opts.params.NodeSizeFunc)
assert.Equal(t, 50.0, opts.params.VirtualNodeFixedSize)
assert.True(t, opts.params.GreedyCycleBreakerRandomNodeChoice)
assert.Equal(t, CycleBreakingGreedy, phase1.Greedy)
assert.Equal(t, CycleBreakingDepthFirst, phase1.DepthFirst)
assert.Equal(t, LayeringLongestPath, phase2.LongestPath)
assert.Equal(t, LayeringNetworkSimplex, phase2.NetworkSimplex)
assert.Equal(t, OrderingNoop, phase3.NoOrdering)
assert.Equal(t, OrderingWMedian, phase3.WMedian)
assert.Equal(t, PositioningNoop, phase4.NoPositioning)
assert.Equal(t, PositioningVAlign, phase4.VerticalAlign)
assert.Equal(t, PositioningNetworkSimplex, phase4.NetworkSimplex)
assert.Equal(t, PositioningBrandesKoepf, phase4.BrandesKoepf)
assert.Equal(t, PositioningSinkColoring, phase4.SinkColoring)
assert.Equal(t, PositioningPackRight, phase4.PackRight)
assert.Equal(t, EdgeRoutingNoop, phase5.NoRouting)
assert.Equal(t, EdgeRoutingStraight, phase5.Straight)
assert.Equal(t, EdgeRoutingPolyline, phase5.Polyline)
assert.Equal(t, EdgeRoutingOrtho, phase5.Ortho)
}
func testOptions(opts ...Option) options {
layoutOpts := defaultOptions
for _, opt := range opts {
opt(&layoutOpts)
}
return layoutOpts
}