package net.ranides.assira.collection.query.derived;

import net.ranides.test.CQueryAssert;
import org.junit.Test;

import net.ranides.assira.collection.lists.IntRange;
import net.ranides.assira.collection.query.CQuery;
import net.ranides.assira.collection.query.base.CQCollection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CQAppendTest {

    @Test
    public void testBasic() {
        CQuery<Integer> query1 = CQuery.<Integer>empty()
            .append(CQuery.from().values(1, 2, 3))
            .append(CQuery.from().values(4, 5, 6));

        CQueryAssert.assertEquals(Arrays.asList(1,2,3,4,5,6), query1);

        CQuery<Integer> query2 = CQuery.from().values(1,2)
            .append(CQuery.from().values(3,4))
            .append(CQuery.from().values(5, 6));

        CQueryAssert.assertEquals(Arrays.asList(1,2,3,4,5,6), query2);
    }

    @Test
    public void testParallel() {
        CQuery<Integer> query1 = CQuery.<Integer>empty()
            .append(CQuery.from(new ArrayList<>(new IntRange(0, 50))))
            .append(CQuery.from(new ArrayList<>(new IntRange(60, 90))))
            .append(CQuery.from(new ArrayList<>(new IntRange(130, 190))));

        CQueryAssert.assertUnorderedParallel(query1);
    }
}