package linkedList;

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.VerifyConfiguration;
import edu.udel.cis.vsl.tass.front.minimp.ModelExtractor;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.util.SyntaxException;
import edu.udel.cis.vsl.tass.verify.Verification;

public class LinkedListTest {

	private File rootDirectory = new File(Example.exampleDirectory,
			"linkedList");
	private File repository = new File(rootDirectory, "TASSREP");

	@Test
	public void testVerifyLinkedListSimple() throws IOException,
			SyntaxException {
		VerifyConfiguration config = new VerifyConfiguration(repository);
		ModelIF model;

		config.setSourceFile(new File(rootDirectory, "linkedListSimple.c"));
		config.setModelName("linkedListSimple");
		config.setNumProcs(1);
		model = ModelExtractor.extractModel(config);
		assertTrue(Verification.verify(model, config, true));
	}

	@Test
	public void testVerifyLinkedListMedium() throws IOException,
			SyntaxException {
		VerifyConfiguration config1 = new VerifyConfiguration(repository);
		ModelIF model1;

		config1.setSourceFile(new File(rootDirectory, "linkedListMedium.c"));
		config1.setModelName("linkedListMedium");
		config1.setNumProcs(1);
		model1 = ModelExtractor.extractModel(config1);
		assertTrue(Verification.verify(model1, config1, true));
	}

	@Test
	public void testVerifyLinkedListHard() throws IOException, SyntaxException {
		VerifyConfiguration config2 = new VerifyConfiguration(repository);
		ModelIF model2;

		config2.setSourceFile(new File(rootDirectory, "linkedListHard.c"));
		config2.setModelName("linkedListHard");
		config2.setNumProcs(1);
		model2 = ModelExtractor.extractModel(config2);
		assertTrue(Verification.verify(model2, config2, true));
	}

	@Test
	public void testVerifyLinkedListDeletion() throws IOException,
			SyntaxException {
		VerifyConfiguration config3 = new VerifyConfiguration(repository);
		ModelIF model3;
		config3.setSourceFile(new File(rootDirectory, "linkedListDeletion.c"));
		config3.setModelName("linkedListDeletionFail");
		config3.setNumProcs(1);
		model3 = ModelExtractor.extractModel(config3);

		assertTrue(Verification.verify(model3, config3, true));
	}

	@Test
	public void testVerifyLinkedListInsertion() throws IOException,
			SyntaxException {
		VerifyConfiguration config3 = new VerifyConfiguration(repository);
		ModelIF model3;
		config3.setSourceFile(new File(rootDirectory, "linkedListInsertion.c"));
		config3.setModelName("linkedListInsertion");
		config3.setNumProcs(1);
		model3 = ModelExtractor.extractModel(config3);

		assertTrue(Verification.verify(model3, config3, true));
	}
}