SQLite.dll — File Browser
SQLite.dllv0.5.3 / SQLite.dllv0.5.3 / test.mrc
test.mrc — 5.84 KB — Download this file
#sqlite_debug_dll off
; For testing your own Compiled Version
alias -l SQLite return $shortfn($+($scriptdir,src\Debug\sqlite.dll))
#sqlite_debug_dll end
alias -l SQLite return $shortfn($+($scriptdir,sqlite.dll))
#sqlite_debug off
; To Make debugging Clearer :D
alias SQLiteDll {
var %x = $dll($SQLite,$1,$iif($2- != $null,$2-,_))
if (E_* iswm %x) {
echo -a SQLiteDll:7 $+($1,:6) $+($2,:12) $3- $+(:4,%x)
return %x
}
echo -a SQLiteDll:7 $+($1,:6) $+($2,:12) $3- $+(:3,%x)
return %x
}
#sqlite_debug end
alias SQLiteDLL return $dll($SQLite,$1,$iif($2- != $null,$2-,_))
on *:load:{
.disable #sqlite_debug_dll
.disable #sqlite_debug
echo $color(info) -a * Loaded $SQLiteDLL(DllInfo)
echo $color(info) -a * Type /sqlite to test the Library...
}
alias sqlite {
var %dll_old
if ($1 == debug) %dll_old = $group(#sqlite_debug_dll)
var %old = $group(#sqlite_debug)
if (%dll_old && %dll_old != on) .enable #sqlite_debug_dll
if (%old != on) .enable #sqlite_debug
sqlite_test
if (%old != on) .disable #sqlite_debug
if (%dll_old && %dll_old != on) .disable #sqlite_debug_dll
}
alias sqlite_test {
echo -a Testing Opening Databases
; Open an in memory Database
SQLiteDLL Open test :memory:
; Close it...
SQLiteDLL Close test
; Open a Database for testing...
SQLiteDLL Open test $shortfn($scriptdird1.db)
; A Test
SQLiteDLL Open test $shortfn($scriptdird1.db)
echo -a Begining Transaction
; Begin a transaction...
SQLiteDLL Query test BEGIN TRANSACTION;
SQLiteDLL Query test BEGIN TRANSACTION;
echo -a Create a couple of Test Tables
; Create a couple of tables...
SQLiteDLL Query test CREATE TABLE t1 (f1,f2,f3,f4);
SQLiteDLL Query test CREATE TABLE t2 (f1,f2,f3,f4);
SQLiteDLL Query test CREATE TEMPORY TABLE t3 (f1,f2,f3,f4);
echo -a Testing Querys
; Test a few queries for Being Incorrect...
SQLiteDLL Query test SELECT * FROM
SQLiteDLL Query fred SELECT * FROM moo;
echo -a Commit Transaction
; Commit our transaction...
SQLiteDLL Query test COMMIT TRANSACTION;
SQLiteDLL Query test COMMIT TRANSACTION;
; Test a Valid Query... (this is the Same as "SHOW TABLES;" in MySQL).
SQLiteDLL Query test SELECT * $&
FROM sqlite_master $&
WHERE (type IN ('table','trigger')) $&
UNION ALL $&
SELECT * $&
FROM sqlite_temp_master $&
WHERE (type IN('table','trigger'));
echo -a Testing Fetch Data
; How many Rows were there?
SQLiteDLL Rows test
; How many Rows were affected?
SQLiteDLL RowsAffected test
; Get the Fields Separated by tab (default)
SQLiteDLL Fields test
; Get the Fields Separated by $chr(1)
SQLiteDLL Fields test 1
; Get row 1 (Separated by '#')
SQLiteDLL FetchRow test 1 #
; Get row 2 (Separated by '@')
SQLiteDLL FetchRow test 2 @
; Get row 4096 (obvious error)
SQLiteDLL FetchRow test 4098
; Get row Separated by $chr(1)
SQLiteDLL FetchRow test 1 $chr(1)
echo -a Freeing up Query Results...
; Free the Query Results (this is only if you dont plan on performin any more queries for the time being... :)
SQLiteDLL FreeQuery test
echo -a Destroy Tempory Databases
; Good Practice... :)
SQLiteDLL Query test BEGIN TRANSACTION;
; Destroy the two permanant Databases we Made
SQLiteDLL Query test DROP TABLE t1;
SQLiteDLL Query test DROP TABLE t2;
; :P
SQLiteDLL Query test COMMIT TRANSACTION;
SQLiteDLL Query test BEGIN TRANSACTION;
echo -a Testing misc. Pragma's
SQLiteDll Query test PRAGMA integrity_check;
SQLiteDLL Fields test
SQLiteDLL FetchRow test 1
echo -a Testing Fetch
; Testing Fetch
SQLiteDll Query test PRAGMA database_list;
; Total Number of Rows
SQLiteDLL Fetch test 0 1
; Total Number of Fields
SQLiteDLL Fetch test 1 0
; Total Number of Fields
SQLiteDLL Fetch test 1 1
SQLiteDLL Fetch test 1 2
SQLiteDLL Fetch test 1 3
SQLiteDLL Fetch test 1 4
SQLiteDLL Fetch test 2 seq
SQLiteDLL Fetch test 2 name
SQLiteDLL Fetch test 2 file
SQLiteDLL Fetch test 2 bob
SQLiteDLL Fetch test -1 -1
SQLiteDLL Fetch test 0 -1 !
SQLiteDLL Fetch test 1 -1 9
SQLiteDLL Fetch test 2 -1 255
SQLiteDLL Fetch test 3 -1 128
SQLiteDLL Fetch test -1 0
SQLiteDLL Fetch test -1 1
SQLiteDLL Fetch test -1 2
SQLiteDLL Fetch test -1 3
SQLiteDLL Fetch test -1 4
SQLiteDLL Fetch test 0
SQLiteDLL Fetch test 1
SQLiteDLL Fetch test 2
SQLiteDLL Fetch test 3
SQLiteDLL Query test COMMIT TRANSACTION;
echo -a Testing Closing Databases
; Close the Database
SQLiteDLL Close test
; error checking... weeeeeeeeeee
SQLiteDLL Close test
echo -a Testing Label Listing (Using InMemory Database)...
; Open a few In-Memory Databases...
SQLiteDLL Open test_a :memory:
SQLiteDLL Open test_b :memory:
SQLiteDLL Open test_c :memory:
; Findout the number of Labels Open...
SQLiteDLL Labels 0
; Label N# 1
SQLiteDLL Labels 1
; Label N# 2
SQLiteDLL Labels 2
; Label N# 3
SQLiteDLL Labels 3
; Label N# 4 (obvious error)
SQLiteDLL Labels 4
; Close the Databases
SQLiteDLL Close test_c
SQLiteDLL Close test_b
SQLiteDLL Close test_a
; Completed
echo -a Tests Completed...
dll -u $sqlite
}
;________________________________________________
;
; Auto Debug Calling Code...
;________________________________________________
;
on *:start:if (SQLITE_AUTO_*_TEST iswm $cmdline) .timersqlite_test 1 3 sqlite_auto_test
alias -l sqlite_auto_test {
var %old_dll = $group(#sqlite_debug_dll)
var %old = $group(#sqlite_debug )
if (RELEASE isin $cmdline) .disable #sqlite_debug_dll
if (DEBUG isin $cmdline) .enable #sqlite_debug_dll
if (%old != on) .enable #sqlite_debug
sqlite_test
if (%old != on) .disable #sqlite_debug
$iif(%old_dll == on,.enable,.disable) #sqlite_debug_dll
}