AryaWu/sqlite
0
1# 2016 December 172#3# The author disclaims copyright to this source code. In place of4# 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# TESTRUNNER: shell12#13# Test the readfile() function built into the shell tool. Specifically,14# that it does not truncate the blob read at the first embedded 0x0015# byte.16#17 18set testdir [file dirname $argv0]19source $testdir/tester.tcl20set testprefix shell721set CLI [test_find_cli]22 23 24do_execsql_test 1.0 { 25 CREATE TABLE f1(tn INTEGER PRIMARY KEY, x BLOB); 26 CREATE TABLE f2(tn INTEGER PRIMARY KEY, x BLOB); 27 28 INSERT INTO f1 VALUES(1, X'01020304');29 INSERT INTO f1 VALUES(2, X'01000304');30 INSERT INTO f1 VALUES(3, randomblob(200));31}32 33foreach {tn l x} [db eval { SELECT tn, length(x) AS l, x FROM f1 }] {34 forcedelete shell7_test.bin35 set fd [open shell7_test.bin w]36 fconfigure $fd -translation binary37 puts -nonewline $fd $x38 close $fd39 40 do_test 1.$tn.1 { file size shell7_test.bin } $l41 do_test 1.$tn.2 { 42 catchcmd test.db "INSERT INTO f2 VALUES($tn, readfile('shell7_test.bin'));"43 } {0 {}}44 45 do_execsql_test 1.$tn.3 { 46 SELECT (SELECT x FROM f1 WHERE tn=1)==(SELECT x FROM f2 WHERE tn=1)47 } {1}48}49 50 51 52finish_test53 