Skip to content

Commit

Permalink
Merge pull request #32 from nulab/dev-2/unit-testing-coverage
Browse files Browse the repository at this point in the history
Unit testing coverage
  • Loading branch information
vibridi authored Oct 16, 2024
2 parents 3cd0b18 + d51a3ea commit 6a9799e
Show file tree
Hide file tree
Showing 43 changed files with 1,335 additions and 1,152 deletions.
3 changes: 1 addition & 2 deletions autolayout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/nulab/autog/graph"
ig "github.com/nulab/autog/internal/graph"
"github.com/nulab/autog/internal/graph/connected"
imonitor "github.com/nulab/autog/internal/monitor"
"github.com/nulab/autog/internal/processor"
"github.com/nulab/autog/internal/processor/postprocessor"
Expand Down Expand Up @@ -55,7 +54,7 @@ func Layout(source graph.Source, opts ...Option) graph.Layout {
shift := 0.0

// process each connected components and collect results into the same layout output
for _, g := range connected.Components(G) {
for _, g := range G.ConnectedComponents() {
if len(g.Nodes) == 0 {
panic("autog: connected sub-graph node set is empty: this might be a bug")
}
Expand Down
1 change: 1 addition & 0 deletions autolayout_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var defaultOptions = options{
NetworkSimplexThoroughness: 28,
NetworkSimplexMaxIterFactor: 0,
NetworkSimplexBalance: graph.OptionNsBalanceV,
VirtualNodeFixedSize: 0.0,
WMedianMaxIter: 24,
NetworkSimplexAuxiliaryGraphWeightFactor: 4,
LayerSpacing: 150.0,
Expand Down
6 changes: 6 additions & 0 deletions autolayout_options_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ func WithNodeFixedSize(w, h float64) Option {
}
}

func WithVirtualNodeFixedSize(n float64) Option {
return func(o *options) {
o.params.VirtualNodeFixedSize = n
}
}

func WithBrandesKoepfLayout(i int) Option {
return func(o *options) {
o.params.BrandesKoepfLayout = i
Expand Down
4 changes: 4 additions & 0 deletions autolayout_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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),
Expand All @@ -25,10 +26,12 @@ func TestOptions(t *testing.T) {
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)
Expand All @@ -40,6 +43,7 @@ func TestOptions(t *testing.T) {
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)
Expand Down
Loading

0 comments on commit 6a9799e

Please sign in to comment.