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

Side by Side Diff: third_party/sqlite/src/test/shell1.test

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/shared4.test ('k') | third_party/sqlite/src/test/shell2.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2009 Nov 11 1 # 2009 Nov 11
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
(...skipping 27 matching lines...) Expand all
38 # Test cases shell1-1.*: Basic command line option handling. 38 # Test cases shell1-1.*: Basic command line option handling.
39 # 39 #
40 40
41 # invalid option 41 # invalid option
42 do_test shell1-1.1.1 { 42 do_test shell1-1.1.1 {
43 set res [catchcmd "-bad test.db" ""] 43 set res [catchcmd "-bad test.db" ""]
44 set rc [lindex $res 0] 44 set rc [lindex $res 0]
45 list $rc \ 45 list $rc \
46 [regexp {Error: unknown option: -bad} $res] 46 [regexp {Error: unknown option: -bad} $res]
47 } {1 1} 47 } {1 1}
48 do_test shell1-1.1.1b {
49 set res [catchcmd "test.db -bad" ""]
50 set rc [lindex $res 0]
51 list $rc \
52 [regexp {Error: unknown option: -bad} $res]
53 } {1 1}
48 # error on extra options 54 # error on extra options
49 do_test shell1-1.1.2 { 55 do_test shell1-1.1.2 {
50 set res [catchcmd "-bad test.db \"select 3\" \"select 4\"" ""] 56 catchcmd "test.db \"select 3\" \"select 4\"" ""
51 set rc [lindex $res 0] 57 } {0 {3
52 list $rc \ 58 4}}
53 [regexp {Error: too many options: "select 4"} $res]
54 } {1 1}
55 # error on extra options 59 # error on extra options
56 do_test shell1-1.1.3 { 60 do_test shell1-1.1.3 {
57 set res [catchcmd "-bad FOO test.db BAD" ".quit"] 61 catchcmd "test.db FOO test.db BAD" ".quit"
58 set rc [lindex $res 0] 62 } {1 {Error: near "FOO": syntax error}}
59 list $rc \
60 [regexp {Error: too many options: "BAD"} $res]
61 } {1 1}
62 63
63 # -help 64 # -help
64 do_test shell1-1.2.1 { 65 do_test shell1-1.2.1 {
65 set res [catchcmd "-help test.db" ""] 66 set res [catchcmd "-help test.db" ""]
66 set rc [lindex $res 0] 67 set rc [lindex $res 0]
67 list $rc \ 68 list $rc \
68 [regexp {Usage} $res] \ 69 [regexp {Usage} $res] \
69 [regexp {\-init} $res] \ 70 [regexp {\-init} $res] \
70 [regexp {\-version} $res] 71 [regexp {\-version} $res]
71 } {1 1 1 1} 72 } {1 1 1 1}
72 73
73 # -init filename read/process named file 74 # -init filename read/process named file
74 do_test shell1-1.3.1 { 75 do_test shell1-1.3.1 {
75 catchcmd "-init FOO test.db" "" 76 catchcmd "-init FOO test.db" ""
76 } {0 {}} 77 } {0 {}}
77 do_test shell1-1.3.2 { 78 do_test shell1-1.3.2 {
78 set res [catchcmd "-init FOO test.db .quit BAD" ""] 79 catchcmd "-init FOO test.db .quit BAD" ""
79 set rc [lindex $res 0] 80 } {0 {}}
80 list $rc \ 81 do_test shell1-1.3.3 {
81 [regexp {Error: too many options: "BAD"} $res] 82 catchcmd "-init FOO test.db BAD .quit" ""
82 } {1 1} 83 } {1 {Error: near "BAD": syntax error}}
83 84
84 # -echo print commands before execution 85 # -echo print commands before execution
85 do_test shell1-1.4.1 { 86 do_test shell1-1.4.1 {
86 catchcmd "-echo test.db" "" 87 catchcmd "-echo test.db" ""
87 } {0 {}} 88 } {0 {}}
88 89
89 # -[no]header turn headers on or off 90 # -[no]header turn headers on or off
90 do_test shell1-1.5.1 { 91 do_test shell1-1.5.1 {
91 catchcmd "-header test.db" "" 92 catchcmd "-header test.db" ""
92 } {0 {}} 93 } {0 {}}
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 catchcmd "test.db" ".\'foo OFF" 200 catchcmd "test.db" ".\'foo OFF"
200 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}} 201 } {1 {Error: unknown command or invalid arguments: "foo OFF". Enter ".help" for help}}
201 do_test shell1-2.2.3 { 202 do_test shell1-2.2.3 {
202 catchcmd "test.db" ".explain \"OFF" 203 catchcmd "test.db" ".explain \"OFF"
203 } {0 {}} 204 } {0 {}}
204 do_test shell1-2.2.4 { 205 do_test shell1-2.2.4 {
205 catchcmd "test.db" ".explain \'OFF" 206 catchcmd "test.db" ".explain \'OFF"
206 } {0 {}} 207 } {0 {}}
207 do_test shell1-2.2.5 { 208 do_test shell1-2.2.5 {
208 catchcmd "test.db" ".mode \"insert FOO" 209 catchcmd "test.db" ".mode \"insert FOO"
209 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 210 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
210 do_test shell1-2.2.6 { 211 do_test shell1-2.2.6 {
211 catchcmd "test.db" ".mode \'insert FOO" 212 catchcmd "test.db" ".mode \'insert FOO"
212 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 213 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
213 214
214 # check multiple tokens, and quoted tokens 215 # check multiple tokens, and quoted tokens
215 do_test shell1-2.3.1 { 216 do_test shell1-2.3.1 {
216 catchcmd "test.db" ".explain 1" 217 catchcmd "test.db" ".explain 1"
217 } {0 {}} 218 } {0 {}}
218 do_test shell1-2.3.2 { 219 do_test shell1-2.3.2 {
219 catchcmd "test.db" ".explain on" 220 catchcmd "test.db" ".explain on"
220 } {0 {}} 221 } {0 {}}
221 do_test shell1-2.3.3 { 222 do_test shell1-2.3.3 {
222 catchcmd "test.db" ".explain \"1 2 3\"" 223 catchcmd "test.db" ".explain \"1 2 3\""
223 } {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}} 224 } {1 {ERROR: Not a boolean value: "1 2 3". Assuming "no".}}
224 do_test shell1-2.3.4 { 225 do_test shell1-2.3.4 {
225 catchcmd "test.db" ".explain \"OFF\"" 226 catchcmd "test.db" ".explain \"OFF\""
226 } {0 {}} 227 } {0 {}}
227 do_test shell1-2.3.5 { 228 do_test shell1-2.3.5 {
228 catchcmd "test.db" ".\'explain\' \'OFF\'" 229 catchcmd "test.db" ".\'explain\' \'OFF\'"
229 } {0 {}} 230 } {0 {}}
230 do_test shell1-2.3.6 { 231 do_test shell1-2.3.6 {
231 catchcmd "test.db" ".explain \'OFF\'" 232 catchcmd "test.db" ".explain \'OFF\'"
232 } {0 {}} 233 } {0 {}}
233 do_test shell1-2.3.7 { 234 do_test shell1-2.3.7 {
234 catchcmd "test.db" ".\'explain\' \'OFF\'" 235 catchcmd "test.db" ".\'explain\' \'OFF\'"
235 } {0 {}} 236 } {0 {}}
236 237
237 # check quoted args are unquoted 238 # check quoted args are unquoted
238 do_test shell1-2.4.1 { 239 do_test shell1-2.4.1 {
239 catchcmd "test.db" ".mode FOO" 240 catchcmd "test.db" ".mode FOO"
240 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 241 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
241 do_test shell1-2.4.2 { 242 do_test shell1-2.4.2 {
242 catchcmd "test.db" ".mode csv" 243 catchcmd "test.db" ".mode csv"
243 } {0 {}} 244 } {0 {}}
244 do_test shell1-2.4.2 { 245 do_test shell1-2.4.2 {
245 catchcmd "test.db" ".mode \"csv\"" 246 catchcmd "test.db" ".mode \"csv\""
246 } {0 {}} 247 } {0 {}}
247 248
248 249
249 #---------------------------------------------------------------------------- 250 #----------------------------------------------------------------------------
250 # Test cases shell1-3.*: Basic test that "dot" command can be called. 251 # Test cases shell1-3.*: Basic test that "dot" command can be called.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 catchcmd "test.db" ".import FOO" 399 catchcmd "test.db" ".import FOO"
399 } {1 {Usage: .import FILE TABLE}} 400 } {1 {Usage: .import FILE TABLE}}
400 #do_test shell1-3.11.2 { 401 #do_test shell1-3.11.2 {
401 # catchcmd "test.db" ".import FOO BAR" 402 # catchcmd "test.db" ".import FOO BAR"
402 #} {1 {Error: no such table: BAR}} 403 #} {1 {Error: no such table: BAR}}
403 do_test shell1-3.11.3 { 404 do_test shell1-3.11.3 {
404 # too many arguments 405 # too many arguments
405 catchcmd "test.db" ".import FOO BAR BAD" 406 catchcmd "test.db" ".import FOO BAR BAD"
406 } {1 {Usage: .import FILE TABLE}} 407 } {1 {Usage: .import FILE TABLE}}
407 408
408 # .indices ?TABLE? Show names of all indices 409 # .indexes ?TABLE? Show names of all indexes
409 # If TABLE specified, only show indices for tables 410 # If TABLE specified, only show indexes for tables
410 # matching LIKE pattern TABLE. 411 # matching LIKE pattern TABLE.
411 do_test shell1-3.12.1 { 412 do_test shell1-3.12.1 {
412 catchcmd "test.db" ".indices" 413 catchcmd "test.db" ".indexes"
413 } {0 {}} 414 } {0 {}}
414 do_test shell1-3.12.2 { 415 do_test shell1-3.12.2 {
416 catchcmd "test.db" ".indexes FOO"
417 } {0 {}}
418 do_test shell1-3.12.2-legacy {
415 catchcmd "test.db" ".indices FOO" 419 catchcmd "test.db" ".indices FOO"
416 } {0 {}} 420 } {0 {}}
417 do_test shell1-3.12.3 { 421 do_test shell1-3.12.3 {
418 # too many arguments 422 # too many arguments
419 catchcmd "test.db" ".indices FOO BAD" 423 catchcmd "test.db" ".indexes FOO BAD"
420 } {1 {Usage: .indices ?LIKE-PATTERN?}} 424 } {1 {Usage: .indexes ?LIKE-PATTERN?}}
421 425
422 # .mode MODE ?TABLE? Set output mode where MODE is one of: 426 # .mode MODE ?TABLE? Set output mode where MODE is one of:
427 # ascii Columns/rows delimited by 0x1F and 0x1E
423 # csv Comma-separated values 428 # csv Comma-separated values
424 # column Left-aligned columns. (See .width) 429 # column Left-aligned columns. (See .width)
425 # html HTML <table> code 430 # html HTML <table> code
426 # insert SQL insert statements for TABLE 431 # insert SQL insert statements for TABLE
427 # line One value per line 432 # line One value per line
428 # list Values delimited by .separator string 433 # list Values delimited by .separator strings
429 # tabs Tab-separated values 434 # tabs Tab-separated values
430 # tcl TCL list elements 435 # tcl TCL list elements
431 do_test shell1-3.13.1 { 436 do_test shell1-3.13.1 {
432 catchcmd "test.db" ".mode" 437 catchcmd "test.db" ".mode"
433 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 438 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
434 do_test shell1-3.13.2 { 439 do_test shell1-3.13.2 {
435 catchcmd "test.db" ".mode FOO" 440 catchcmd "test.db" ".mode FOO"
436 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 441 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
437 do_test shell1-3.13.3 { 442 do_test shell1-3.13.3 {
438 catchcmd "test.db" ".mode csv" 443 catchcmd "test.db" ".mode csv"
439 } {0 {}} 444 } {0 {}}
440 do_test shell1-3.13.4 { 445 do_test shell1-3.13.4 {
441 catchcmd "test.db" ".mode column" 446 catchcmd "test.db" ".mode column"
442 } {0 {}} 447 } {0 {}}
443 do_test shell1-3.13.5 { 448 do_test shell1-3.13.5 {
444 catchcmd "test.db" ".mode html" 449 catchcmd "test.db" ".mode html"
445 } {0 {}} 450 } {0 {}}
446 do_test shell1-3.13.6 { 451 do_test shell1-3.13.6 {
(...skipping 12 matching lines...) Expand all
459 catchcmd "test.db" ".mode tcl" 464 catchcmd "test.db" ".mode tcl"
460 } {0 {}} 465 } {0 {}}
461 do_test shell1-3.13.11 { 466 do_test shell1-3.13.11 {
462 # extra arguments ignored 467 # extra arguments ignored
463 catchcmd "test.db" ".mode tcl BAD" 468 catchcmd "test.db" ".mode tcl BAD"
464 } {0 {}} 469 } {0 {}}
465 470
466 # don't allow partial mode type matches 471 # don't allow partial mode type matches
467 do_test shell1-3.13.12 { 472 do_test shell1-3.13.12 {
468 catchcmd "test.db" ".mode l" 473 catchcmd "test.db" ".mode l"
469 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 474 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
470 do_test shell1-3.13.13 { 475 do_test shell1-3.13.13 {
471 catchcmd "test.db" ".mode li" 476 catchcmd "test.db" ".mode li"
472 } {1 {Error: mode should be one of: column csv html insert line list tabs tcl}} 477 } {1 {Error: mode should be one of: ascii column csv html insert line list tabs tcl}}
473 do_test shell1-3.13.14 { 478 do_test shell1-3.13.14 {
474 catchcmd "test.db" ".mode lin" 479 catchcmd "test.db" ".mode lin"
475 } {0 {}} 480 } {0 {}}
476 481
477 # .nullvalue STRING Print STRING in place of NULL values 482 # .nullvalue STRING Print STRING in place of NULL values
478 do_test shell1-3.14.1 { 483 do_test shell1-3.14.1 {
479 catchcmd "test.db" ".nullvalue" 484 catchcmd "test.db" ".nullvalue"
480 } {1 {Usage: .nullvalue STRING}} 485 } {1 {Usage: .nullvalue STRING}}
481 do_test shell1-3.14.2 { 486 do_test shell1-3.14.2 {
482 catchcmd "test.db" ".nullvalue FOO" 487 catchcmd "test.db" ".nullvalue FOO"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 CREATE TABLE t1(x); 583 CREATE TABLE t1(x);
579 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; 584 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
580 CREATE VIEW v1 AS SELECT y+1 FROM v2; 585 CREATE VIEW v1 AS SELECT y+1 FROM v2;
581 } 586 }
582 catchcmd "test.db" ".schema" 587 catchcmd "test.db" ".schema"
583 } {0 {CREATE TABLE t1(x); 588 } {0 {CREATE TABLE t1(x);
584 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1; 589 CREATE VIEW v2 AS SELECT x+1 AS y FROM t1;
585 CREATE VIEW v1 AS SELECT y+1 FROM v2;}} 590 CREATE VIEW v1 AS SELECT y+1 FROM v2;}}
586 db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;} 591 db eval {DROP VIEW v1; DROP VIEW v2; DROP TABLE t1;}
587 592
588 # .separator STRING Change separator used by output mode and .import 593 # .separator STRING Change column separator used by output and .import
589 do_test shell1-3.22.1 { 594 do_test shell1-3.22.1 {
590 catchcmd "test.db" ".separator" 595 catchcmd "test.db" ".separator"
591 } {1 {Usage: .separator SEPARATOR ?NEWLINE?}} 596 } {1 {Usage: .separator COL ?ROW?}}
592 do_test shell1-3.22.2 { 597 do_test shell1-3.22.2 {
593 catchcmd "test.db" ".separator FOO" 598 catchcmd "test.db" ".separator FOO"
594 } {0 {}} 599 } {0 {}}
595 do_test shell1-3.22.3 { 600 do_test shell1-3.22.3 {
596 catchcmd "test.db" ".separator ABC XYZ" 601 catchcmd "test.db" ".separator ABC XYZ"
597 } {0 {}} 602 } {0 {}}
598 do_test shell1-3.22.4 { 603 do_test shell1-3.22.4 {
599 # too many arguments 604 # too many arguments
600 catchcmd "test.db" ".separator FOO BAD BAD2" 605 catchcmd "test.db" ".separator FOO BAD BAD2"
601 } {1 {Usage: .separator SEPARATOR ?NEWLINE?}} 606 } {1 {Usage: .separator COL ?ROW?}}
602 607
603 # .show Show the current values for various settings 608 # .show Show the current values for various settings
604 do_test shell1-3.23.1 { 609 do_test shell1-3.23.1 {
605 set res [catchcmd "test.db" ".show"] 610 set res [catchcmd "test.db" ".show"]
606 list [regexp {echo:} $res] \ 611 list [regexp {echo:} $res] \
607 [regexp {explain:} $res] \ 612 [regexp {explain:} $res] \
608 [regexp {headers:} $res] \ 613 [regexp {headers:} $res] \
609 [regexp {mode:} $res] \ 614 [regexp {mode:} $res] \
610 [regexp {nullvalue:} $res] \ 615 [regexp {nullvalue:} $res] \
611 [regexp {output:} $res] \ 616 [regexp {output:} $res] \
612 [regexp {separator:} $res] \ 617 [regexp {colseparator:} $res] \
618 [regexp {rowseparator:} $res] \
613 [regexp {stats:} $res] \ 619 [regexp {stats:} $res] \
614 [regexp {width:} $res] 620 [regexp {width:} $res]
615 } {1 1 1 1 1 1 1 1 1} 621 } {1 1 1 1 1 1 1 1 1 1}
616 do_test shell1-3.23.2 { 622 do_test shell1-3.23.2 {
617 # too many arguments 623 # too many arguments
618 catchcmd "test.db" ".show BAD" 624 catchcmd "test.db" ".show BAD"
619 } {1 {Usage: .show}} 625 } {1 {Usage: .show}}
620 626
621 # .stats ON|OFF Turn stats on or off 627 # .stats ON|OFF Turn stats on or off
622 do_test shell1-3.23b.1 { 628 do_test shell1-3.23b.1 {
623 catchcmd "test.db" ".stats" 629 catchcmd "test.db" ".stats"
624 } {1 {Usage: .stats on|off}} 630 } {1 {Usage: .stats on|off}}
625 do_test shell1-3.23b.2 { 631 do_test shell1-3.23b.2 {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 # Test the output of the ".dump" command 731 # Test the output of the ".dump" command
726 # 732 #
727 do_test shell1-4.1 { 733 do_test shell1-4.1 {
728 db close 734 db close
729 forcedelete test.db 735 forcedelete test.db
730 sqlite3 db test.db 736 sqlite3 db test.db
731 db eval { 737 db eval {
732 PRAGMA encoding=UTF16; 738 PRAGMA encoding=UTF16;
733 CREATE TABLE t1(x); 739 CREATE TABLE t1(x);
734 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f'); 740 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
741 CREATE TABLE t3(x,y);
742 INSERT INTO t3 VALUES(1,null), (2,''), (3,1),
743 (4,2.25), (5,'hello'), (6,x'807f');
735 } 744 }
736 catchcmd test.db {.dump} 745 catchcmd test.db {.dump}
737 } {0 {PRAGMA foreign_keys=OFF; 746 } {0 {PRAGMA foreign_keys=OFF;
738 BEGIN TRANSACTION; 747 BEGIN TRANSACTION;
739 CREATE TABLE t1(x); 748 CREATE TABLE t1(x);
740 INSERT INTO "t1" VALUES(NULL); 749 INSERT INTO "t1" VALUES(NULL);
741 INSERT INTO "t1" VALUES(''); 750 INSERT INTO "t1" VALUES('');
742 INSERT INTO "t1" VALUES(1); 751 INSERT INTO "t1" VALUES(1);
743 INSERT INTO "t1" VALUES(2.25); 752 INSERT INTO "t1" VALUES(2.25);
744 INSERT INTO "t1" VALUES('hello'); 753 INSERT INTO "t1" VALUES('hello');
745 INSERT INTO "t1" VALUES(X'807F'); 754 INSERT INTO "t1" VALUES(X'807F');
755 CREATE TABLE t3(x,y);
756 INSERT INTO "t3" VALUES(1,NULL);
757 INSERT INTO "t3" VALUES(2,'');
758 INSERT INTO "t3" VALUES(3,1);
759 INSERT INTO "t3" VALUES(4,2.25);
760 INSERT INTO "t3" VALUES(5,'hello');
761 INSERT INTO "t3" VALUES(6,X'807F');
746 COMMIT;}} 762 COMMIT;}}
747 763
748 # Test the output of ".mode insert" 764 # Test the output of ".mode insert"
749 # 765 #
750 do_test shell1-4.2 { 766 do_test shell1-4.2.1 {
751 catchcmd test.db ".mode insert t1\nselect * from t1;" 767 catchcmd test.db ".mode insert t1\nselect * from t1;"
752 } {0 {INSERT INTO t1 VALUES(NULL); 768 } {0 {INSERT INTO t1 VALUES(NULL);
753 INSERT INTO t1 VALUES(''); 769 INSERT INTO t1 VALUES('');
754 INSERT INTO t1 VALUES(1); 770 INSERT INTO t1 VALUES(1);
755 INSERT INTO t1 VALUES(2.25); 771 INSERT INTO t1 VALUES(2.25);
756 INSERT INTO t1 VALUES('hello'); 772 INSERT INTO t1 VALUES('hello');
757 INSERT INTO t1 VALUES(X'807f');}} 773 INSERT INTO t1 VALUES(X'807f');}}
758 774
775 # Test the output of ".mode insert" with headers
776 #
777 do_test shell1-4.2.2 {
778 catchcmd test.db ".mode insert t1\n.headers on\nselect * from t1;"
779 } {0 {INSERT INTO t1(x) VALUES(NULL);
780 INSERT INTO t1(x) VALUES('');
781 INSERT INTO t1(x) VALUES(1);
782 INSERT INTO t1(x) VALUES(2.25);
783 INSERT INTO t1(x) VALUES('hello');
784 INSERT INTO t1(x) VALUES(X'807f');}}
785
786 # Test the output of ".mode insert"
787 #
788 do_test shell1-4.2.3 {
789 catchcmd test.db ".mode insert t3\nselect * from t3;"
790 } {0 {INSERT INTO t3 VALUES(1,NULL);
791 INSERT INTO t3 VALUES(2,'');
792 INSERT INTO t3 VALUES(3,1);
793 INSERT INTO t3 VALUES(4,2.25);
794 INSERT INTO t3 VALUES(5,'hello');
795 INSERT INTO t3 VALUES(6,X'807f');}}
796
797 # Test the output of ".mode insert" with headers
798 #
799 do_test shell1-4.2.4 {
800 catchcmd test.db ".mode insert t3\n.headers on\nselect * from t3;"
801 } {0 {INSERT INTO t3(x,y) VALUES(1,NULL);
802 INSERT INTO t3(x,y) VALUES(2,'');
803 INSERT INTO t3(x,y) VALUES(3,1);
804 INSERT INTO t3(x,y) VALUES(4,2.25);
805 INSERT INTO t3(x,y) VALUES(5,'hello');
806 INSERT INTO t3(x,y) VALUES(6,X'807f');}}
807
759 # Test the output of ".mode tcl" 808 # Test the output of ".mode tcl"
760 # 809 #
761 do_test shell1-4.3 { 810 do_test shell1-4.3 {
762 db close 811 db close
763 forcedelete test.db 812 forcedelete test.db
764 sqlite3 db test.db 813 sqlite3 db test.db
765 db eval { 814 db eval {
766 PRAGMA encoding=UTF8; 815 PRAGMA encoding=UTF8;
767 CREATE TABLE t1(x); 816 CREATE TABLE t1(x);
768 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f'); 817 INSERT INTO t1 VALUES(null), (''), (1), (2.25), ('hello'), (x'807f');
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break 854 foreach {x y} [catchcmd test.db ".mode tcl\nselect * from tcl1;"] break
806 list $x $y [llength $y] 855 list $x $y [llength $y]
807 } {0 {"\"" 856 } {0 {"\""
808 "[" 857 "["
809 "]" 858 "]"
810 "\\{" 859 "\\{"
811 "\\}" 860 "\\}"
812 ";" 861 ";"
813 "$"} 7} 862 "$"} 7}
814 863
864 # Test using arbitrary byte data with the shell via standard input/output.
865 #
866 do_test shell1-5.0 {
867 #
868 # NOTE: Skip NUL byte because it appears to be incompatible with command
869 # shell argument parsing.
870 #
871 for {set i 1} {$i < 256} {incr i} {
872 #
873 # NOTE: Due to how the Tcl [exec] command works (i.e. where it treats
874 # command channels opened for it as textual ones), the carriage
875 # return character (and on Windows, the end-of-file character)
876 # cannot be used here.
877 #
878 if {$i==0x0D || ($tcl_platform(platform)=="windows" && $i==0x1A)} {
879 continue
880 }
881 set hex [format %02X $i]
882 set char [subst \\x$hex]; set oldChar $char
883 set escapes [list]
884 if {$tcl_platform(platform)=="windows"} {
885 #
886 # NOTE: On Windows, we need to escape all the whitespace characters,
887 # the alarm (\a) character, and those with special meaning to
888 # the SQLite shell itself.
889 #
890 set escapes [list \
891 \a \\a \b \\b \t \\t \n \\n \v \\v \f \\f \r \\r \
892 " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
893 } else {
894 #
895 # NOTE: On Unix, we need to escape most of the whitespace characters
896 # and those with special meaning to the SQLite shell itself.
897 # The alarm (\a), backspace (\b), and carriage-return (\r)
898 # characters do not appear to require escaping on Unix. For
899 # the alarm and backspace characters, this is probably due to
900 # differences in the command shell. For the carriage-return,
901 # it is probably due to differences in how Tcl handles command
902 # channel end-of-line translations.
903 #
904 set escapes [list \
905 \t \\t \n \\n \v \\v \f \\f \
906 " " "\" \"" \" \\\" ' \"'\" \\ \\\\]
907 }
908 set char [string map $escapes $char]
909 set x [catchcmdex test.db ".print $char\n"]
910 set code [lindex $x 0]
911 set res [lindex $x 1]
912 if {$code ne "0"} {
913 error "failed with error: $res"
914 }
915 if {$res ne "$oldChar\n"} {
916 error "failed with byte $hex mismatch"
917 }
918 }
919 } {}
920
815 finish_test 921 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/shared4.test ('k') | third_party/sqlite/src/test/shell2.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698