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

import java.util.Map;
import net.ranides.assira.collection.maps.IntMap;
import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class EnumUtilsTest {
    
    public EnumUtilsTest() {
    }

    @Test
    public void testIntMap() {
        IntMap<MyEnum> map = EnumUtils.intmap(MyEnum.class, e -> e.v);
        assertEquals(4, map.size());
        assertTrue(map.containsKey(4));
        assertEquals(MyEnum.CONST, map.get(8));
    }
    
    @Test
    public void testMap() {
        Map<String, MyEnum> map = EnumUtils.map(MyEnum.class, e -> e.name().toLowerCase());
        assertEquals(4, map.size());
        assertTrue(map.containsKey("entry"));
        assertFalse(map.containsKey("ENTRY"));
        assertEquals(MyEnum.CONST, map.get("const"));
    }
    
    
    private enum MyEnum {
        VALUE(1),
        ITEM(4),
        ENTRY(2),
        CONST(8);
        
        private final int v;

        private MyEnum(int v) {
            this.v = v;
        }

    }
    
}
