diff options
author | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 |
---|---|---|
committer | Hans-Christoph Steiner <hans@eds.org> | 2014-10-16 22:51:43 -0400 |
commit | 9f67c0520ea0d5f11a190197cdf746c512db4ce4 (patch) | |
tree | c88a33f01f20a3d13a09594f114fffacebd0d1a4 /test/extension01.test | |
parent | ee20336e9c78d2e3782c8d096b9ab4f6ca8ce95f (diff) | |
parent | 569c6676a6ddb0ff73821d7693b5e18ddef809b9 (diff) |
Merge tag 'upstream/3.2.0'
Upstream version 3.2.0
# gpg: Signature made Thu 16 Oct 2014 10:51:39 PM EDT using RSA key ID 374BBE81
# gpg: Good signature from "Hans-Christoph Steiner <hans@guardianproject.info>"
# gpg: aka "Hans-Christoph Steiner <hans@eds.org>"
# gpg: aka "Hans-Christoph Steiner <hans@at.or.at>"
# gpg: aka "[jpeg image of size 5408]"
Diffstat (limited to 'test/extension01.test')
-rw-r--r-- | test/extension01.test | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/test/extension01.test b/test/extension01.test new file mode 100644 index 0000000..97b7726 --- /dev/null +++ b/test/extension01.test @@ -0,0 +1,83 @@ +# 2014-06-16 +# +# 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 tests for various small extensions. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix extension01 + +load_static_extension db fileio +do_test 1.0 { + forcedelete file1.txt + set out [open ./file1.txt wb] + puts -nonewline $out "This is a text file without a line ending" + close $out + db eval { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); + INSERT INTO t1 VALUES(1, readfile('./file1.txt')); + SELECT * FROM t1; + } +} {1 {This is a text file without a line ending}} +do_test 1.1 { + forcedelete file2.txt + db nullvalue nil + db eval { + DELETE FROM t1; + INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt')); + SELECT a, b, typeof(b) FROM t1; + } +} {2 nil null 3 nil null} + +do_test 1.2 { + db eval { + SELECT writefile('./file2.txt', 'A second test line'); + } +} {18} +do_test 1.3 { + set in [open ./file2.txt rb] + set x [read $in] + close $in + list $x [file size file2.txt] +} {{A second test line} 18} + +do_test 1.4 { + db eval { + SELECT writefile('./file2.txt', NULL); + } +} {0} +do_test 1.5 { + file size ./file2.txt +} {0} + +do_test 1.6 { + if {$::tcl_platform(platform)=="unix"} { + file attributes ./file2.txt -permissions r--r--r-- + } else { + file attributes ./file2.txt -readonly 1 + } + db eval { + SELECT writefile('./file2.txt', 'Another test'); + } +} {nil} +do_test 1.7 { + if {$::tcl_platform(platform)=="unix"} { + file attributes ./file2.txt -permissions rw-r--r-- + } else { + file attributes ./file2.txt -readonly 0 + } + db eval { + SELECT writefile(NULL, 'Another test'); + } +} {nil} + +finish_test |