package com.alibaba.druid.bvt.sql;

import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
import com.alibaba.druid.sql.dialect.oracle.parser.OracleExprParser;
import junit.framework.TestCase;

import static org.junit.Assert.assertNotEquals;

public class EqualTest_number extends TestCase {
    public void test_exits() throws Exception {
        String sql = "3.5";
        String sql_c = "3.51";
        SQLNumberExpr exprA, exprB, exprC;
        {
            OracleExprParser parser = new OracleExprParser(sql);
            exprA = (SQLNumberExpr) parser.expr();
        }
        {
            OracleExprParser parser = new OracleExprParser(sql);
            exprB = (SQLNumberExpr) parser.expr();
        }
        {
            OracleExprParser parser = new OracleExprParser(sql_c);
            exprC = (SQLNumberExpr) parser.expr();
        }
        assertEquals(exprA, exprB);
        assertNotEquals(exprA, exprC);
        assertTrue(exprA.equals(exprA));
        assertFalse(exprA.equals(new Object()));
        assertEquals(exprA.hashCode(), exprB.hashCode());

        assertEquals(new SQLNumberExpr(), new SQLNumberExpr());
        assertEquals(new SQLNumberExpr().hashCode(), new SQLNumberExpr().hashCode());
    }
}
