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

import net.ranides.assira.ContractTesters;
import net.ranides.assira.collection.CollectionUtils;
import net.ranides.assira.collection.IntComparator;
import net.ranides.assira.collection.Swapper;
import net.ranides.assira.collection.arrays.*;
import net.ranides.assira.collection.lists.ListUtils;
import net.ranides.assira.collection.mockup.TMaps;
import net.ranides.assira.collection.mockup.TPoint;
import net.ranides.assira.collection.sets.AVLTreeSet;
import net.ranides.assira.collection.utils.CollectionSort;
import net.ranides.assira.junit.NewAssert;
import net.ranides.assira.test.TCollection.TItems;
import net.ranides.assira.test.TMap;
import org.junit.Test;

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

import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class ArrayMapTest {



    @Test
    public void testBasics() throws Exception {
        TMap<TPoint, Integer> $map = TMaps.MAP_PI;

        TItems<TPoint> keys = $map.keys().range(32).shuffle(5);
        TItems<Integer> values = $map.values().range(32).shuffle(5);

        ArrayMap<TPoint, Integer> map = new ArrayMap<>(
            keys.values(), values.values(), $map.comparator()
        );

        List<TPoint> ekeys = keys.intoList();
        List<Integer> evalues = values.intoList();

        System.out.println(ekeys);
        System.out.println(evalues);

        CollectionSort.msort2($map.comparator(), ekeys, evalues);

        System.out.println(ekeys);
        System.out.println(evalues);

        // @todo (assira #2) ArrayMap: test

    }

    @Test
    public void testMap() {
        ArrayMap<String, Integer> map = new ArrayMap<>(
                new String[]{"a","b","c","d","e"},
                new Integer[]{71,62,53,24,15}
        );
        
        assertEquals(62, map.get("b").intValue());
        assertEquals(15, map.get("e").intValue());
        assertEquals(71, map.get("a").intValue());
        assertEquals(null, map.get("q"));
    }
    
}
