package fib;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import config.Example;
import edu.udel.cis.vsl.tass.config.CompareConfiguration;
import edu.udel.cis.vsl.tass.front.minimp.ModelExtractor;
import edu.udel.cis.vsl.tass.front.minimp.ModelPair;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.util.SyntaxException;
import edu.udel.cis.vsl.tass.verify.Comparison;

public class FibTest {

	@Test
	public void testCompareGood() throws IOException, SyntaxException {
		ModelIF specModel, implModel;
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "fib");
		CompareConfiguration compareConfiguration = new CompareConfiguration(
				new File(rootDirectory, "TASSREP"));

		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"fib_spec.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"fib_impl.c"));
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(1);
		compareConfiguration.setLoopTechnique(true);
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
		assertTrue(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}

	@Test
	public void testCompareBad() throws IOException, SyntaxException {
		ModelIF specModel, implModel;
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "fib");
		CompareConfiguration compareConfiguration = new CompareConfiguration(
				new File(rootDirectory, "TASSREP"));

		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"fib_spec.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"fib_implBad.c"));
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(1);
		compareConfiguration.setLoopTechnique(true);
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
		assertFalse(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}

}
