/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.collection.list;

import java.util.Arrays;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author ranides
 */
public class RTListTest {
    
    public RTListTest() {
    }

    @Test
    public void testContent() {
        RTList<Integer> values = new RTList<>(Arrays.asList(11, 22, 33, 44, 55));
        assertEquals(5, values.size());
        assertEquals(11, (int)values.get(0));
        assertEquals(22, (int)values.get(1));
        assertEquals(33, (int)values.get(2));
        assertEquals(44, (int)values.get(3));
        assertEquals(55, (int)values.get(4));
    }

    @Test
    public void testSet() {
        RTList<Integer> values = new RTList<>(Arrays.asList(11, 22, 33, 44, 55));
        values.set(0, 71);
        values.set(3, 77);
        assertEquals(71, (int)values.get(0));
        assertEquals(22, (int)values.get(1));
        assertEquals(33, (int)values.get(2));
        assertEquals(77, (int)values.get(3));
        assertEquals(55, (int)values.get(4));
    }

    @Test
    public void testAdd() {
        RTList<Integer> values = new RTList<>(Arrays.asList(11, 22, 33));
        values.add(91);
        values.add(92);
        assertEquals(Arrays.asList(11,22,33,91,92), values);
        values.add(1, 93);
        values.add(3, 94);
        assertEquals(Arrays.asList(11,93,22,94,33,91,92), values);
    }

    @Test
    public void testRemove() {
        RTList<Long> values = new RTList<>(Arrays.asList(11L, 22L, 33L, 44L, 55L, 66L));
        values.remove(1);
        values.remove(2);
        assertEquals(Arrays.asList(11L, 33L, 55L, 66L), values);
        values.add(1, 91L);
        values.remove(3);
        assertEquals(Arrays.asList(11L, 91L, 33L, 66L), values);
    }
}
