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

Method test_2

testdata/ruby/dbLayerMapping.rb:97–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95 end
96
97 def test_2
98
99 lmap = RBA::LayerMap::new
100
101 lmap.map( "1/0", 0 )
102 assert_equal(lmap.is_mapped(RBA::LayerInfo::new(1, 0)), true)
103 assert_equal(lmap.is_mapped(RBA::LayerInfo::new(1, 1)), false)
104 assert_equal(lmap.is_mapped(RBA::LayerInfo::new(2, 2)), false)
105 lmap.map( "2/2", 0 )
106 assert_equal(lmap.is_mapped(RBA::LayerInfo::new(2, 2)), true)
107 lmap.map( "10/2", 0 )
108 assert_equal( lmap.mapping_str(0), "1/0;2/2;10/2" )
109
110 lmap.map( "3/2", 1 )
111 lmap.map( "2/2", 1 )
112 lmap.map( "4/2", 1 )
113 lmap.map( "1/2", 1 )
114 lmap.map( "0/0", 1 )
115 assert_equal( lmap.mapping_str(1), "0/0;1-4/2" ) # could be "0/0;1-4/2" as well ...
116
117 lmap.map( RBA::LayerInfo::new(2, 2), RBA::LayerInfo::new(4, 4), 2 )
118 lmap.map( RBA::LayerInfo::new(0, 1), 2 )
119 assert_equal( lmap.mapping_str(2), "0/1;2-4/2-4" )
120
121 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(2, 4)), true )
122 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(0, 0)), true )
123 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(0, 100)), false )
124
125 assert_equal( lmap.logical(RBA::LayerInfo::new(2, 4)), 2 )
126 assert_equal( lmap.logical(RBA::LayerInfo::new(4, 2)), 2 )
127 assert_equal( lmap.logical(RBA::LayerInfo::new(1, 2)), 1 )
128 assert_equal( lmap.logical(RBA::LayerInfo::new(0, 0)), 1 )
129 assert_equal( lmap.logical(RBA::LayerInfo::new(100, 0)), -1 )
130 assert_equal( lmap.logical(RBA::LayerInfo::new(10, 2)), 0 )
131 assert_equal( lmap.logical(RBA::LayerInfo::new(1, 0)), 0 )
132
133 assert_equal( lmap.mapping(2).to_s, "2/2" )
134 assert_equal( lmap.mapping(1).to_s, "1/2" )
135 assert_equal( lmap.mapping(0).to_s, "10/2" )
136
137 lmap2 = lmap.dup
138
139 lmap.clear
140 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(2, 4)), false )
141 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(0, 0)), false )
142 assert_equal( lmap.is_mapped?(RBA::LayerInfo::new(0, 100)), false )
143
144 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(2, 4)), true )
145 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(0, 0)), true )
146 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(0, 100)), false )
147
148 assert_equal( lmap2.mapping(0).to_s, "10/2" )
149
150 lmap2.assign( lmap )
151 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(2, 4)), false )
152 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(0, 0)), false )
153 assert_equal( lmap2.is_mapped?(RBA::LayerInfo::new(0, 100)), false )
154

Callers

nothing calls this directly

Calls 11

mapping_strMethod · 0.80
logicalMethod · 0.80
mappingMethod · 0.80
mmapMethod · 0.80
mapMethod · 0.45
is_mappedMethod · 0.45
to_sMethod · 0.45
dupMethod · 0.45
clearMethod · 0.45
assignMethod · 0.45
unmapMethod · 0.45

Tested by

no test coverage detected