diff --git a/tests/develop-test/2-query/constant_compare.py b/tests/develop-test/2-query/constant_compare.py index 7ac39330225e27d9b43b7659eb881127954f484e..5c752d5e78027df5df002d16a7927ef963fdbf7c 100644 --- a/tests/develop-test/2-query/constant_compare.py +++ b/tests/develop-test/2-query/constant_compare.py @@ -111,6 +111,31 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 1.0 = true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 = false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0 = false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0.0 = true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true = 1.001 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true = 1.0000000001 from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + ##operator: != tdSql.query('select 1 != 1 from tb;') tdSql.checkRows(1) @@ -168,6 +193,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1.0 != true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0.0 != false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 1.0 != false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 != true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true != 1.001 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true != 1.0000000001 from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: <> tdSql.query('select 1 <> 1 from tb;') tdSql.checkRows(1) @@ -225,6 +274,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1.0 <> true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0.0 <> false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 1.0 <> false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 <> true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true <> 1.001 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true <> 1.0000000001 from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: < tdSql.query('select 1 < 1 from tb;') tdSql.checkRows(1) @@ -282,6 +355,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select 1.0 < true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0.0 < false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select false < 1.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 < true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true < 1.001 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true < 1.0000000001 from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: > tdSql.query('select 1 > 1 from tb;') tdSql.checkRows(1) @@ -339,6 +436,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1.0 > true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 0.0 > false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select 1.0 > false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true > 0.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.001 > true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0000000001 > true from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + ##operator: <= tdSql.query('select 1 <= 2 from tb;') tdSql.checkRows(1) @@ -408,11 +529,35 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) - tdSql.query('select true >= true from tb;') + tdSql.query('select true <= true from tb;') tdSql.checkRows(1) tdSql.checkData(0, 0, 1) - tdSql.query('select false >= false from tb;') + tdSql.query('select false <= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0 <= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 <= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select false <= 1.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 <= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true <= 1.001 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true <= 1.0000000001 from tb;') ##DBL_EPSILON is used in floating number comparison tdSql.checkRows(1) tdSql.checkData(0, 0, 1) @@ -493,6 +638,30 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1.0 >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0.0 >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0 >= false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true >= 0.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.001 >= true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0000000001 >= true from tb;') ##DBL_EPSILON is used in floating number comparison + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: between and tdSql.query('select 1 between 2 and 4 from tb;') tdSql.checkRows(1) @@ -591,6 +760,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select false between 0.0 and 1.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select false between 1.0 and 2.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + + tdSql.query('select true between 0.0 and 1.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select true between -1.0 and 0.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.query('select 0 between false and true from tb;') tdSql.checkRows(1) tdSql.checkData(0, 0, 1) @@ -607,6 +792,22 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 0.0 between false and true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1.0 between false and true from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 0 between false and 10.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 between true and 10.0 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: and tdSql.query('select 10 and 10 from tb;') tdSql.checkRows(1) @@ -644,6 +845,10 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 0) + tdSql.query('select true and 10.0 and false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.query('select 1 and 2 and 3 and 10.1 and -20.02 and 22.03 from tb;') tdSql.checkRows(1) tdSql.checkData(0, 0, 1) @@ -693,6 +898,10 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select true or 10.0 or false from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + ##operator: multiple operations tdSql.query('select 1 and 1 != 2 and 1 < 2 and 2 between 1 and 3 from tb;') tdSql.checkRows(1) @@ -738,6 +947,14 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, 1) + tdSql.query('select 1 != 2 and 1 < 2 or 1 >= 2 or 2 between 4 and 5 and true and 10.1 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + + tdSql.query('select 1 != 2 and 1 < 2 or 1 >= 2 or 2 between 4 and 5 and false or 10.1 from tb;') + tdSql.checkRows(1) + tdSql.checkData(0, 0, 1) + tdSql.execute('drop database db') def stop(self): tdSql.close()