# 2021 July 6
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix rowvalueA

do_execsql_test 1.0 {
  SELECT (1, 2) IN ( (3, 4), (5, 6), (1, 3) );
} {0}

do_execsql_test 1.1 {
  SELECT (1, 2) IN ( (3, 4), (5, 6), (1, 2) );
} {1}

do_execsql_test 1.2 {
  SELECT (1, 2) IN ( (3, 2) );
} {0}

do_execsql_test 1.3 {
  SELECT (1, 2) IN ( (1, 2) );
} {1}

do_execsql_test 1.4 {
  SELECT (1, 2) IN ( );
} {0}

do_execsql_test 1.5 {
  SELECT (1, 2) NOT IN ( );
} {1}

for {set ii 0} {$ii < 2000} {incr ii} {
  lappend L "($ii, $ii)"
}

do_execsql_test 1.6.1 "
  SELECT (400,400) IN ( [join $L ,] )
" 1

do_execsql_test 1.6.2 "
  SELECT (1500,1500) IN ( [join $L ,] )
" 1

do_execsql_test 1.6.2 "
  SELECT (1500,1499) IN ( [join $L ,] )
" 0

#-------------------------------------------------------------------------

do_catchsql_test 2.0 {
  SELECT (1, 2) IN ( (1, 2), (3, 4, 5), (5, 6) )
} {1 {IN(...) element has 3 terms - expected 2}}

do_catchsql_test 2.1 {
  SELECT (1, 2) IN ( (1, 2), 4, (5, 6) )
} {1 {IN(...) element has 1 term - expected 2}}

do_catchsql_test 2.2 {
  SELECT (1, 2, 3) IN ( (1, 2), (3, 4), (5, 6) )
} {1 {IN(...) element has 2 terms - expected 3}}

do_catchsql_test 2.3 {
  SELECT 2 IN ( (1, 2), (3, 4), (5, 6) )
} {1 {row value misused}}

finish_test

