2019-06-01 15:00:37 +02:00
|
|
|
package sqlbuilder
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
2019-06-01 18:04:56 +02:00
|
|
|
func TestIntegerExpressionEQ(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.EQ(table2ColInt), "(table1.colInt = table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.EQ(Int(11)), "(table1.colInt = $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionNOT_EQ(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.NOT_EQ(table2ColInt), "(table1.colInt != table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.NOT_EQ(Int(11)), "(table1.colInt != $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionGT(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.GT(table2ColInt), "(table1.colInt > table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.GT(Int(11)), "(table1.colInt > $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionGT_EQ(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.GT_EQ(table2ColInt), "(table1.colInt >= table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.GT_EQ(Int(11)), "(table1.colInt >= $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionLT(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.LT(table2ColInt), "(table1.colInt < table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.LT(Int(11)), "(table1.colInt < $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionLT_EQ(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.LT_EQ(table2ColInt), "(table1.colInt <= table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.LT_EQ(Int(11)), "(table1.colInt <= $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionADD(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.ADD(table2ColInt), "(table1.colInt + table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.ADD(Int(11)), "(table1.colInt + $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionSUB(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.SUB(table2ColInt), "(table1.colInt - table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.SUB(Int(11)), "(table1.colInt - $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionMUL(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.MUL(table2ColInt), "(table1.colInt * table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.MUL(Int(11)), "(table1.colInt * $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntegerExpressionDIV(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.DIV(table2ColInt), "(table1.colInt / table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.DIV(Int(11)), "(table1.colInt / $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntExpressionMOD(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.MOD(table2ColInt), "(table1.colInt % table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.MOD(Int(11)), "(table1.colInt % $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-01 18:04:56 +02:00
|
|
|
func TestIntExpressionPOW(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.POW(table2ColInt), "(table1.colInt ^ table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.POW(Int(11)), "(table1.colInt ^ $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntExpressionBIT_SHIFT_LEFT(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_LEFT(table2ColInt), "(table1.colInt << table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_LEFT(Int(11)), "(table1.colInt << $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestIntExpressionBIT_SHIFT_RIGHT(t *testing.T) {
|
2019-06-05 17:15:20 +02:00
|
|
|
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_RIGHT(table2ColInt), "(table1.colInt >> table2.colInt)")
|
|
|
|
|
assertClauseSerialize(t, table1ColInt.BIT_SHIFT_RIGHT(Int(11)), "(table1.colInt >> $1)", int64(11))
|
2019-06-01 15:00:37 +02:00
|
|
|
}
|