parent
e1ee1c175b
commit
3af0ea5c4f
@ -1,5 +1,7 @@
|
||||
package eva2.tools;
|
||||
|
||||
import eva2.util.annotation.Parameter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -11,7 +13,6 @@ public class Pair<S, T> implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3620465393975181451L;
|
||||
public S head;
|
||||
public T tail;
|
||||
|
||||
@ -24,9 +25,6 @@ public class Pair<S, T> implements Serializable {
|
||||
this.tail = tail;
|
||||
}
|
||||
|
||||
public Pair() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@ -75,10 +73,6 @@ public class Pair<S, T> implements Serializable {
|
||||
return head;
|
||||
}
|
||||
|
||||
public String headTipText() {
|
||||
return "First pair entry";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@ -90,15 +84,6 @@ public class Pair<S, T> implements Serializable {
|
||||
return tail;
|
||||
}
|
||||
|
||||
public String tailTipText() {
|
||||
return "Last pair entry";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + head.toString() + "," + tail.toString() + ")";
|
||||
@ -111,6 +96,7 @@ public class Pair<S, T> implements Serializable {
|
||||
/**
|
||||
* @param head
|
||||
*/
|
||||
@Parameter(description="First pair entry")
|
||||
public void setHead(S head) {
|
||||
this.head = head;
|
||||
}
|
||||
@ -118,6 +104,7 @@ public class Pair<S, T> implements Serializable {
|
||||
/**
|
||||
* @param tail
|
||||
*/
|
||||
@Parameter(description = "Last pair entry")
|
||||
public void setTail(T tail) {
|
||||
this.tail = tail;
|
||||
}
|
||||
|
@ -1052,9 +1052,7 @@ public final class BayNet {
|
||||
line = line + ": " + pTable[j];
|
||||
result += line;
|
||||
}
|
||||
Pair<Integer, String> p = new Pair<>();
|
||||
p.setHead(length);
|
||||
p.setTail(result);
|
||||
Pair<Integer, String> p = new Pair<>(length, result);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
79
src/test/java/eva2/tools/PairTest.java
Normal file
79
src/test/java/eva2/tools/PairTest.java
Normal file
@ -0,0 +1,79 @@
|
||||
package eva2.tools;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PairTest {
|
||||
private Pair<String, Double> p;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
p = new Pair<>("Head", 12.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCar() throws Exception {
|
||||
assertEquals("Head", p.car());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCdr() throws Exception {
|
||||
assertEquals(12.0, p.cdr(), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClone() throws Exception {
|
||||
//assertEquals(p, p.clone());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() throws Exception {
|
||||
assertNotNull(p.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception {
|
||||
assertEquals("Head", p.head());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHead() throws Exception {
|
||||
assertEquals("Head", p.getHead());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTail() throws Exception {
|
||||
assertEquals(12.0, p.tail(), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTail() throws Exception {
|
||||
assertEquals(12.0, p.getTail(), 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() throws Exception {
|
||||
assertEquals("(Head,12.0)", p.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetName() throws Exception {
|
||||
assertEquals("(Head,12.0)", p.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetHead() throws Exception {
|
||||
String newHead = "newHead";
|
||||
p.setHead(newHead);
|
||||
assertEquals(newHead, p.getHead());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTail() throws Exception {
|
||||
Double newTail = 42.0;
|
||||
p.setTail(newTail);
|
||||
assertEquals(newTail, p.getTail());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user