/ Check-in [f87ddf83]
Login

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

Overview
Comment:Test script changes that go with the coverage enhancements of the previous check-in. (CVS 4878)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f87ddf83a5d1340652f222972a7d75f4fdbe776b
User & Date: drh 2008-03-18 13:46:53
Context
2008-03-18
13:47
Update the documentation to distinguish between protected and unprotected sqlite3_value objects. (CVS 4879) check-in: 074ee55f user: drh tags: trunk
13:46
Test script changes that go with the coverage enhancements of the previous check-in. (CVS 4878) check-in: f87ddf83 user: drh tags: trunk
13:01
Minor test coverage enhancements. (CVS 4877) check-in: edd207b9 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/pragma.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
809
810
811
812
813
814
815

















816
817
818
819
820
821
822
823
824
825
826










827


828
829
830
831
832











833


834
835
836
837
838











839
840
841
842
843
844
845
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.57 2008/01/20 23:19:58 drh Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
do_test pragma-8.2.15 {
  execsql {
    PRAGMA user_version;
  }
} {-450}
} ; # ifcapable schema_version



















# Test temp_store and temp_store_directory pragmas
#
ifcapable pager_pragmas {
do_test pragma-9.1 {
  db close
  sqlite3 db test.db
  execsql {
    PRAGMA temp_store;
  }
} {0}










do_test pragma-9.2 {


  execsql {
    PRAGMA temp_store=file;
    PRAGMA temp_store;
  }
} {1}











do_test pragma-9.3 {


  execsql {
    PRAGMA temp_store=memory;
    PRAGMA temp_store;
  }
} {2}











do_test pragma-9.4 {
  execsql {
    PRAGMA temp_store_directory;
  }
} {}
do_test pragma-9.5 {
  set pwd [string map {' ''} [pwd]]







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>
>
>
>
>
>
>

>
>





>
>
>
>
>
>
>
>
>
>
>

>
>





>
>
>
>
>
>
>
>
>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.58 2008/03/18 13:46:53 drh Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
do_test pragma-8.2.15 {
  execsql {
    PRAGMA user_version;
  }
} {-450}
} ; # ifcapable schema_version

# Check to see if TEMP_STORE is memory or disk.  Return strings
# "memory" or "disk" as appropriate.
#
proc check_temp_store {} {
  db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)}
  db eval {PRAGMA database_list} {
    if {$name=="temp"} {
      if {$file==""} {
        return "memory"
      } else {
        return "disk"
      }
    }
  }
  return "unknown"
}


# Test temp_store and temp_store_directory pragmas
#
ifcapable pager_pragmas {
do_test pragma-9.1 {
  db close
  sqlite3 db test.db
  execsql {
    PRAGMA temp_store;
  }
} {0}
if {$TEMP_STORE<=1} {
  do_test pragma-9.1.1 {
    check_temp_store
  } {disk}
} else {
  do_test pragma-9.1.1 {
    check_temp_store
  } {memory}
}

do_test pragma-9.2 {
  db close
  sqlite3 db test.db
  execsql {
    PRAGMA temp_store=file;
    PRAGMA temp_store;
  }
} {1}
if {$TEMP_STORE==3} {
  # When TEMP_STORE is 3, always use memory regardless of pragma settings.
  do_test pragma-9.2.1 {
    check_temp_store
  } {memory}
} else {
  do_test pragma-9.2.1 {
    check_temp_store
  } {disk}
}

do_test pragma-9.3 {
  db close
  sqlite3 db test.db
  execsql {
    PRAGMA temp_store=memory;
    PRAGMA temp_store;
  }
} {2}
if {$TEMP_STORE==0} {
  # When TEMP_STORE is 0, always use the disk regardless of pragma settings.
  do_test pragma-9.3.1 {
    check_temp_store
  } {disk}
} else {
  do_test pragma-9.3.1 {
    check_temp_store
  } {memory}
}

do_test pragma-9.4 {
  execsql {
    PRAGMA temp_store_directory;
  }
} {}
do_test pragma-9.5 {
  set pwd [string map {' ''} [pwd]]

Changes to test/safety.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25














26
27
28
29
30
31
32
..
42
43
44
45
46
47
48





49
50
51
52
53
54
55
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff
# functions.  Those routines are not strictly necessary - they are
# designed to detect misuse of the library.
#
# $Id: safety.test,v 1.3 2008/01/23 03:03:05 drh Exp $

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

ifcapable !debug {
  puts "Skipping safety tests since SQLITE_DEBUG is off"
  finish_test
  return
}















do_test safety-1.1 {
  set DB [sqlite3_connection_pointer db]
  db eval {CREATE TABLE t1(a)}
  sqlite_set_magic $DB SQLITE_MAGIC_BUSY
  catchsql {
    SELECT name FROM sqlite_master;
................................................................................
do_test safety-2.1 {
  proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY"
  db function safety_on safety_on
  catchsql {
    SELECT safety_on(), name FROM sqlite_master
  }
} {1 {library routine called out of sequence}}





do_test safety-2.2 {
  catchsql {
    SELECT 'hello'
  }
} {1 {library routine called out of sequence}}
do_test safety-2.3 {
  sqlite3_close $DB







|









>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the sqlite3SafetyOn and sqlite3SafetyOff
# functions.  Those routines are not strictly necessary - they are
# designed to detect misuse of the library.
#
# $Id: safety.test,v 1.4 2008/03/18 13:46:53 drh Exp $

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

ifcapable !debug {
  puts "Skipping safety tests since SQLITE_DEBUG is off"
  finish_test
  return
}

# Return the UTF-8 representation of the supplied UTF-16 string $str. 
proc utf8 {str} {
  # If $str ends in two 0x00 0x00 bytes, knock these off before
  # converting to UTF-8 using TCL.
  binary scan $str \c* vals
  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
    set str [binary format \c* [lrange $vals 0 end-2]]
  }

  set r [encoding convertfrom unicode $str]
  return $r
}


do_test safety-1.1 {
  set DB [sqlite3_connection_pointer db]
  db eval {CREATE TABLE t1(a)}
  sqlite_set_magic $DB SQLITE_MAGIC_BUSY
  catchsql {
    SELECT name FROM sqlite_master;
................................................................................
do_test safety-2.1 {
  proc safety_on {} "sqlite_set_magic $DB SQLITE_MAGIC_BUSY"
  db function safety_on safety_on
  catchsql {
    SELECT safety_on(), name FROM sqlite_master
  }
} {1 {library routine called out of sequence}}
ifcapable {utf16} {
  do_test safety-2.1.1 {
    utf8 [sqlite3_errmsg16 db]
  } {library routine called out of sequence}
}
do_test safety-2.2 {
  catchsql {
    SELECT 'hello'
  }
} {1 {library routine called out of sequence}}
do_test safety-2.3 {
  sqlite3_close $DB