CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
extension01.test84 linesDownload Raw Back to test
1# 2014-06-162#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# 12# This file implements tests for various small extensions.13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set ::testprefix extension0118 19load_static_extension db fileio20do_test 1.0 {21  forcedelete file1.txt22  set out [open ./file1.txt wb]23  puts -nonewline $out "This is a text file without a line ending"24  close $out25  db eval {26    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);27    INSERT INTO t1 VALUES(1, readfile('./file1.txt'));28    SELECT * FROM t1;29  }30} {1 {This is a text file without a line ending}}31do_test 1.1 {32  forcedelete file2.txt33  db nullvalue nil34  db eval {35    DELETE FROM t1;36    INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));37    SELECT a, b, typeof(b) FROM t1;38  }39} {2 nil null 3 nil null}40 41do_test 1.2 {42  db eval {43    SELECT writefile('./file2.txt', 'A second test line');44  }45} {18}46do_test 1.3 {47  set in [open ./file2.txt rb]48  set x [read $in]49  close $in50  list $x [file size file2.txt]51} {{A second test line} 18}52 53do_test 1.4 {54  db eval {55    SELECT writefile('./file2.txt', NULL);56  }57} {0}58do_test 1.5 {59  file size ./file2.txt60} {0}61 62do_test 1.6 {63  if {$::tcl_platform(os) ne "Windows NT"} {64    file attributes ./file2.txt -permissions r--r--r--65  } else {66    file attributes ./file2.txt -readonly 167  }68  db eval {69    SELECT writefile('./file2.txt', 'Another test');70  }71} {nil}72do_test 1.7 {73  if {$::tcl_platform(os) ne "Windows NT"} {74    file attributes ./file2.txt -permissions rw-r--r--75  } else {76    file attributes ./file2.txt -readonly 077  }78  db eval {79    SELECT writefile(NULL, 'Another test');80  }81} {nil}82 83finish_test84