# 2014 September 15.
#
# 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 sort5


#-------------------------------------------------------------------------
# Verify that sorting works with a version 1 sqlite3_io_methods structure.
#
testvfs tvfs -iversion 1 -default true
reset_db
do_execsql_test 1.0 {
  PRAGMA mmap_size = 10000000;
  PRAGMA cache_size = 10;
  CREATE TABLE t1(a, b);
} {0}

do_test 1.1 {
  execsql BEGIN
  for {set i 0} {$i < 2000} {incr i} {
    execsql { INSERT INTO t1 VALUES($i, randomblob(2000)) }
  }
  execsql COMMIT
} {}

do_execsql_test 1.2 {
  CREATE INDEX i1 ON t1(b);
}

db close
tvfs delete
finish_test
