/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.matlab2smt.test;

import ca.mcmaster.cas.matlab2smt.CVC3Generator;
import ca.mcmaster.cas.matlab2smt.CheckerGenerator;
import ca.mcmaster.cas.matlab2smt.FixedPointVariableType;
import ca.mcmaster.cas.matlab2smt.MatlabLiteral;
import ca.mcmaster.cas.matlab2smt.RealVariableType;
import ca.mcmaster.cas.matlab2smt.VariableType;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 *
 * @author matthew
 */
@RunWith(JUnit4.class)
public class MatlabLiteralTest {
    /**
     * Test of canHandleOutputType method, of class MatlabLiteral.
     */
    @Test
    public void testType() {
        MatlabLiteral instance = new MatlabLiteral(null);
        VariableType exprType = new RealVariableType();
        assertEquals(exprType, instance.actualOutputTypeForRequestedOutput(exprType));
    }

    /**
     * Test of getCVC3Output method, of class MatlabLiteral.  Test only natural numbers;
     */
    @Test
    public void testGetCVC3Output() {
        MatlabLiteral instance = new MatlabLiteral("5");
        assertEquals("5", instance.getCheckerOutput(generator, new RealVariableType()));
        assertEquals("0bin00101", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 0)));
        assertEquals("0bin01010", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 1)));
    }

    /**
     * Test of getCVC3Output method, of class MatlabLiteral.  Test fun fixed point number;
     */
    @Test
    public void testCVC3OutputOnInterestingFixedPoint() {
        MatlabLiteral instance = new MatlabLiteral("0");
        assertEquals("0bin00000", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 1)));
        
        instance = new MatlabLiteral("5.5");
        assertEquals("0bin01011", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 1)));
        
        instance = new MatlabLiteral("-5.5");
        assertEquals("0bin10101", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 1)));
        
        instance = new MatlabLiteral("-5");
        assertEquals("0bin11011", instance.getCheckerOutput(generator, new FixedPointVariableType(true, 5, 0)));
    }
    CheckerGenerator generator = new CVC3Generator();
}
