-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_pyspice.py
executable file
·62 lines (53 loc) · 1.71 KB
/
test_pyspice.py
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
#!/usr/bin/python
#@+leo-ver=4
#@+node:@file test_pyspice.py
#@@first
#@@language python
#@@tabwidth -4
"""Unit test stuff for pyspice.py"""
__author__ = "Dan White ([email protected])"
__version__ = "$Revision: 1.3 $"
__date__ = "$Date: 2004/05/05 21:57:20 $"
__copyright__ = "Copyright (c) 2007 Dan White"
__license__ = "GPL"
import pyspice
import unittest
from decimal import Decimal as D
#@+others
#@+node:unit conversions
class unitConversion(unittest.TestCase):
"""Tests conversion between SPICE string and Decimal number."""
knownValues = ( ('5T', D('5.0e12')),
('5G', D('5.0e9')),
('10MEG', D('10.0e6')),
('342x', D('342.0e6')),
('15k', D('15.0e3')),
('1MIL', D('25.4e-6')),
('435M', D('435e-3')),
('1U', D('1.0e-6')),
('67N', D('67.0e-9')),
('4P', D('4.0e-12')),
('3F', D('3.0e-15')) )
badValues = ( 'like' )
def test_unit_knownValues(self):
"""unit() should give known result with known input"""
for s, num in self.knownValues:
result = pyspice.unit(s)
self.assertEqual(num,result)
def test_unit_badValues(self):
"""unit() should fail with bad input"""
for s in self.badValues:
self.assertRaises(pyspice.BadUnitError, pyspice.unit, s)
#@-node:unit conversions
#@+node:netlist parsing
class netlistParsing(unittest.TestCase):
"""Tests the netlist parser"""
pass
#@nonl
#@-node:netlist parsing
#@-others
if __name__ == "__main__":
unittest.main()
#@nonl
#@-node:@file test_pyspice.py
#@-leo