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

import net.ranides.test.mockup.query.CQueryMockup;
import org.junit.Test;

import net.ranides.assira.collection.query.CQuery;

import static net.ranides.assira.collection.query.CQueryFeatures.*;
import static org.junit.Assert.assertEquals;

public class BaseFeaturesTest {

    @Test
    public void testAnd() {
        CQuery<String> a = CQueryMockup.of("list length");
        CQuery<String> b = CQueryMockup.of("stream list");
        CQuery<String> c = CQueryMockup.of("iterator stream list");


        assertEquals(LIST | LENGTH,  a.features().flags());
        assertEquals(LIST | STREAM,  b.features().flags());
        assertEquals(LIST | STREAM | ITERATOR,  c.features().flags());

        assertEquals(LIST | STREAM, BaseFeatures.and(b, c));
        assertEquals(LIST, BaseFeatures.and(a, c));
    }

}