MCPcopy Create free account
hub / github.com/KLayout/klayout / test_1_Edge

Method test_1_Edge

testdata/ruby/dbEdgeTest.rb:150–263  ·  view source on GitHub ↗

Edge basics

Source from the content-addressed store, hash-verified

148
149 # Edge basics
150 def test_1_Edge
151
152 a = RBA::Edge::new
153 assert_equal( a.to_s, "(0,0;0,0)" )
154 assert_equal( a.is_degenerate?, true )
155
156 b = a
157 a = RBA::Edge::new( RBA::Point::new( -1, 2 ), RBA::Point::new( 15, -7 ) )
158 assert_equal( a.to_s, "(-1,2;15,-7)" )
159 assert_equal( RBA::Edge::from_s(a.to_s).to_s, a.to_s )
160 assert_equal( RBA::Edge::from_bytes(a.to_bytes).to_s, a.to_s )
161 assert_equal( (a*2).to_s, "(-2,4;30,-14)" )
162 d = RBA::DEdge::new( a )
163 assert_equal( d.to_s, "(-1,2;15,-7)" )
164 assert_equal( a.p1.to_s, "-1,2" )
165 assert_equal( a.p2.to_s, "15,-7" )
166 assert_equal( a.x1, -1 )
167 assert_equal( a.y1, 2 )
168 assert_equal( a.x2, 15 )
169 assert_equal( a.y2, -7 )
170 assert_equal( a.dx, 16 )
171 assert_equal( a.dy, -9 )
172 assert_equal( a.dx_abs, 16 )
173 assert_equal( a.dy_abs, 9 )
174 assert_equal( a.d.to_s, "16,-9" )
175 assert_equal( a.is_degenerate?, false )
176
177 c = a.dup;
178 assert_equal( a == c, true )
179 assert_equal( a == b, false )
180 assert_equal( a != c, false )
181 assert_equal( a != b, true )
182
183 aa = a.dup
184 a.move( RBA::Point::new( 1, 2 ) )
185 assert_equal( a.to_s, "(0,4;16,-5)" )
186 assert_equal( a.ortho_length, 25 )
187
188 aa.move( 1, 2 )
189 assert_equal( aa.to_s, "(0,4;16,-5)" )
190 assert_equal( aa.ortho_length, 25 )
191 aa.p1 = RBA::Point::new( 1, 5 )
192 assert_equal( aa.to_s, "(1,5;16,-5)" )
193 aa.p2 = RBA::Point::new( 2, 6 )
194 assert_equal( aa.to_s, "(1,5;2,6)" )
195 aa.x1 = -1
196 assert_equal( aa.to_s, "(-1,5;2,6)" )
197 aa.x2 = -2
198 assert_equal( aa.to_s, "(-1,5;-2,6)" )
199 aa.y1 = -5
200 assert_equal( aa.to_s, "(-1,-5;-2,6)" )
201 aa.y2 = -6
202 assert_equal( aa.to_s, "(-1,-5;-2,-6)" )
203
204 assert_equal( a == c.moved( RBA::Point::new( 1, 2 ) ), true )
205 assert_equal( a == c.moved( 1, 2 ), true )
206
207 a = RBA::Edge::new( RBA::Point::new( -1, 2 ), RBA::Point::new( 5, 2 ) )

Callers

nothing calls this directly

Calls 15

y1Method · 0.80
x2Method · 0.80
dxMethod · 0.80
dyMethod · 0.80
intersection_pointMethod · 0.80
crossing_pointMethod · 0.80
to_sMethod · 0.45
from_bytesMethod · 0.45
to_bytesMethod · 0.45
p1Method · 0.45
p2Method · 0.45
x1Method · 0.45

Tested by

no test coverage detected