2019-06-21 13:56:57 +02:00
package jet
2019-05-29 14:03:38 +02:00
import (
"testing"
)
2019-07-19 17:19:58 +02:00
var timeVar = Time ( 10 , 20 , 0 , 0 )
2019-05-29 14:03:38 +02:00
func TestTimeExpressionEQ ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . EQ ( table2ColTime ) , "(table1.col_time = table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . EQ ( timeVar ) , "(table1.col_time = $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
func TestTimeExpressionNOT_EQ ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . NOT_EQ ( table2ColTime ) , "(table1.col_time != table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . NOT_EQ ( timeVar ) , "(table1.col_time != $1::time without time zone)" , "10:20:00.000" )
}
func TestTimeExpressionIS_DISTINCT_FROM ( t * testing . T ) {
assertClauseSerialize ( t , table1ColTime . IS_DISTINCT_FROM ( table2ColTime ) , "(table1.col_time IS DISTINCT FROM table2.col_time)" )
assertClauseSerialize ( t , table1ColTime . IS_DISTINCT_FROM ( timeVar ) , "(table1.col_time IS DISTINCT FROM $1::time without time zone)" , "10:20:00.000" )
}
func TestTimeExpressionIS_NOT_DISTINCT_FROM ( t * testing . T ) {
assertClauseSerialize ( t , table1ColTime . IS_NOT_DISTINCT_FROM ( table2ColTime ) , "(table1.col_time IS NOT DISTINCT FROM table2.col_time)" )
assertClauseSerialize ( t , table1ColTime . IS_NOT_DISTINCT_FROM ( timeVar ) , "(table1.col_time IS NOT DISTINCT FROM $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
func TestTimeExpressionLT ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . LT ( table2ColTime ) , "(table1.col_time < table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . LT ( timeVar ) , "(table1.col_time < $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
func TestTimeExpressionLT_EQ ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . LT_EQ ( table2ColTime ) , "(table1.col_time <= table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . LT_EQ ( timeVar ) , "(table1.col_time <= $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
func TestTimeExpressionGT ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . GT ( table2ColTime ) , "(table1.col_time > table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . GT ( timeVar ) , "(table1.col_time > $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
func TestTimeExpressionGT_EQ ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , table1ColTime . GT_EQ ( table2ColTime ) , "(table1.col_time >= table2.col_time)" )
2019-07-19 17:19:58 +02:00
assertClauseSerialize ( t , table1ColTime . GT_EQ ( timeVar ) , "(table1.col_time >= $1::time without time zone)" , "10:20:00.000" )
2019-05-29 14:03:38 +02:00
}
2019-06-07 14:23:14 +02:00
func TestTimeExp ( t * testing . T ) {
2019-06-17 12:05:52 +02:00
assertClauseSerialize ( t , TimeExp ( table1ColFloat ) , "table1.col_float" )
2019-06-07 14:23:14 +02:00
assertClauseSerialize ( t , TimeExp ( table1ColFloat ) . LT ( Time ( 1 , 1 , 1 , 1 ) ) ,
2019-06-17 12:05:52 +02:00
"(table1.col_float < $1::time without time zone)" , string ( "01:01:01.001" ) )
2019-06-07 14:23:14 +02:00
}