|
| 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