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

import net.ranides.test.ContractTesters;
import net.ranides.test.data.TComparator;
import net.ranides.test.data.TMap;
import net.ranides.test.data.TMapItems;
import net.ranides.test.data.TMaps;
import net.ranides.test.data.TPoint;
import org.junit.Test;

import net.ranides.assira.collection.maps.IntArrayMap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Pattern;

import static net.ranides.assira.junit.NewAssert.*;

public class ArrayLookupTest {
    
    private final TMap<TPoint, Integer> $map = TMaps.MAP_PI;
    
    @Test
    public void testSuite() {

        ContractTesters.runner()
            .param("map!", $map)
            .function(new int[0], array -> new ArrayLookup<>($map.keys().list(array).values(), $map.values().list(array).valuesInt(), $map.comparator()))
            .ignore(Pattern.compile(".*_HC"))
            .run();
    }


    @Test
    public void counter() {
        Lookup<String> map = new ArrayLookup<>();
        map.inc("a");
        map.inc("a");
        map.inc("a");
        map.inc("b");
        map.inc("b");
        map.inc("c");

        assertEquals(Arrays.asList("a", "b", "c"), new ArrayList<>(map.keySet()));

        map.dec("a");
        map.dec("b");
        map.dec("c");

        assertEquals(Arrays.asList("a", "b"), new ArrayList<>(map.keySet()));

        map.dec("a");
        map.dec("b");

        assertEquals(Arrays.asList("a"), new ArrayList<>(map.keySet()));
    }

}
