parent
e1ee1c175b
commit
3af0ea5c4f
@ -1,5 +1,7 @@
|
|||||||
package eva2.tools;
|
package eva2.tools;
|
||||||
|
|
||||||
|
import eva2.util.annotation.Parameter;
|
||||||
|
|
||||||
import java.io.Serializable;
|
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 S head;
|
||||||
public T tail;
|
public T tail;
|
||||||
|
|
||||||
@ -24,9 +25,6 @@ public class Pair<S, T> implements Serializable {
|
|||||||
this.tail = tail;
|
this.tail = tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -75,10 +73,6 @@ public class Pair<S, T> implements Serializable {
|
|||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String headTipText() {
|
|
||||||
return "First pair entry";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -90,15 +84,6 @@ public class Pair<S, T> implements Serializable {
|
|||||||
return tail;
|
return tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String tailTipText() {
|
|
||||||
return "Last pair entry";
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "(" + head.toString() + "," + tail.toString() + ")";
|
return "(" + head.toString() + "," + tail.toString() + ")";
|
||||||
@ -111,6 +96,7 @@ public class Pair<S, T> implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* @param head
|
* @param head
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description="First pair entry")
|
||||||
public void setHead(S head) {
|
public void setHead(S head) {
|
||||||
this.head = head;
|
this.head = head;
|
||||||
}
|
}
|
||||||
@ -118,6 +104,7 @@ public class Pair<S, T> implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* @param tail
|
* @param tail
|
||||||
*/
|
*/
|
||||||
|
@Parameter(description = "Last pair entry")
|
||||||
public void setTail(T tail) {
|
public void setTail(T tail) {
|
||||||
this.tail = tail;
|
this.tail = tail;
|
||||||
}
|
}
|
||||||
|
@ -1052,9 +1052,7 @@ public final class BayNet {
|
|||||||
line = line + ": " + pTable[j];
|
line = line + ": " + pTable[j];
|
||||||
result += line;
|
result += line;
|
||||||
}
|
}
|
||||||
Pair<Integer, String> p = new Pair<>();
|
Pair<Integer, String> p = new Pair<>(length, result);
|
||||||
p.setHead(length);
|
|
||||||
p.setTail(result);
|
|
||||||
return p;
|
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