package urban.transformers;
import static org.junit.Assert.*;
import org.antlr.runtime.RecognitionException;
import org.junit.Test;
import urban.model.Rule;
import urban.parser.UrbanParser;
import urban.shapes.RuleGraph;
public class RuleToRuleGraphTransformerTest {
@Test
public void testTransform() throws RecognitionException{
String rule = "B(a!1, c),A(b!1, c!2),C(a!2, b) <-> B(a!1, c!3),A(b!1, c!2),C(a!2, b!3) @ 0, 0\n";
String expected = "B(a!1, c),C(a!2, b),A(b!1, c!2) <-> B(a!1, c!2),C(a!3, b!2),A(b!1, c!3) @ 0, 0\n";
RuleGraph graph = new RuleToRuleGraphTransformer().transform(parse(rule));
assertEquals(expected, new RuleGraphToRuleTransformer().transform(graph).toString());
}
private Rule parse(String rule) throws RecognitionException {
return UrbanParser.parse(rule).rule();
}
}