This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
sp-04/test/ch/usi/inf/sp/graph/NodeTest.java
github-classroom[bot] 74a433f602
Initial commit
2023-10-18 19:57:49 +00:00

42 lines
No EOL
980 B
Java

package ch.usi.inf.sp.graph;
import ch.usi.inf.sp.graph.Edge;
import ch.usi.inf.sp.graph.Node;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class NodeTest {
@Test
void newNode() {
Node n = new Node();
assertEquals(0, n.getInEdges().size());
assertEquals(0, n.getOutEdges().size());
}
@Test
void toStringTest() {
Node n = new Node();
assertEquals('"'+n.getClass().getName()+"@"+Integer.toHexString(n.hashCode())+'"', n.toString());
}
@Test
void addInEdge() {
Node n = new Node();
Edge e = new Edge();
n.addInEdge(e);
assertEquals(1, n.getInEdges().size());
assertSame(e, n.getInEdges().get(0));
}
@Test
void addOutEdge() {
Node n = new Node();
Edge e = new Edge();
n.addOutEdge(e);
assertEquals(1, n.getOutEdges().size());
assertSame(e, n.getOutEdges().get(0));
}
}