summaryrefslogtreecommitdiff
path: root/test/func3.test
blob: d5a462fe33e44f0e7fecf26576656d10d5ea70b2 (plain)
1
2
3
4
5
6
7
8
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# 2010 August 27
#
# 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. The
# focus of this file is testing that destructor functions associated
# with functions created using sqlite3_create_function_v2() is 
# correctly invoked.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl


ifcapable utf16 {
  do_test func3-1.1 {
    set destroyed 0
    proc destroy {} { set ::destroyed 1 }
    sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy
    set destroyed
  } 0
  do_test func3-1.2 {
    sqlite3_create_function_v2 db f2 -1 utf8 -func f2
    set destroyed
  } 0
  do_test func3-1.3 {
    sqlite3_create_function_v2 db f2 -1 utf16le -func f2
    set destroyed
  } 0
  do_test func3-1.4 {
    sqlite3_create_function_v2 db f2 -1 utf16be -func f2
    set destroyed
  } 1
}

do_test func3-2.1 {
  set destroyed 0
  proc destroy {} { set ::destroyed 1 }
  sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy
  set destroyed
} 0
do_test func3-2.2 {
  sqlite3_create_function_v2 db f3 -1 utf8 -func f3
  set destroyed
} 1

do_test func3-3.1 {
  set destroyed 0
  proc destroy {} { set ::destroyed 1 }
  sqlite3_create_function_v2 db f3 -1 any -func f3 -destroy destroy
  set destroyed
} 0
do_test func3-3.2 {
  db close
  set destroyed
} 1

sqlite3 db test.db
do_test func3-4.1 {
  set destroyed 0
  set rc [catch { 
    sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy
  } msg]
  list $rc $msg
} {1 SQLITE_MISUSE}
do_test func3-4.2 { set destroyed } 1

finish_test