Skip to content

Commit 8072e36

Browse files
committed
Cleanup and more tests
1 parent fc59ffb commit 8072e36

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

docs/src/routes.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ end
102102
c = Cell("test")
103103
render!.(c, paths, GDSMeta())
104104
render!(c, channel_path, GDSMeta(2))
105-
save("straight_channel.svg", flatten(c); width=6inch, height=2inch)
105+
save("straight_channel.svg", flatten(c); width=6inch, height=2inch);
106+
nothing; # hide
106107
```
107108

108109
```@raw html
@@ -139,7 +140,8 @@ end
139140
c = Cell("test")
140141
render!.(c, paths, GDSMeta())
141142
render!(c, channel_path, GDSMeta(2))
142-
save("bspline_channel.svg", flatten(c); width=6inch, height=4inch)
143+
save("bspline_channel.svg", flatten(c); width=6inch, height=4inch);
144+
nothing; # hide
143145
```
144146

145147
```@raw html
@@ -174,7 +176,8 @@ end
174176
c = Cell("test")
175177
render!.(c, paths, GDSMeta())
176178
render!(c, channel_path, GDSMeta(2))
177-
save("compound_channel.svg", flatten(c); width=6inch, height=4inch)
179+
save("compound_channel.svg", flatten(c); width=6inch, height=4inch);
180+
nothing; # hide
178181
```
179182

180183
```@raw html

test/test_channels.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ end
160160
rule = transition_rules[1]
161161
paths = test_single_channel_reversals(rule, channel_segments[1], channel_styles[1])
162162
@test isempty(Intersect.intersections(paths...))
163+
c = Cell("test", nm)
164+
render!(c, paths[1], GDSMeta()) # No error
163165
end
164166
rule = transition_rules[2] # BSpline rule for all-angle transitions
165167
for segtype in channel_segments[2:end]
@@ -169,6 +171,20 @@ end
169171
end
170172
end
171173
end
174+
# Channel too short
175+
pa = Path(0.0nm, 0.0nm)
176+
straight!(pa, 100nm, Paths.Trace(0.1mm))
177+
ch = RouteChannel(pa)
178+
pa2 = Path(-0.1mm, 0mm)
179+
rule = Paths.SingleChannelRouting(
180+
ch,
181+
Paths.BSplineRouting(auto_curvature=true, auto_speed=true),
182+
50μm
183+
)
184+
route!(pa2, Point(0.1mm, 0.1mm), 0, rule, Paths.CPW(2nm, 2nm))
185+
c = Cell("test", nm)
186+
render!(c, pa2, GDSMeta()) # No error
187+
172188
## Schematic-level routing
173189
test_schematic_single_channel()
174190
end

test/test_render.jl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ end
209209
pa = Path{Float64}()
210210
straight!(pa, 20.0, Paths.Trace(x -> 2.0 * x))
211211
render!(c, pa)
212+
revsty = reverse(pa[1]).sty
213+
@test Paths.width(revsty, 0) == Paths.trace(pa[1].sty, 20)
214+
@test Paths.extent(revsty)(20) == 0.5 * Paths.width(pa[1].sty)(0)
212215
end
213216

214217
@testset "Straight, SimpleCPW" begin
@@ -228,6 +231,9 @@ end
228231
p(20.082731241720513, 1.7128648145206729),
229232
p(0.5197792270443984, -2.4453690018345142)
230233
]
234+
revsty = reverse(pa[1]).sty
235+
@test Paths.trace(revsty, 0) == Paths.trace(pa[1].sty, 20)
236+
@test Paths.trace(revsty, 20) == Paths.trace(pa[1].sty, 0)
231237

232238
c = Cell("main", pm2μm)
233239
pa = Path(μm2μm, α0=12°)
@@ -249,9 +255,14 @@ end
249255
] * 10^6
250256
end
251257

252-
# @testset "Straight, GeneralCPW" begin
253-
#
254-
# end
258+
@testset "Straight, GeneralCPW" begin
259+
c = Cell{Float64}("main")
260+
pa = Path(NoUnits, α0=12°)
261+
straight!(pa, 20.0, Paths.CPW(x -> 2 * x, x -> 3 * x))
262+
revsty = reverse(pa[1]).sty
263+
@test Paths.trace(revsty, 0) == Paths.trace(pa[1].sty, 20)
264+
@test Paths.trace(revsty, 20) == Paths.trace(pa[1].sty, 0)
265+
end
255266

256267
@testset "Turn, SimpleTrace" begin
257268
c = Cell{Float64}("main")
@@ -424,6 +435,9 @@ end
424435
p(50000.0nm, -4000.0nm),
425436
p(0.0nm, -5000.0nm)
426437
]
438+
revsty = reverse(pa[1]).sty
439+
@test Paths.trace(revsty, 0.0μm) == Paths.trace(pa[1].sty, 50.0μm)
440+
@test Paths.trace(revsty, 50.0μm) == Paths.trace(pa[1].sty, 0.0μm)
427441

428442
@test_throws "length" split(Paths.TaperCPW(10.0μm, 6.0μm, 8.0μm, 2.0μm), 10μm)
429443

@@ -447,6 +461,7 @@ end
447461
pa = Path(μm)
448462
turn!(pa, π / 2, 20μm, Paths.TaperTrace(10μm, 20μm))
449463
render!(c, pa, GDSMeta(0))
464+
@test Paths.trace(pa[1].sty, 0μm) == 10μm
450465

451466
@test (elements(c)[1]).p[1] p(0.0nm, -5000.0nm)
452467
@test (elements(c)[1]).p[end] p(0.0nm, 5000.0nm)
@@ -556,6 +571,9 @@ end
556571
straight!(pa, 20μm, Paths.Trace(15μm))
557572
straight!(pa, 20μm, Paths.Trace(20μm))
558573
simplify!(pa)
574+
revsty = reverse(pa[1]).sty
575+
@test Paths.trace(revsty, 10μm) == Paths.trace(pa[1].sty, 50μm)
576+
@test Paths.trace(revsty, 50μm) == Paths.trace(pa[1].sty, 10μm)
559577

560578
pa2 = split(pa[1], 20μm)
561579
@test length(pa2) == 2

0 commit comments

Comments
 (0)