|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * JSQLParser library |
| 4 | + * %% |
| 5 | + * Copyright (C) 2004 - 2019 JSQLParser |
| 6 | + * %% |
| 7 | + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 |
| 8 | + * #L% |
| 9 | + */ |
| 10 | +package net.sf.jsqlparser.expression; |
| 11 | + |
| 12 | +import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
| 13 | +import static org.junit.Assert.assertEquals; |
| 14 | +import org.junit.Test; |
| 15 | + |
| 16 | +/** |
| 17 | + * Test some cases linked to a boolean (condition) argument as function parameter. |
| 18 | + * |
| 19 | + * @author Denis Fulachier |
| 20 | + * |
| 21 | + */ |
| 22 | +public class FunctionWithBooleanParameterTest { |
| 23 | + |
| 24 | + public FunctionWithBooleanParameterTest() { |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void testParseOpLowerTotally() throws Exception { |
| 29 | + Expression result = CCJSqlParserUtil.parseExpression("if(a<b, c, d)"); |
| 30 | + assertEquals("if(a < b, c, d)", result.toString()); |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + public void testParseOpLowerOrEqual() throws Exception { |
| 35 | + Expression result = CCJSqlParserUtil.parseExpression("if(a+x<=b+y, c, d)"); |
| 36 | + assertEquals("if(a + x <= b + y, c, d)", result.toString()); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void testParseOpGreaterTotally() throws Exception { |
| 41 | + Expression result = CCJSqlParserUtil.parseExpression("if(a>b, c, d)"); |
| 42 | + assertEquals("if(a > b, c, d)", result.toString()); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void testParseOpGreaterOrEqual() throws Exception { |
| 47 | + Expression result = CCJSqlParserUtil.parseExpression("if(a>=b, c, d)"); |
| 48 | + assertEquals("if(a >= b, c, d)", result.toString()); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testParseOpEqual() throws Exception { |
| 53 | + Expression result = CCJSqlParserUtil.parseExpression("if(a=b, c, d)"); |
| 54 | + assertEquals("if(a = b, c, d)", result.toString()); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void testParseOpNotEqualStandard() throws Exception { |
| 59 | + Expression result = CCJSqlParserUtil.parseExpression("if(a<>b, c, d)"); |
| 60 | + assertEquals("if(a <> b, c, d)", result.toString()); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void testParseOpNotEqualBang() throws Exception { |
| 65 | + Expression result = CCJSqlParserUtil.parseExpression("if(a!=b, c, d)"); |
| 66 | + assertEquals("if(a != b, c, d)", result.toString()); |
| 67 | + } |
| 68 | +} |
0 commit comments