Add Vavr.Tuple example

This commit is contained in:
Thibauld Dujardin 2020-10-03 16:25:03 +02:00
parent d48defc3e2
commit b37b135504
1 changed files with 31 additions and 0 deletions

View File

@ -93,6 +93,37 @@ public class VavrUnitTest {
assertEquals("JavaVavr 4", transformed);
}
@Test
public void editTupleValueForNewTupleInstance(){
final Tuple2<String, Integer> java9 = Tuple.of("Java", 8);
final Tuple2<String, Integer> transformed = java9.update2(9);
int num = transformed._2();
assertEquals(9,num);
}
@Test
public void editTupleValueForSameInstance(){
Tuple2<String, Integer> java9 = Tuple.of("Java", 8);
java9 = java9.update2(9);
final int num = java9._2();
assertEquals(9,num);
}
@Test
public void getNumberOfElementTuple(){
Tuple2<String, Integer> java8 = Tuple.of("Java", 8);
Tuple3<String, Integer, Double> java8Triple = Tuple.of("Java", 8, 1.8);
Tuple3<String, Integer, Double> java8TripleWnull = Tuple.of("Java", null, 1.8);
int num = java8.arity();
int numTriple = java8Triple.arity();
int numTripleWnull = java8TripleWnull.arity();
assertEquals(2,num);
assertEquals(3,numTriple);
assertEquals(3,numTripleWnull);
}
/*
* Functions
*/