/ Check-in [ced6a348]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests for the BETWEEN operator to e_expr.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ced6a3480fe4a8e2b93160a8419bdc3ab30935e8
User & Date: dan 2010-08-17 16:06:09
Context
2010-08-17
17:25
Changes to pager for improved testability. check-in: 61c64b3a user: drh tags: trunk
16:06
Add tests for the BETWEEN operator to e_expr.test. check-in: ced6a348 user: dan tags: trunk
14:52
Invoke sqlite3_log() whenever one or more frames are recovered from a WAL file. check-in: e05089aa user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/e_expr.test.

   813    813     do_execsql_test e_expr-12.4.$tn "
   814    814       CREATE TRIGGER dbname.tr$tn BEFORE DELETE ON tblname BEGIN
   815    815         SELECT $raiseexpr ;
   816    816       END;
   817    817     " {}
   818    818   }
   819    819   
          820  +#-------------------------------------------------------------------------
          821  +# Test the statements related to the BETWEEN operator.
          822  +#
          823  +# EVIDENCE-OF: R-40079-54503 The BETWEEN operator is logically
          824  +# equivalent to a pair of comparisons. "x BETWEEN y AND z" is equivalent
          825  +# to "x>=y AND x<=z" except that with BETWEEN, the x expression is
          826  +# only evaluated once.
          827  +#
          828  +db func x x
          829  +proc x {} { incr ::xcount ; return [expr $::x] }
          830  +foreach {tn x expr res nEval} {
          831  +  1  10  "x() >= 5 AND x() <= 15"  1  2
          832  +  2  10  "x() BETWEEN 5 AND 15"    1  1
          833  +
          834  +  3   5  "x() >= 5 AND x() <= 5"   1  2
          835  +  4   5  "x() BETWEEN 5 AND 5"     1  1
          836  +} {
          837  +  do_test e_expr-13.1.$tn {
          838  +    set ::xcount 0
          839  +    set a [execsql "SELECT $expr"]
          840  +    list $::xcount $a
          841  +  } [list $nEval $res]
          842  +}
          843  +
          844  +# EVIDENCE-OF: R-05155-34454 The precedence of the BETWEEN operator is
          845  +# the same as the precedence as operators == and != and LIKE and groups
          846  +# left to right.
          847  +# 
          848  +# Therefore, BETWEEN groups more tightly than operator "AND", but less
          849  +# so than "<".
          850  +#
          851  +do_execsql_test e_expr-13.2.1  { SELECT 1 == 10 BETWEEN 0 AND 2   }  1
          852  +do_execsql_test e_expr-13.2.2  { SELECT (1 == 10) BETWEEN 0 AND 2 }  1
          853  +do_execsql_test e_expr-13.2.3  { SELECT 1 == (10 BETWEEN 0 AND 2) }  0
          854  +do_execsql_test e_expr-13.2.4  { SELECT  6 BETWEEN 4 AND 8 == 1 }    1
          855  +do_execsql_test e_expr-13.2.5  { SELECT (6 BETWEEN 4 AND 8) == 1 }   1
          856  +do_execsql_test e_expr-13.2.6  { SELECT  6 BETWEEN 4 AND (8 == 1) }  0
          857  +
          858  +do_execsql_test e_expr-13.2.7  { SELECT  5 BETWEEN 0 AND 0  != 1 }   1
          859  +do_execsql_test e_expr-13.2.8  { SELECT (5 BETWEEN 0 AND 0) != 1 }   1
          860  +do_execsql_test e_expr-13.2.9  { SELECT  5 BETWEEN 0 AND (0 != 1) }  0
          861  +do_execsql_test e_expr-13.2.10 { SELECT  1 != 0  BETWEEN 0 AND 2  }  1
          862  +do_execsql_test e_expr-13.2.11 { SELECT (1 != 0) BETWEEN 0 AND 2  }  1
          863  +do_execsql_test e_expr-13.2.12 { SELECT  1 != (0 BETWEEN 0 AND 2) }  0
          864  +
          865  +do_execsql_test e_expr-13.2.13  { SELECT 1 LIKE 10 BETWEEN 0 AND 2   }  1
          866  +do_execsql_test e_expr-13.2.14  { SELECT (1 LIKE 10) BETWEEN 0 AND 2 }  1
          867  +do_execsql_test e_expr-13.2.15  { SELECT 1 LIKE (10 BETWEEN 0 AND 2) }  0
          868  +do_execsql_test e_expr-13.2.16  { SELECT  6 BETWEEN 4 AND 8 LIKE 1   }  1
          869  +do_execsql_test e_expr-13.2.17  { SELECT (6 BETWEEN 4 AND 8) LIKE 1  }  1
          870  +do_execsql_test e_expr-13.2.18  { SELECT  6 BETWEEN 4 AND (8 LIKE 1) }  0
          871  +
          872  +do_execsql_test e_expr-13.2.19  { SELECT 0 AND 0 BETWEEN 0 AND 1   } 0
          873  +do_execsql_test e_expr-13.2.20  { SELECT 0 AND (0 BETWEEN 0 AND 1) } 0
          874  +do_execsql_test e_expr-13.2.21  { SELECT (0 AND 0) BETWEEN 0 AND 1 } 1
          875  +do_execsql_test e_expr-13.2.22  { SELECT 0 BETWEEN -1 AND 1 AND 0   } 0
          876  +do_execsql_test e_expr-13.2.23  { SELECT (0 BETWEEN -1 AND 1) AND 0 } 0
          877  +do_execsql_test e_expr-13.2.24  { SELECT 0 BETWEEN -1 AND (1 AND 0) } 1
          878  +
          879  +do_execsql_test e_expr-13.2.25  { SELECT 2 < 3 BETWEEN 0 AND 1   } 1
          880  +do_execsql_test e_expr-13.2.26  { SELECT (2 < 3) BETWEEN 0 AND 1 } 1
          881  +do_execsql_test e_expr-13.2.27  { SELECT 2 < (3 BETWEEN 0 AND 1) } 0
          882  +do_execsql_test e_expr-13.2.28  { SELECT 2 BETWEEN 1 AND 2 < 3    } 0
          883  +do_execsql_test e_expr-13.2.29  { SELECT 2 BETWEEN 1 AND (2 < 3)  } 0
          884  +do_execsql_test e_expr-13.2.30  { SELECT (2 BETWEEN 1 AND 2) < 3  } 1
   820    885   
   821    886   finish_test
   822         -