| Index: third_party/sqlite/sqlite-src-3100200/test/shell5.test
|
| diff --git a/third_party/sqlite/src/test/shell5.test b/third_party/sqlite/sqlite-src-3100200/test/shell5.test
|
| similarity index 85%
|
| copy from third_party/sqlite/src/test/shell5.test
|
| copy to third_party/sqlite/sqlite-src-3100200/test/shell5.test
|
| index 8d740cb980efaf3a2e6e5b6d15d579ff8f190a72..b921accca5f431a70bbaff1d314e00644b11f303 100644
|
| --- a/third_party/sqlite/src/test/shell5.test
|
| +++ b/third_party/sqlite/sqlite-src-3100200/test/shell5.test
|
| @@ -55,7 +55,7 @@ do_test shell5-1.1.3 {
|
| # .separator STRING Change separator used by output mode and .import
|
| do_test shell5-1.2.1 {
|
| catchcmd "test.db" ".separator"
|
| -} {1 {Usage: .separator SEPARATOR ?NEWLINE?}}
|
| +} {1 {Usage: .separator COL ?ROW?}}
|
| do_test shell5-1.2.2 {
|
| catchcmd "test.db" ".separator ONE"
|
| } {0 {}}
|
| @@ -65,12 +65,18 @@ do_test shell5-1.2.3 {
|
| do_test shell5-1.2.4 {
|
| # too many arguments
|
| catchcmd "test.db" ".separator ONE TWO THREE"
|
| -} {1 {Usage: .separator SEPARATOR ?NEWLINE?}}
|
| +} {1 {Usage: .separator COL ?ROW?}}
|
|
|
| -# separator should default to "|"
|
| -do_test shell5-1.3.1 {
|
| +# column separator should default to "|"
|
| +do_test shell5-1.3.1.1 {
|
| set res [catchcmd "test.db" ".show"]
|
| - list [regexp {separator: \"\|\"} $res]
|
| + list [regexp {colseparator: \"\|\"} $res]
|
| +} {1}
|
| +
|
| +# row separator should default to "\n"
|
| +do_test shell5-1.3.1.2 {
|
| + set res [catchcmd "test.db" ".show"]
|
| + list [regexp {rowseparator: \"\\n\"} $res]
|
| } {1}
|
|
|
| # set separator to different value.
|
| @@ -372,5 +378,61 @@ CREATE TABLE t4(a, b);
|
| db eval { SELECT * FROM t4 }
|
| } {xy\" hello one 2 {} {}}
|
|
|
| +#----------------------------------------------------------------------------
|
| +# Tests for the shell "ascii" import/export mode.
|
| +#
|
| +do_test shell5-3.1 {
|
| + set fd [open shell5.csv w]
|
| + fconfigure $fd -encoding binary -translation binary
|
| + puts -nonewline $fd "\"test 1\"\x1F,test 2\r\n\x1E"
|
| + puts -nonewline $fd "test 3\x1Ftest 4\n"
|
| + close $fd
|
| + catchcmd test.db {
|
| +.mode ascii
|
| +CREATE TABLE t5(a, b);
|
| +.import shell5.csv t5
|
| + }
|
| + db eval { SELECT * FROM t5 }
|
| +} "\{\"test 1\"} \{,test 2\r\n\} \{test 3\} \{test 4\n\}"
|
| +
|
| +do_test shell5-3.2 {
|
| + set x [catchcmd test.db {
|
| +.mode ascii
|
| +SELECT * FROM t5;
|
| + }]
|
| + # Handle platform end-of-line differences
|
| + regsub -all {[\n\r]?\n} $x <EOL> x
|
| + set x
|
| +} "0 \{\"test 1\"\x1F,test 2<EOL>\x1Etest 3\x1Ftest 4<EOL>\x1E\}"
|
| +
|
| +do_test shell5-4.1 {
|
| + forcedelete shell5.csv
|
| + set fd [open shell5.csv w]
|
| + puts $fd "1,2,3"
|
| + puts $fd "4,5"
|
| + puts $fd "6,7,8"
|
| + close $fd
|
| + catchcmd test.db [string trim {
|
| +.mode csv
|
| +CREATE TABLE t6(a, b, c);
|
| +.import shell5.csv t6
|
| + }]
|
| + db eval { SELECT * FROM t6 ORDER BY a }
|
| +} {1 2 3 4 5 {} 6 7 8}
|
| +
|
| +do_test shell5-4.2 {
|
| + forcedelete shell5.csv
|
| + set fd [open shell5.csv w]
|
| + puts $fd "1,2,3"
|
| + puts $fd "4,5"
|
| + puts $fd "6,7,8,9"
|
| + close $fd
|
| + catchcmd test.db [string trim {
|
| +.mode csv
|
| +CREATE TABLE t7(a, b, c);
|
| +.import shell5.csv t7
|
| + }]
|
| + db eval { SELECT * FROM t7 ORDER BY a }
|
| +} {1 2 3 4 5 {} 6 7 8}
|
|
|
| finish_test
|
|
|