| 32 | |
| 33 | # Shapes |
| 34 | def test_7_Layout |
| 35 | |
| 36 | shapes = RBA::Shapes::new |
| 37 | |
| 38 | assert_equal(shapes.cell == nil, true) |
| 39 | assert_equal(shapes.layout == nil, true) |
| 40 | |
| 41 | ly = RBA::Layout::new |
| 42 | |
| 43 | ci1 = ly.add_cell( "c1" ) |
| 44 | ci2 = ly.add_cell( "c2" ) |
| 45 | |
| 46 | linfo = RBA::LayerInfo::new |
| 47 | linfo.layer = 16 |
| 48 | linfo.datatype = 1 |
| 49 | lindex = ly.insert_layer( linfo ) |
| 50 | |
| 51 | linfo = RBA::LayerInfo::new |
| 52 | linfo.layer = 16 |
| 53 | linfo.datatype = 2 |
| 54 | ldummy = ly.insert_layer( linfo ) |
| 55 | |
| 56 | c1 = ly.cell( ci1 ) |
| 57 | c2 = ly.cell( ci2 ) |
| 58 | |
| 59 | c1.shapes( lindex ).insert( RBA::Box::new( 10, -10, 50, 40 ) ) |
| 60 | c1.shapes( lindex ).insert( RBA::Box::new( 100, -10, 150, 40 ) ) |
| 61 | c1.shapes( lindex ).insert( RBA::Box::new( 200, -10, 250, 40 ) ) |
| 62 | |
| 63 | shapes = c1.shapes( lindex ) |
| 64 | |
| 65 | assert_equal(shapes.cell == c1, true) |
| 66 | assert_equal(shapes.layout == ly, true) |
| 67 | |
| 68 | arr = [] |
| 69 | shapes.each( RBA::Shapes::SAll ) { |s| arr.push( s.box.to_s ) } |
| 70 | assert_equal( arr, ["(10,-10;50,40)", "(100,-10;150,40)", "(200,-10;250,40)"] ) |
| 71 | |
| 72 | arr = [] |
| 73 | shapes.each( RBA::Shapes::SAll ) { |s| arr.push( s.bbox.to_s ) } |
| 74 | assert_equal( arr, ["(10,-10;50,40)", "(100,-10;150,40)", "(200,-10;250,40)"] ) |
| 75 | |
| 76 | arr = [] |
| 77 | shapes.each( RBA::Shapes::SAll ) { |s| arr.push( s.area ) } |
| 78 | assert_equal( arr, [2000, 2500, 2500] ) |
| 79 | |
| 80 | arr = [] |
| 81 | shapes.each( RBA::Shapes::SAll ) { |s| arr.push( s.perimeter ) } |
| 82 | assert_equal( arr, [180, 200, 200] ) |
| 83 | |
| 84 | arr = [] |
| 85 | shapes.each { |s| arr.push( s.box.to_s ) } |
| 86 | assert_equal( arr, ["(10,-10;50,40)", "(100,-10;150,40)", "(200,-10;250,40)"] ) |
| 87 | |
| 88 | arr = [] |
| 89 | shapes.each( RBA::Shapes::SBoxes ) { |s| arr.push( s.box.to_s ) } |
| 90 | assert_equal( arr, ["(10,-10;50,40)", "(100,-10;150,40)", "(200,-10;250,40)"] ) |
| 91 |
nothing calls this directly
no test coverage detected