import org.junit.Test;
import static org.junit.Assert.*;

public class SLListTest {

    @Test
    public void testSLListAdd() {
        SLList test1 = SLList.of(1, 3, 5);
        SLList test2 = new SLList();

        test1.add(1, 2);
        test1.add(3, 4);
        assertEquals(5, test1.size());
        assertEquals(3, test1.get(2));
        assertEquals(4, test1.get(3));

        test2.add(1, 1);
        assertEquals(1, test2.get(0));
        assertEquals(1, test2.size());

        test2.add(10, 10);
        assertEquals(10, test2.get(1));
        test1.add(0, 0);
        assertEquals(SLList.of(0, 1, 2, 3, 4, 5), test1);
    }
    
    @Test
    public void testReverse() {
        var w = SLList.of();
        w.reverse();
        assertEquals(w, SLList.of());
        
        var x = SLList.of(1);
        x.reverse();
        assertEquals(x, SLList.of(1));
        
        var y = SLList.of(4, 3, 2, 1);
        y.reverse();
        System.out.println(y);
        assertEquals(y, SLList.of(1, 2, 3, 4));
        
        var z = SLList.of(4, 4, 4, 4);
        z.reverse();
        assertEquals(z, SLList.of(4, 4, 4, 4));
        
        var a = SLList.of(4, 3, 3, 4);
        a.reverse();
        assertEquals(a, SLList.of(4, 3, 3, 4));
        
        var b = SLList.of(0, 1, 2, 3, 4, 5);
        b.reverse();
        assertEquals(b, SLList.of(5, 4, 3, 2, 1, 0));
        
        var c = SLList.of(1, 2, 3);
        c.reverse();
        assertEquals(c, SLList.of(3, 2, 1));
        
        var d = SLList.of(4, 3, 2, 3, 4);
        d.reverse();
        assertEquals(d, SLList.of(4, 3, 2, 3, 4));
        
        var e = SLList.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
        e.reverse();
        assertEquals(e, SLList.of(11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
        
        SLList f = SLList.of(1, 2, 3, 4);
        f.reverse();
        System.out.println(f);
        assertEquals(f, SLList.of(4, 3, 1, 1));
    }
}
