From 1ecd7759c7a3e06e476903ff9a11a268d27435ae Mon Sep 17 00:00:00 2001 From: vipul-09 Date: Sun, 12 Jul 2026 22:21:28 +0530 Subject: [PATCH] Add unit tests for wire module --- unit_tests/test_wire.py | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 unit_tests/test_wire.py diff --git a/unit_tests/test_wire.py b/unit_tests/test_wire.py new file mode 100644 index 000000000..7e62c8ef8 --- /dev/null +++ b/unit_tests/test_wire.py @@ -0,0 +1,62 @@ +import sys +from io import StringIO + +sys.path.append( + "src/converter/schematic_converters/lib/PythonLib" +) + +import wire + + +def test_wire_constructor(): + w = wire.Wire(1, 2, 3, 4) + + assert w.x1 == 1 + assert w.y1 == 2 + assert w.x2 == 3 + assert w.y2 == 4 + + +def test_connector_constructor(): + c = wire.Connector(5, 6) + + assert c.x == 5 + assert c.y == 6 + + +def test_parse_wire(): + wires = [] + + stream = StringIO( + "s 1 2 3 4 0\n" + "@\n" + ) + + wire.parseWire(stream, wires) + + assert len(wires) == 1 + + w = wires[0] + + assert w.x1 == 10 + assert w.y1 == 20 + assert w.x2 == 30 + assert w.y2 == 40 + + +def test_parse_conn(): + conns = [] + + stream = StringIO( + "j 7 8\n" + "@\n" + ) + + wire.parseConn(stream, conns) + + assert len(conns) == 1 + + c = conns[0] + + assert c.x == 70 + assert c.y == 80 \ No newline at end of file