/** * Factory method to create a tuple. * * @param <A> Type of the tuple element. * @param elements The elements of the tuple * @return A new tuple that contains {@code elements} */ @SuppressWarnings("unchecked") public static <A> Tuple<A> of(A ... elements) { return new Tuple<A>(elements); }
public void testSize() { assertEquals(2, tuple.size()); }
public void testGet() { assertEquals(FOO, tuple.get(0)); assertEquals(BAR, tuple.get(1)); try { tuple.get(-1); fail("Should have thrown IndexOutOfBoundsException when accessing index -1."); } catch (ArrayIndexOutOfBoundsException e) { // Expected. } try { tuple.get(2); fail("Should have thrown IndexOutOfBoundsException when accessing index that is greater " + "than the size of the tuple."); } catch (ArrayIndexOutOfBoundsException e) { // Expected. } }
public void testSize() { assertEquals(2, tuple.size()); }
public void testGet() { assertEquals(FOO, tuple.get(0)); assertEquals(BAR, tuple.get(1)); try { tuple.get(-1); fail("Should have thrown IndexOutOfBoundsException when accessing index -1."); } catch (ArrayIndexOutOfBoundsException e) { // Expected. } try { tuple.get(2); fail("Should have thrown IndexOutOfBoundsException when accessing index that is greater " + "than the size of the tuple."); } catch (ArrayIndexOutOfBoundsException e) { // Expected. } }