package com.mattrixwv; import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class TestTriple{ private Triple triple; @BeforeEach public void setup(){ triple = new Triple<>(1L, 2L, 3L); } @Test public void testConstructor(){ triple = new Triple<>(1L, 2L, 3L); assertEquals(1L, triple.getA()); assertEquals(2L, triple.getB()); assertEquals(3L, triple.getC()); } @Test public void testGetters(){ assertEquals(1L, triple.getA()); assertEquals(2L, triple.getB()); assertEquals(3L, triple.getC()); } @Test public void testEquals(){ Triple triple2 = new Triple<>(1L, 2L, 3L); Triple triple3 = new Triple<>(3L, 2L, 3L); Triple triple4 = new Triple<>(1L, 3L, 3L); Triple triple5 = new Triple<>(1L, 2L, 1L); Triple triple6 = new Triple<>(2L, 1L, 3L); Triple triple7 = new Triple<>(3L, 2L, 1L); Triple triple8 = new Triple<>(1L, 3L, 2L); Triple triple9 = new Triple<>(3L, 1L, 2L); assertEquals(triple, triple); assertEquals(triple, triple2); assertNotEquals(triple, triple3); assertNotEquals(triple, triple4); assertNotEquals(triple, triple5); assertNotEquals(triple, triple6); assertNotEquals(triple, triple7); assertNotEquals(triple, triple8); assertNotEquals(triple, triple9); assertNotEquals(triple, 1L); } @Test public void testHashCode(){ assertEquals(Long.hashCode(1) + Long.hashCode(2) * Long.hashCode(3), triple.hashCode()); } @Test public void testToString(){ assertEquals("[1, 2, 3]", triple.toString()); } }