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

import org.junit.Test;
import static org.junit.Assert.*;

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

    @Test
    public void testIdentity() {
        ProjectionFunction<String, String> a = ProjectionFunction.identity();
        ProjectionFunction<Integer, Integer> b = ProjectionFunction.identity();
        
        assertEquals("z", a.invert("z"));
        assertEquals("z", a.apply("z"));
        assertEquals(Integer.valueOf(17), b.invert(17));
        assertEquals(Integer.valueOf(17), b.apply(17));
    }
    
    @Test
    public void testProduce() {
        ProjectionFunction<String, Character> func = ProjectionFunction.produce(s->s.charAt(1), c->"#"+c);
        
        assertEquals(Character.valueOf('a'), func.apply("#a"));
        assertEquals("#z", func.invert('z'));
    }
    
}
