Skip to content

Commit 5941b69

Browse files
committed
SnakePattern tests
1 parent 6aa7636 commit 5941b69

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

test/lattices.jl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,43 @@ end
201201
@test allunique(NNN)
202202
end
203203
end
204+
205+
@testset "SnakePattern" begin
206+
base_lattice = FiniteCylinder(4, 16)
207+
base_V = vertices(base_lattice)
208+
base_NN = nearest_neighbours(base_lattice)
209+
210+
lattice = SnakePattern(base_lattice, identity)
211+
212+
V = vertices(lattice)
213+
@test all(zip(V, base_V)) do (x, y)
214+
return linearize_index(x) == linearize_index(y)
215+
end
216+
217+
@test length(base_lattice) == length(lattice)
218+
@test lattice[1, 1] == first(V)
219+
220+
NN = nearest_neighbours(lattice)
221+
@test all(zip(NN, base_NN)) do (x, y)
222+
return linearize_index.(Tuple(x)) ==
223+
linearize_index.(Tuple(y))
224+
end
225+
226+
pattern(i) = length(lattice) - i + 1
227+
lattice = SnakePattern(base_lattice, pattern)
228+
229+
V = vertices(lattice)
230+
@test all(zip(V, base_V)) do (x, y)
231+
return linearize_index(x) == pattern(linearize_index(y))
232+
end
233+
234+
@test length(base_lattice) == length(lattice)
235+
@test lattice[1, 1] == first(V)
236+
237+
base_NN = nearest_neighbours(base_lattice)
238+
NN = nearest_neighbours(lattice)
239+
@test all(zip(NN, base_NN)) do (x, y)
240+
return linearize_index.(Tuple(x)) ==
241+
pattern.(linearize_index.(Tuple(y)))
242+
end
243+
end

0 commit comments

Comments
 (0)