package jalf.type;

import static org.junit.Assert.*;
import static jalf.fixtures.SuppliersAndParts.*;
import jalf.Tuple;

import org.junit.Test;

public class TestTupleType {

    TupleType type = TupleType.varargs(SID, String.class);

    @Test
    public void testEquals() {
        // it is equal to itself
        assertTrue(type.equals(type));
        // it is equal to an equivalent
        assertTrue(type.equals(TupleType.varargs(SID, String.class)));
        // it is not equal to another ones
        assertFalse(type.equals(TupleType.varargs()));
        assertFalse(type.equals(TupleType.varargs(SID, String.class, STATUS, Integer.class)));
        assertFalse(type.equals(TupleType.varargs(SID, Integer.class)));
        assertFalse(type.equals(TupleType.varargs(NAME, String.class)));
    }

    @Test
    public void testContains() {
        assertTrue(type.contains(Tuple.varargs(SID, "S1")));
        assertFalse(type.contains(Tuple.varargs()));
        assertFalse(type.contains(Tuple.varargs(SID, 12)));
        assertFalse(type.contains(Tuple.varargs(SID, "S1", STATUS, 12)));
        assertFalse(type.contains("hello"));
        assertFalse(type.contains(null));
    }

}

@@ -92,24 +92,25 @@
 AndParts.*;%0A
+%0A
 import jalf.
@@ -110,18 +110,33 @@
 t ja
-lf.Tuple;%0A
+va.util.*;%0Aimport jalf.*;
 %0Aimp
@@ -246,16 +246,1110 @@
 lass);%0A%0A
+    @Test%0A    public void testContains() %7B%0A        assertTrue(type.contains(Tuple.varargs(SID, %22S1%22)));%0A        assertFalse(type.contains(Tuple.varargs()));%0A        assertFalse(type.contains(Tuple.varargs(SID, 12)));%0A        assertFalse(type.contains(Tuple.varargs(SID, %22S1%22, STATUS, 12)));%0A        assertFalse(type.contains(%22hello%22));%0A        assertFalse(type.contains(null));%0A    %7D%0A%0A    @Test%0A    public void testToAttrList() %7B%0A        TupleType type = TupleType.varargs(STATUS, Integer.class, SID, String.class);%0A        AttrList expected = AttrList.attrs(STATUS, SID);%0A        assertEquals(expected, type.toAttrList());%0A%0A        // it preserves the insertion order%0A        List%3CAttrName%3E list = Arrays.asList(STATUS, SID);%0A        assertEquals(list, expected.toList());%0A    %7D%0A%0A    @Test%0A    public void testHashCode() %7B%0A        // it does not depend on the order%0A        TupleType t1 = TupleType.varargs(SID, String.class, STATUS, Integer.class);%0A        TupleType t2 = TupleType.varargs(STATUS, Integer.class, SID, String.class);%0A        assertEquals(t1.hashCode(), t2.hashCode());%0A    %7D%0A%0A
     @Tes
@@ -1914,391 +1914,6 @@
  %7D%0A%0A
-    @Test%0A    public void testContains() %7B%0A        assertTrue(type.contains(Tuple.varargs(SID, %22S1%22)));%0A        assertFalse(type.contains(Tuple.varargs()));%0A        assertFalse(type.contains(Tuple.varargs(SID, 12)));%0A        assertFalse(type.contains(Tuple.varargs(SID, %22S1%22, STATUS, 12)));%0A        assertFalse(type.contains(%22hello%22));%0A        assertFalse(type.contains(null));%0A    %7D%0A%0A
 %7D%0A

Add unit tests for TupleType (refs #4)