Skip to content
Snippets Groups Projects
Commit c6d6d8b5 authored by angloth's avatar angloth
Browse files

Fix some errors with graph id tests

parent 6fff2339
No related branches found
No related tags found
1 merge request!2Integrated ID system, traversing and som signal tests
Pipeline #10009 passed
......@@ -16,4 +16,8 @@ def graph_ids():
GraphID("ÅÄÖ", 2), GraphID("", 3), \
GraphID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4)]
@pytest.fixture
def graph_id_generator():
return GraphIDGenerator()
......@@ -11,24 +11,26 @@ from b_asic.graph_id import GraphID
import pytest
def test_create_graph_id():
"""
Tests creation
"""Tests creation of graph ID objects."""
graph_id = GraphID("add", 1)
assert graph_id.graph_id_type == "add"
assert graph_id.graph_id_number == 1
def test_create_graph_id_empty_string():
graph_id2 = GraphID("", 2)
assert graph_id2.graph_id_type == ""
assert graph_id2.graph_id_number == 2
def test_create_graph_id_long_string():
graph_id3 = GraphID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3)
assert graph_id3.graph_id_type == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
assert graph_id3.graph_id_number == 3
def test_graph_id_str(graph_ids):
"""Test the str() function of graph ids."""
assert str(graph_ids[0]) == "add1"
assert str(graph_ids[1]) == "add2"
assert str(graph_ids[2]) == "sig1"
......@@ -39,6 +41,7 @@ def test_graph_id_str(graph_ids):
assert str(graph_ids[7]) == "ABCDEFGHIJKLMNOPQRSTUVWXYZ4"
def test_graph_id_repr(graph_ids):
"""Test the repr() function of graph ids."""
assert repr(graph_ids[0]) == "add1"
assert repr(graph_ids[1]) == "add2"
assert repr(graph_ids[2]) == "sig1"
......@@ -49,6 +52,7 @@ def test_graph_id_repr(graph_ids):
assert repr(graph_ids[7]) == "ABCDEFGHIJKLMNOPQRSTUVWXYZ4"
def test_graph_id_eq(graph_ids):
"""Test the equality of graph ids."""
assert graph_ids[0] == graph_ids[0]
assert graph_ids[0] != graph_ids[1]
assert graph_ids[2] == graph_ids[3]
......
"""
B-ASIC test suite for graph id generator.
"""
from b_asic.graph_id import GraphIDGenerator, GraphID
import pytest
def test_empty_string_generator(graph_id_generator):
"""Test the graph id generator for an empty string type."""
assert graph_id_generator.get_next_id("") == GraphID("", 1)
assert graph_id_generator.get_next_id("") == GraphID("", 2)
def test_normal_string_generator(graph_id_generator):
""""Test the graph id generator for a normal string type."""
assert graph_id_generator.get_next_id("add") == GraphID("add", 1)
assert graph_id_generator.get_next_id("add") == GraphID("add", 2)
def test_different_strings_generator(graph_id_generator):
"""Test the graph id generator for different strings."""
assert graph_id_generator.get_next_id("sub") == GraphID("sub", 1)
assert graph_id_generator.get_next_id("mul") == GraphID("mul", 1)
assert graph_id_generator.get_next_id("sub") == GraphID("sub", 2)
assert graph_id_generator.get_next_id("mul") == GraphID("mul", 2)
\ No newline at end of file
......@@ -13,8 +13,8 @@ def test_connect_one_signal_to_port(signal):
assert port.signal() == signal
def test_change_port_signal():
source = SignalSource(Addition(0), 1)
dest = SignalDestination(Addition(1),2)
source = SignalSource(Addition, 1)
dest = SignalDestination(Addition,2)
signal1 = Signal(1, source, dest)
signal2 = Signal(2, source, dest)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment