Skip to content

Commit 8ad9b2a

Browse files
committed
add tests
1 parent deb109c commit 8ad9b2a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,21 @@ jagmesh_adj = jagmesh()
465465
@test ep[5][2] != [2]
466466
end
467467
end
468+
469+
@testset "Align" begin
470+
using NetworkLayout: AbstractLayout, @addcall
471+
@addcall struct Manual{Dim, Ptype} <: AbstractLayout{Dim, Ptype}
472+
positions :: Vector{Point{Dim, Ptype}}
473+
end
474+
NetworkLayout.layout(algo::Manual, ::AbstractMatrix) = copy(algo.positions)
475+
476+
g = Graph(2); add_edge!(g, 1, 2)
477+
pos = Align(Manual([Point2f(1, 2), Point2f(2, 3)]), 0.0)(g)
478+
@test all(r->abs(r[2])<1e-12, pos)
479+
@test norm(pos[1]-pos[2]) == norm(Point2f(1, 2)-Point2f(2, 3))
480+
481+
g = Graph(3); add_edge!(g, 1, 2); add_edge!(g, 2, 3); add_edge!(g, 3, 1)
482+
pos = Align(Manual([Point2f(0, 4), Point2f(-1, -2), Point2f(1, -2)]), 0.0)(g)
483+
@test pos [Point2f(4, 0), Point2f(-2, 1), Point2f(-2, -1)]
484+
end
468485
end

0 commit comments

Comments
 (0)