()
| 60 | } |
| 61 | |
| 62 | @Test |
| 63 | public void testTuple() throws Exception { |
| 64 | TupleFactory tf = TupleFactory.getInstance(); |
| 65 | |
| 66 | int arity = 5; |
| 67 | int[] input1 = { 1, 2, 3, 4, 5 }; |
| 68 | String[] input2 = { "1", "2", "3", "4", "5" }; |
| 69 | String[] input3 = { "1", "2", "3", "4", "5", "6" }; |
| 70 | |
| 71 | // validate construction and equality |
| 72 | Tuple f1 = Util.loadFlatTuple(tf.newTuple(arity), input1); |
| 73 | Tuple f2 = Util.loadFlatTuple(tf.newTuple(arity), input1); |
| 74 | Tuple f3 = tf.newTuple(arity); |
| 75 | assertEquals(arity, f1.size()); |
| 76 | assertEquals(f1, f2); |
| 77 | |
| 78 | // invalid equality |
| 79 | f2 = Util.loadTuple(tf.newTuple(input3.length), input3); |
| 80 | assertFalse(f1.equals(f2)); |
| 81 | |
| 82 | // copy equality |
| 83 | /* |
| 84 | * f2.copyFrom(f1); |
| 85 | * assertTrue(f1.equals(f2)); |
| 86 | */ |
| 87 | |
| 88 | // append function and equality |
| 89 | int[] input4 = { 1, 2, 3 }; |
| 90 | int[] input5 = { 4, 5 }; |
| 91 | /* |
| 92 | * f1 = Util.loadFlatTuple(tf.newTuple(input4.length), input4); |
| 93 | * f2 = Util.loadFlatTuple(tf.newTuple(input5.length), input5); |
| 94 | * f3 = Util.loadFlatTuple(tf.newTuple(input1.length), input1); |
| 95 | * f1.appendTuple(f2); |
| 96 | * assertTrue(f3.equals(f1)); |
| 97 | */ |
| 98 | |
| 99 | // arity then value comparision behavior |
| 100 | f1 = Util.loadFlatTuple(tf.newTuple(input1.length), input1); // 1,2,3,4,5 |
| 101 | f2 = Util.loadFlatTuple(tf.newTuple(input4.length), input4); // 1,2,3 |
| 102 | assertTrue(f1.compareTo(f2) > 0); |
| 103 | assertFalse(f1.compareTo(f2) < 0); |
| 104 | |
| 105 | int[] input6 = { 1, 2, 3, 4, 6 }; |
| 106 | f2 = Util.loadFlatTuple(tf.newTuple(input6.length), input6); |
| 107 | assertTrue(f1.compareTo(f2) < 0); |
| 108 | assertFalse(f1.compareTo(f2) > 0); |
| 109 | |
| 110 | // delimited export |
| 111 | String expected = "1:2:3:4:5"; |
| 112 | f1 = Util.loadFlatTuple(tf.newTuple(input1.length), input1); |
| 113 | assertTrue(expected.equals(f1.toDelimitedString(":"))); |
| 114 | |
| 115 | // value read / write & marshalling |
| 116 | PipedOutputStream pos = new PipedOutputStream(); |
| 117 | DataOutputStream dos = new DataOutputStream(pos); |
| 118 | PipedInputStream pis = new PipedInputStream(pos); |
| 119 | DataInputStream dis = new DataInputStream(pis); |
nothing calls this directly
no test coverage detected