Skip to content

Commit a39c78f

Browse files
committed
Add unit test for PieceWiseLinearVoltageSource.
1 parent d15c078 commit a39c78f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ install:
88

99
script:
1010
- python unit-test/Spice/test_BasicElement.py
11+
- python unit-test/Spice/test_HighLevelElement.py
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
####################################################################################################
2+
#
3+
# PySpice - A Spice Package for Python
4+
# Copyright (C) 2014 Fabrice Salvaire
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
####################################################################################################
20+
21+
####################################################################################################
22+
23+
import unittest
24+
25+
####################################################################################################
26+
27+
from PySpice.Spice.HighLevelElement import *
28+
from PySpice.Spice.Netlist import Circuit
29+
from PySpice.Unit import *
30+
31+
####################################################################################################
32+
33+
class TestHighLevelElement(unittest.TestCase):
34+
35+
##############################################
36+
37+
def _test_spice_declaration(self, element, spice_declaration):
38+
39+
self.assertEqual(str(element), spice_declaration)
40+
41+
##############################################
42+
43+
def test(self):
44+
45+
self._test_spice_declaration(PieceWiseLinearVoltageSource(Circuit(''), 'inpwl1', '1', '0',
46+
values=[(0, 0), (10@u_ms, 0), (11@u_ms, 5@u_V), (20@u_ms, 5@u_V)]),
47+
'Vinpwl1 1 0 PWL(0s 0V 10ms 0V 11ms 5V 20ms 5V r=0s td=0.0s)')
48+
49+
####################################################################################################
50+
51+
if __name__ == '__main__':
52+
53+
unittest.main()

0 commit comments

Comments
 (0)