/** * Copyright © 2012 Akiban Technologies, Inc. All rights * reserved. * * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * This program may also be available under different license terms. * For more information, see www.akiban.com or contact * licensing@akiban.com. * * Contributors: * Akiban Technologies, Inc. */ package com.akiban.sql.compiler; import com.akiban.sql.TestBase; import com.akiban.sql.parser.StatementNode; import org.junit.Before; import org.junit.Test; import static junit.framework.Assert.*; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.junit.runner.RunWith; import java.io.File; import java.util.Collection; @RunWith(Parameterized.class) public class BooleanNormalizerTest extends ASTTransformTestBase implements TestBase.GenerateAndCheckResult { public static final File RESOURCE_DIR = new File(ASTTransformTestBase.RESOURCE_DIR, "normalize"); protected BooleanNormalizer booleanNormalizer; @Before public void makeNormalizer() throws Exception { booleanNormalizer = new BooleanNormalizer(parser); } @Parameters public static Collection<Object[]> statements() throws Exception { return sqlAndExpected(RESOURCE_DIR); } public BooleanNormalizerTest(String caseName, String sql, String expected, String error) { super(caseName, sql, expected, error); } @Test public void testNormalizer() throws Exception { generateAndCheckResult(); } @Override public String generateResult() throws Exception { StatementNode stmt = parser.parseStatement(sql); stmt = booleanNormalizer.normalize(stmt); return unparser.toString(stmt); } @Override public void checkResult(String result) { assertEquals(caseName, expected, result); } }