Home | History | Annotate | Download | only in test
      1 # 2010 August 27
      2 #
      3 # The author disclaims copyright to this source code.  In place of
      4 # a legal notice, here is a blessing:
      5 #
      6 #    May you do good and not evil.
      7 #    May you find forgiveness for yourself and forgive others.
      8 #    May you share freely, never taking more than you give.
      9 #
     10 #***********************************************************************
     11 # This file implements regression tests for SQLite library. The
     12 # focus of this file is testing that destructor functions associated
     13 # with functions created using sqlite3_create_function_v2() is 
     14 # correctly invoked.
     15 #
     16 set testdir [file dirname $argv0]
     17 source $testdir/tester.tcl
     18 
     19 
     20 do_test func3-1.1 {
     21   set destroyed 0
     22   proc destroy {} { set ::destroyed 1 }
     23   sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy
     24   set destroyed
     25 } 0
     26 do_test func3-1.2 {
     27   sqlite3_create_function_v2 db f2 -1 utf8 -func f2
     28   set destroyed
     29 } 0
     30 do_test func3-1.3 {
     31   sqlite3_create_function_v2 db f2 -1 utf16le -func f2
     32   set destroyed
     33 } 0
     34 do_test func3-1.4 {
     35   sqlite3_create_function_v2 db f2 -1 utf16be -func f2
     36   set destroyed
     37 } 1
     38 
     39 do_test func3-2.1 {
     40   set destroyed 0
     41   proc destroy {} { set ::destroyed 1 }
     42   sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy
     43   set destroyed
     44 } 0
     45 do_test func3-2.2 {
     46   sqlite3_create_function_v2 db f3 -1 utf8 -func f3
     47   set destroyed
     48 } 1
     49 
     50 do_test func3-3.1 {
     51   set destroyed 0
     52   proc destroy {} { set ::destroyed 1 }
     53   sqlite3_create_function_v2 db f3 -1 any -func f3 -destroy destroy
     54   set destroyed
     55 } 0
     56 do_test func3-3.2 {
     57   db close
     58   set destroyed
     59 } 1
     60 
     61 sqlite3 db test.db
     62 do_test func3-4.1 {
     63   set destroyed 0
     64   set rc [catch { 
     65     sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy
     66   } msg]
     67   list $rc $msg
     68 } {1 SQLITE_MISUSE}
     69 do_test func3-4.2 { set destroyed } 1
     70 
     71 finish_test
     72