Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/sqlite/src/tool/shell4.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/tool/shell3.test ('k') | third_party/sqlite/src/tool/shell5.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/tool/shell4.test
diff --git a/third_party/sqlite/src/tool/shell4.test b/third_party/sqlite/src/tool/shell4.test
new file mode 100644
index 0000000000000000000000000000000000000000..085c279bb3148dc4ccda9a1c392613b78fc27e0d
--- /dev/null
+++ b/third_party/sqlite/src/tool/shell4.test
@@ -0,0 +1,129 @@
+# 2010 July 28
+#
+# 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.
+#
+#***********************************************************************
+#
+# The focus of this file is testing the CLI shell tool.
+# These tests are specific to the .stats command.
+#
+# $Id: shell4.test,v 1.7 2009/07/17 16:54:48 shaneh Exp $
+#
+
+# Test plan:
+#
+# shell4-1.*: Basic tests specific to the "stats" command.
+#
+
+set CLI "./sqlite3"
+
+proc do_test {name cmd expected} {
+ puts -nonewline "$name ..."
+ set res [uplevel $cmd]
+ if {$res eq $expected} {
+ puts Ok
+ } else {
+ puts Error
+ puts " Got: $res"
+ puts " Expected: $expected"
+ exit
+ }
+}
+
+proc catchcmd {db {cmd ""}} {
+ global CLI
+ set out [open cmds.txt w]
+ puts $out $cmd
+ close $out
+ set line "exec $CLI $db < cmds.txt"
+ set rc [catch { eval $line } msg]
+ list $rc $msg
+}
+
+file delete -force test.db test.db.journal
+
+#----------------------------------------------------------------------------
+# Test cases shell4-1.*: Tests specific to the "stats" command.
+#
+
+# should default to off
+do_test shell4-1.1.1 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {stats: off} $res]
+} {1}
+
+do_test shell4-1.1.2 {
+ set res [catchcmd "test.db" ".show"]
+ list [regexp {stats: on} $res]
+} {0}
+
+# -stats should turn it on
+do_test shell4-1.2.1 {
+ set res [catchcmd "-stats test.db" ".show"]
+ list [regexp {stats: on} $res]
+} {1}
+
+do_test shell4-1.2.2 {
+ set res [catchcmd "-stats test.db" ".show"]
+ list [regexp {stats: off} $res]
+} {0}
+
+# .stats ON|OFF Turn stats on or off
+do_test shell4-1.3.1 {
+ catchcmd "test.db" ".stats"
+} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
+do_test shell4-1.3.2 {
+ catchcmd "test.db" ".stats ON"
+} {0 {}}
+do_test shell4-1.3.3 {
+ catchcmd "test.db" ".stats OFF"
+} {0 {}}
+do_test shell4-1.3.4 {
+ # too many arguments
+ catchcmd "test.db" ".stats OFF BAD"
+} {1 {Error: unknown command or invalid arguments: "stats". Enter ".help" for help}}
+
+# NB. whitespace is important
+do_test shell4-1.4.1 {
+ set res [catchcmd "test.db" {.show}]
+ list [regexp {stats: off} $res]
+} {1}
+
+do_test shell4-1.4.2 {
+ set res [catchcmd "test.db" {.stats ON
+.show
+}]
+ list [regexp {stats: on} $res]
+} {1}
+
+do_test shell4-1.4.3 {
+ set res [catchcmd "test.db" {.stats OFF
+.show
+}]
+ list [regexp {stats: off} $res]
+} {1}
+
+# make sure stats not present when off
+do_test shell4-1.5.1 {
+ set res [catchcmd "test.db" {SELECT 1;}]
+ list [regexp {Memory Used} $res] \
+ [regexp {Heap Usage} $res] \
+ [regexp {Autoindex Inserts} $res]
+} {0 0 0}
+
+# make sure stats are present when on
+do_test shell4-1.5.2 {
+ set res [catchcmd "test.db" {.stats ON
+SELECT 1;
+}]
+ list [regexp {Memory Used} $res] \
+ [regexp {Heap Usage} $res] \
+ [regexp {Autoindex Inserts} $res]
+} {1 1 1}
+
+puts "CLI tests completed successfully"
« no previous file with comments | « third_party/sqlite/src/tool/shell3.test ('k') | third_party/sqlite/src/tool/shell5.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698