Skip to content

Commit

Permalink
Add WireVector name setter unit test (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyKorol1 authored Sep 12, 2023
1 parent 868e375 commit 20ca579
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/test_wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ def test_valid_names(self):
self.assertTrue(self.is_valid_str(' '))
self.assertTrue(self.is_valid_str('#$)(*&#@_+!#)('))

def check_name_setter(self, ns):
"""test name setter in wire.py.
Keyword arguments:
ns -- new name of WireVector to be set
"""
test = pyrtl.WireVector(1, 'test')
test.name = ns
self.assertTrue(test.name == ns)

def test_invalid_name_setter(self):
"""test invalid name data types and expect PyrtlError."""
with self.assertRaises(pyrtl.PyrtlError):
self.check_name_setter(24)
with self.assertRaises(pyrtl.PyrtlError):
self.check_name_setter(True)
with self.assertRaises(pyrtl.PyrtlError):
self.check_name_setter(3.14)

def test_valid_name_setter(self):
"""test string names and expect no error."""
self.check_name_setter('24')
self.check_name_setter(str(24))
self.check_name_setter('twenty_four')


class TestWireVectorFail(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 20ca579

Please sign in to comment.