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/EdgeTest.java

46 lines
951 B
Java
Raw Normal View History

2023-10-18 19:57:49 +00:00
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 EdgeTest {
@Test
void newEdge() {
Edge e = new Edge();
assertNull(e.getFrom());
assertNull(e.getTo());
}
@Test
void toStringTest() {
Node n1 = new Node();
Node n2 = new Node();
Edge e = new Edge();
e.setFrom(n1);
e.setTo(n2);
assertEquals(n1.toString()+" -> "+n2.toString(), e.toString());
}
@Test
void setFrom() {
Edge e = new Edge();
Node n = new Node();
e.setFrom(n);
assertEquals(n, e.getFrom());
assertNull(e.getTo());
}
@Test
void setTo() {
Edge e = new Edge();
Node n = new Node();
e.setTo(n);
assertEquals(n, e.getTo());
assertNull(e.getFrom());
}
}