Commit 55aa7ca8 authored by Corentin Guillevic's avatar Corentin Guillevic
Browse files

Modification of the method toString (Pair) and add test

parent 14716cb8
......@@ -32,6 +32,6 @@ public class Pair <T, U> {
@Override
public String toString() {
return "Pair( " + key + " ; " + value + " )";
return "Pair(" + key + ", " + value + ")";
}
}
......@@ -19,6 +19,7 @@ class PairTest {
Integer i1 = 5;
String s1 = "test";
Pair<Integer, String> pair = new Pair<>(i1, s1);
assertEquals(s1, pair.getValue());
}
@Test
......@@ -36,7 +37,6 @@ class PairTest {
String s1 = "test";
Pair<Integer, String> pair1 = new Pair<>(i1, s1);
assertEquals(pair1, pair1);
System.out.println(pair1 + " " + pair1);
}
@Test
......@@ -80,4 +80,13 @@ class PairTest {
Object o1 = new Object();
assertNotEquals(pair1, o1);
}
@Test
void toString_equalsToExpect() {
Integer i1 = 5;
String s1 = "test";
Pair<Integer, String> pair1 = new Pair<>(i1, s1);
String expect = "Pair(5, test)";
assertEquals(expect, ""+pair1);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment