~ubuntu-branches/ubuntu/maverick/sqlite3/maverick-updates

« back to all changes in this revision

Viewing changes to test/safety.test

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2008-10-01 20:16:18 UTC
  • mfrom: (3.1.20 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081001201618-yfvqqj1qs29wdtcc
Tags: 3.5.9-5
Backport fix for distinct on indexes (closes: #500792).

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# functions.  Those routines are not strictly necessary - they are
14
14
# designed to detect misuse of the library.
15
15
#
16
 
# $Id: safety.test,v 1.2 2006/01/03 00:33:50 drh Exp $
 
16
# $Id: safety.test,v 1.4 2008/03/18 13:46:53 drh Exp $
17
17
 
18
18
set testdir [file dirname $argv0]
19
19
source $testdir/tester.tcl
20
20
 
 
21
ifcapable !debug {
 
22
  puts "Skipping safety tests since SQLITE_DEBUG is off"
 
23
  finish_test
 
24
  return
 
25
}
 
26
 
 
27
# Return the UTF-8 representation of the supplied UTF-16 string $str. 
 
28
proc utf8 {str} {
 
29
  # If $str ends in two 0x00 0x00 bytes, knock these off before
 
30
  # converting to UTF-8 using TCL.
 
31
  binary scan $str \c* vals
 
32
  if {[lindex $vals end]==0 && [lindex $vals end-1]==0} {
 
33
    set str [binary format \c* [lrange $vals 0 end-2]]
 
34
  }
 
35
 
 
36
  set r [encoding convertfrom unicode $str]
 
37
  return $r
 
38
}
 
39
 
 
40
 
21
41
do_test safety-1.1 {
22
42
  set DB [sqlite3_connection_pointer db]
23
43
  db eval {CREATE TABLE t1(a)}
40
60
    SELECT safety_on(), name FROM sqlite_master
41
61
  }
42
62
} {1 {library routine called out of sequence}}
 
63
ifcapable {utf16} {
 
64
  do_test safety-2.1.1 {
 
65
    utf8 [sqlite3_errmsg16 db]
 
66
  } {library routine called out of sequence}
 
67
}
43
68
do_test safety-2.2 {
44
69
  catchsql {
45
70
    SELECT 'hello'