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

import java.util.function.Function;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class CoFunctionTest {
    
    @Test
    public void testIdentity() {
        CoFunction<String, String> a = CoFunction.identity();
        CoFunction<Integer, Integer> b = CoFunction.identity();
        
        assertEquals("z", a.invert("z"));
        assertEquals(Integer.valueOf(17), b.invert(17));
    }
    
    @Test
    public void testInverted() {
        CoFunction<String, Integer> a = String::valueOf;
        Function<Integer, String> b = CoFunction.inverted(a);
        CoFunction<String, Integer> c = CoFunction.inverted(b);
        
        assertEquals("17", a.invert(17));
        assertEquals("17", b.apply(17));
        assertEquals("17", c.invert(17));
    }
}
