-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtests.rb
167 lines (135 loc) · 6.7 KB
/
tests.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# LICENSE file for details.
#
# DESCRIPTION: Cadence tech file importer - tests
# Force load of import_tf.rb
load File.join(File.dirname(__FILE__), "import_tf.rb")
require 'test/unit'
require 'test/unit/ui/console/testrunner'
module TechfileToKLayout
class TFImport_TestClass < Test::Unit::TestCase
def test_read1
begin
lv = RBA::LayoutView::new
tf_file = File.join(File.dirname(__FILE__), "testdata_1", "techfile.tf")
TechfileToKLayout.import_techfile(lv, tf_file)
lp = []
li = lv.begin_layers
while !li.at_end?
lp << [
li.current.fill_color,
li.current.frame_color,
li.current.dither_pattern,
li.current.line_style,
li.current.name,
li.current.source,
li.current.width,
li.current.valid?,
li.current.xfill?
]
li.next
end
ensure
lv._destroy
end
ref = [
# fill color frame color dp ls name source w valid xfill
[ 0xffd9e6ff, 0xffd9e6ff, 62, 9, 'NBL.drawing - 2/0', '2/0@1', 1, true, false ],
[ 0xffffbff2, 0xffffbff2, 61, 8, 'PBL.drawing - 6/0', '6/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 53, 8, 'PW.drawing - 1/0', '1/0@1', 1, true, false ],
[ 0xff39bfff, 0xff39bfff, 47, 13, 'NW.drawing - 12/0', '12/0@1', 1, true, false ],
[ 0xffe61f0d, 0xffe61f0d, 53, 8, 'PTOP.drawing - 25/0', '25/0@1', 1, true, false ],
[ 0xffcccccc, 0xffcccccc, 47, 16, 'AA.drawing - 54/0', '54/0@1', 3, true, false ],
[ 0xffe38b00, 0xffe38b00, 49, 8, 'VTH.drawing - 91/0', '91/0@1', 1, true, false ],
[ 0xffe38b00, 0xffe38b00, 48, 8, 'P1.drawing - 30/0', '30/0@1', 1, true, false ],
[ 0xff39bfff, 0xff39bfff, 53, 0, 'NHV.drawing - 23/0', '23/0@1', 0, true, false ],
[ 0xffe38b00, 0xffe38b00, 56, 8, 'PHV.drawing - 24/0', '24/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 54, 8, 'SP.drawing - 3/0', '3/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 1, 8, 'P2.drawing - 31/0', '31/0@1', 1, true, false ],
[ 0xff333399, 0xff333399, 47, 12, 'NP.drawing - 98/0', '98/0@1', 1, true, false ],
[ 0xff802626, 0xff802626, 47, 8, 'PP.drawing - 97/0', '97/0@1', 1, true, false ],
[ 0xff9900e6, 0xff9900e6, 1, 15, 'C1.drawing - 9/0', '9/0@1', 3, true, true ],
[ 0xff268c6b, 0xff268c6b, 47, 8, 'M1.drawing - 10/0', '10/0@1', 1, true, false ],
[ 0xff8c8ca6, 0xff8c8ca6, 59, 8, 'PA.drawing - 11/0', '11/0@1', 1, true, false ],
[ 0xffe38b00, 0xffffffff, 48, 14, 'P1.net - 102/0', '102/0@1', 1, false, false ],
[ 0xffbf4026, 0xffffffff, 1, 14, 'P2.net - 101/0', '101/0@1', 1, false, false ],
[ 0xff9900e6, 0xffffffff, 1, 14, 'C1.net - 104/0', '104/0@1', 1, false, true ],
[ 0xff268c6b, 0xffffffff, 47, 14, 'M1.net - 103/0', '103/0@1', 1, false, false ]
]
[ ref.size, lp.size ].max.times do |i|
assert_equal(ref[i].inspect, lp[i].inspect)
end
end
def test_read2
begin
lv = RBA::LayoutView::new
tf_file = File.join(File.dirname(__FILE__), "testdata_2", "techfile.tf")
TechfileToKLayout.import_techfile(lv, tf_file)
lp = []
li = lv.begin_layers
while !li.at_end?
lp << [
li.current.fill_color,
li.current.frame_color,
li.current.dither_pattern,
li.current.line_style,
li.current.name,
li.current.source,
li.current.width,
li.current.valid?,
li.current.xfill?
]
li.next
end
ensure
lv._destroy
end
ref = [
# fill color frame color dp ls name source w valid xfill
[ 0xffd9e6ff, 0xffd9e6ff, 62, 9, 'NBL.drawing - 2/0', '2/0@1', 1, true, false ],
[ 0xffffbff2, 0xffffbff2, 61, 8, 'PBL.drawing - 6/0', '6/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 53, 8, 'PW.drawing - 1/0', '1/0@1', 1, true, false ],
[ 0xff39bfff, 0xff39bfff, 47, 13, 'NW.drawing - 12/0', '12/0@1', 1, true, false ],
[ 0xffe61f0d, 0xffe61f0d, 53, 8, 'PTOP.drawing - 25/0', '25/0@1', 1, true, false ],
[ 0xffcccccc, 0xffcccccc, 47, 16, 'AA.drawing - 54/0', '54/0@1', 3, true, false ],
[ 0xffe38b00, 0xffe38b00, 49, 8, 'VTH.drawing - 91/0', '91/0@1', 1, true, false ],
[ 0xffe38b00, 0xffe38b00, 48, 8, 'P1.drawing - 30/0', '30/0@1', 1, true, false ],
[ 0xff39bfff, 0xff39bfff, 53, 0, 'NHV.drawing - 23/0', '23/0@1', 0, true, false ],
[ 0xffe38b00, 0xffe38b00, 56, 8, 'PHV.drawing - 24/0', '24/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 54, 8, 'SP.drawing - 3/0', '3/0@1', 1, true, false ],
[ 0xffbf4026, 0xffbf4026, 1, 8, 'P2.drawing - 31/0', '31/0@1', 1, true, false ],
[ 0xff333399, 0xff333399, 47, 12, 'NP.drawing - 98/0', '98/0@1', 1, true, false ],
[ 0xff802626, 0xff802626, 47, 8, 'PP.drawing - 97/0', '97/0@1', 1, true, false ],
[ 0xff9900e6, 0xff9900e6, 1, 15, 'C1.drawing - 9/0', '9/0@1', 3, true, true ],
[ 0xff268c6b, 0xff268c6b, 47, 8, 'M1.drawing - 10/0', '10/0@1', 1, true, false ],
[ 0xff8c8ca6, 0xff8c8ca6, 59, 8, 'PA.drawing - 11/1', '11/1@1', 1, true, false ],
[ 0xffe38b00, 0xffffffff, 48, 14, 'P1.net - 102/0', '102/0@1', 1, false, false ],
[ 0xffbf4026, 0xffffffff, 1, 14, 'P2.net - 101/0', '101/0@1', 1, false, false ],
[ 0xff9900e6, 0xffffffff, 1, 14, 'C1.net - 104/0', '104/0@1', 1, false, true ],
[ 0xff268c6b, 0xffffffff, 47, 14, 'M1.net - 113/0', '113/0@1', 1, false, false ]
]
[ ref.size, lp.size ].max.times do |i|
assert_equal(ref[i].inspect, lp[i].inspect)
end
end
end
# Runs the tests
class TestRunner < Test::Unit::UI::Console::TestRunner
def initialize(suite, *args)
super(suite, *args)
end
def test_started(name)
super
end
end
err = 0
self.constants.each do |c|
if c.to_s =~ /_TestClass$/
r = TestRunner::new(self.const_get(c), :output => $stdout).start
err += r.error_count + r.failure_count
end
end
err == 0 || $stderr.puts("Test(s) failed. See log for details")
end