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

Method test_1_Box

testdata/ruby/dbBoxTest.rb:253–364  ·  view source on GitHub ↗

Box basics

Source from the content-addressed store, hash-verified

251
252 # Box basics
253 def test_1_Box
254
255 a = RBA::Box::new( 20 )
256 assert_equal( a.to_s, "(-10,-10;10,10)" )
257
258 a = RBA::Box::new( 21 )
259 assert_equal( a.to_s, "(-10,-10;10,10)" )
260
261 a = RBA::Box::new( 20, 40 )
262 assert_equal( a.to_s, "(-10,-20;10,20)" )
263
264 a = RBA::Box::new( -10, 21, 11, 17 )
265 assert_equal( a.to_s, "(-10,17;11,21)" )
266 assert_equal( RBA::Box::from_s(a.to_s).to_s, a.to_s )
267 assert_equal( RBA::Box::from_bytes(a.to_bytes).to_s, a.to_s )
268 assert_equal( (a*2).to_s, "(-20,34;22,42)" )
269
270 b = a
271 a = a.moved( RBA::Point::new( 1, 1 ))
272
273 assert_equal( a.to_s, "(-9,18;12,22)" )
274 a = b.moved( 1, -1 )
275 assert_equal( a.to_s, "(-9,16;12,20)" )
276 a = b.moved( dy: 1 )
277 assert_equal( a.to_s, "(-10,18;11,22)" )
278 a = b.moved( dx: 1 )
279 assert_equal( a.to_s, "(-9,17;12,21)" )
280
281 a = b.dup
282 a.move( 1, -1 )
283 assert_equal( a.to_s, "(-9,16;12,20)" )
284
285 a = b.dup
286 a.move( RBA::Point::new( 1, 1 ))
287 assert_equal( a.to_s, "(-9,18;12,22)" )
288
289 assert_equal( b.to_s, "(-10,17;11,21)" )
290
291 assert_equal( a == b, false )
292 assert_equal( a != b, true )
293 assert_equal( a != a, false )
294 assert_equal( a == a, true )
295 assert_equal( b != b, false )
296 assert_equal( b == b, true )
297
298 a.move( RBA::Point::new(1, 1) ).move( RBA::Point::new(-2, 2) )
299 assert_equal( a.to_s, "(-10,21;11,25)" )
300
301 aa = a.dup
302 a.enlarge( 2 )
303 assert_equal( a.to_s, "(-12,19;13,27)" )
304 a.enlarge( -2 )
305 assert_equal( aa.enlarged( 2 ).to_s, "(-12,19;13,27)" )
306
307 a.enlarge( RBA::Point::new(1, -1) )
308 assert_equal( a.to_s, "(-11,22;12,24)" )
309
310 aa = a.dup

Callers

nothing calls this directly

Calls 15

centerMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
bottomMethod · 0.80
topMethod · 0.80
worldMethod · 0.80
to_sMethod · 0.45
from_bytesMethod · 0.45
to_bytesMethod · 0.45
movedMethod · 0.45
dupMethod · 0.45
moveMethod · 0.45

Tested by

no test coverage detected