Port implements Serializable { @Override public String toString() { StringBuilder sb = new StringBuilder(100); sb.append(name).append(": "); sb.append(direction).append(" ").append(getTypeName()); if (isVector()) { sb.append("(").append(from).append(" "); sb.append(getDirectionName()).append(" "); sb.append(to).append(")"); } return sb.toString(); } Port();  Port(String name, PortDirection direction);  Port(String name, PortDirection direction, int from, int to);  Port(Port clone); String getName(); void setName(String name); PortDirection getDirection(); void setDirection(PortDirection direction); Integer getFrom(); void setFrom(Integer from); Integer getTo(); void setTo(Integer to); boolean isIN(); boolean isOUT(); boolean isScalar(); boolean isVector(); boolean isDOWNTO(); boolean isTO(); String getTypeName(); String getDirectionName(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final String TYPE_STD_LOGIC; static final String TYPE_STD_LOGIC_VECTOR; static final String DIRECTION_DOWNTO; static final String DIRECTION_TO; }
@Test public void testToString() { port.setName("port_name"); port.setDirection(PortDirection.IN); port.setFrom(null); port.setTo(null); toStringPrint(port); assertEquals("port_name: IN STD_LOGIC", port.toString()); port.setFrom(4); port.setTo(1); toStringPrint(port); assertEquals("port_name: IN STD_LOGIC_VECTOR(4 DOWNTO 1)", port .toString()); port.setTo(null); toStringPrint(port); assertEquals("port_name: IN STD_LOGIC_VECTOR", port.toString()); port.setTo(7); toStringPrint(port); assertEquals("port_name: IN STD_LOGIC_VECTOR(4 TO 7)", port.toString()); }