3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source [file join $testdir tester.tcl]
24 do_execsql_test 1.$tn.1 {
25 SELECT hex( unhex( $hex ) );
28 do_execsql_test 1.$tn.2 {
29 SELECT hex( unhex( lower( $hex ) ) );
34 SELECT typeof( unhex('') ), length( unhex('') );
43 do_execsql_test 2.$tn {
44 SELECT unhex( $hex ) IS NULL;
48 do_catchsql_test 3.0 {
50 } {1 {wrong number of arguments to function unhex()}}
51 do_catchsql_test 3.1 {
52 SELECT unhex('ABCD', '1234', '');
53 } {1 {wrong number of arguments to function unhex()}}
55 #--------------------------------------------------------------------------
56 # Test the 2-argument version.
68 foreach x [split $hex ""] {
69 if {[string is xdigit $x]} { append out $x }
72 do_execsql_test 5.$tn.1 {
73 SELECT hex( unhex($hex, ' -') );
78 SELECT typeof( unhex(' ', ' -') ), length( unhex('-', ' -') );
83 SELECT hex( unhex('\u0E01ABCD\u0E02', '\uE01\uE02') )
86 SELECT typeof( unhex('\u0E01ABCD\u0E02', '\uE03\uE02') )
89 SELECT hex( unhex('\u0E01AB CD\uE02\uE01', '\uE01 \uE02') )
92 #--------------------------------------------------------------------------
93 # Test that if either argument is NULL, the returned value is also NULL.
95 do_execsql_test 6.4.1 { SELECT typeof(unhex(NULL)) } {null}
96 do_execsql_test 6.4.2 { SELECT typeof(unhex(NULL, ' ')) } {null}
97 do_execsql_test 6.4.3 { SELECT typeof(unhex('1234', NULL)) } {null}