package sum;

import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileNotFoundException;

import org.junit.BeforeClass;
import org.junit.Test;

import config.Example;
import edu.udel.cis.vsl.tass.config.VerifyConfiguration;
import edu.udel.cis.vsl.tass.config.RunConfiguration.DeadlockStrategy;
import edu.udel.cis.vsl.tass.config.RunConfiguration.ReductionStrategy;
import edu.udel.cis.vsl.tass.front.minimp.ModelExtractor;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.verify.Verification;

public class SumTest {

	private static ModelIF model;
	private static VerifyConfiguration configuration;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		File rootDirectory = new File(Example.exampleDirectory, "sum");

		configuration = new VerifyConfiguration(new File(rootDirectory,
				"TASSREP"));
		configuration.setSourceFile(new File(rootDirectory, "sum.c"));
		configuration.setInput("N_BOUND", 10);
		configuration.setNumProcs(1);
		configuration.setModelName("sum_10");
		configuration.setVerbose(false);
		configuration.setSimplify(false);
		model = ModelExtractor.extractModel(configuration);
	}

	@Test
	public void test() throws FileNotFoundException {
		assertTrue(Verification.verify(model, configuration, true));
	}

	@Test
	public void testSimplify() throws FileNotFoundException {
		VerifyConfiguration config = new VerifyConfiguration(configuration);

		config.setSimplify(true);
		assertTrue(Verification.verify(model, config, true));
	}

	@Test
	public void testUrgent() throws FileNotFoundException {
		VerifyConfiguration config = new VerifyConfiguration(configuration);

		config.setReductionStrategy(ReductionStrategy.URGENT);
		assertTrue(Verification.verify(model, config, true));
	}

	@Test
	public void testUrgentSimplifyPotential() throws FileNotFoundException {
		VerifyConfiguration config = new VerifyConfiguration(configuration);

		config.setReductionStrategy(ReductionStrategy.URGENT);
		config.setSimplify(true);
		config.setDeadlockStrategy(DeadlockStrategy.POTENTIAL);
		assertTrue(Verification.verify(model, config, true));
	}
}
