mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
Add the start of the "uri-filenames" feature.
FossilOrigin-Name: b8a8132e7148a7c90ca1352f20ab71d97b0bc4b0
This commit is contained in:
75
test/uri.test
Normal file
75
test/uri.test
Normal file
@ -0,0 +1,75 @@
|
||||
# 2011 April 22
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
set testprefix uri
|
||||
db close
|
||||
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_uri 1
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that file names are correctly extracted from URIs.
|
||||
#
|
||||
foreach {tn uri file} {
|
||||
1 test.db test.db
|
||||
2 file:test.db test.db
|
||||
3 file://an-authorityPWD/test.db test.db
|
||||
4 file:PWD/test.db test.db
|
||||
5 file:test.db?mork=1 test.db
|
||||
6 file:test.db?mork=1&tonglor=2 test.db
|
||||
7 file:test.db?mork=1#boris test.db
|
||||
8 file:test.db#boris test.db
|
||||
9 test.db#boris test.db#boris
|
||||
10 test.db?mork=1#boris test.db?mork=1#boris
|
||||
11 file:test%2Edb test.db
|
||||
12 file file
|
||||
13 http:test.db http:test.db
|
||||
} {
|
||||
set uri [string map [list PWD [pwd]] $uri]
|
||||
set file [string map [list PWD [pwd]] $file]
|
||||
|
||||
forcedelete $file
|
||||
do_test 1.$tn.1 { file exists $file } 0
|
||||
set DB [sqlite3_open $uri]
|
||||
do_test 1.$tn.2 { file exists $file } 1
|
||||
sqlite3_close $DB
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that URI query parameters are passed through to the VFS layer
|
||||
# correctly.
|
||||
#
|
||||
testvfs tvfs -default 1
|
||||
tvfs filter xOpen
|
||||
tvfs script open_method
|
||||
proc open_method {method file arglist} {
|
||||
set ::arglist $arglist
|
||||
}
|
||||
breakpoint
|
||||
foreach {tn uri kvlist} {
|
||||
1 file:test.db?hello=world {hello world}
|
||||
2 file:test.db?hello&world {hello {} world {}}
|
||||
3 file:test.db?hello=1&world=2&vfs=tvfs {hello 1 world 2 vfs tvfs}
|
||||
4 file:test.db?hello=1&world=2&vfs=unix {}
|
||||
} {
|
||||
set ::arglist ""
|
||||
set DB [sqlite3_open $uri]
|
||||
do_test 2.$tn { set ::arglist } $kvlist
|
||||
sqlite3_close $DB
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user