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 #***********************************************************************
12 # This file implements tests for various small extensions.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set ::testprefix extension01
19 load_static_extension db fileio
22 set out [open ./file1.txt wb]
23 puts -nonewline $out "This is a text file without a line ending"
26 CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
27 INSERT INTO t1 VALUES(1, readfile('./file1.txt'));
30 } {1 {This is a text file without a line ending}}
36 INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));
37 SELECT a, b, typeof(b) FROM t1;
39 } {2 nil null 3 nil null}
43 SELECT writefile('./file2.txt', 'A second test line');
47 set in [open ./file2.txt rb]
50 list $x [file size file2.txt]
51 } {{A second test line} 18}
55 SELECT writefile('./file2.txt', NULL);
63 if {$::tcl_platform(platform)=="unix"} {
64 file attributes ./file2.txt -permissions r--r--r--
66 file attributes ./file2.txt -readonly 1
69 SELECT writefile('./file2.txt', 'Another test');
73 if {$::tcl_platform(platform)=="unix"} {
74 file attributes ./file2.txt -permissions rw-r--r--
76 file attributes ./file2.txt -readonly 0
79 SELECT writefile(NULL, 'Another test');