sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | /* |
| 2 | ** Run this script using the "sqlite3" command-line shell |
| 3 | ** test test formatting of output text that contains |
| 4 | ** vt100 escape sequences. |
| 5 | */ |
| 6 | .open :memory: |
| 7 | .mode box -escape off |
| 8 | CREATE TEMP TABLE t1(a,b,c); |
| 9 | INSERT INTO t1 VALUES |
| 10 | ('one','twotwotwo','thirty-three'), |
| 11 | (unistr('\u001b[91mRED\u001b[0m'),'fourfour','fifty-five'), |
| 12 | ('six','seven','eighty-eight'); |
| 13 | .testcase 100 |
| 14 | SELECT * FROM t1; |
| 15 | .check <<END |
| 16 | ╭─────┬───────────┬──────────────╮ |
| 17 | │ a │ b │ c │ |
| 18 | ╞═════╪═══════════╪══════════════╡ |
| 19 | │ one │ twotwotwo │ thirty-three │ |
| 20 | │ [91mRED[0m │ fourfour │ fifty-five │ |
| 21 | │ six │ seven │ eighty-eight │ |
| 22 | ╰─────┴───────────┴──────────────╯ |
| 23 | END |
| 24 | |
| 25 | .mode box -escape ascii |
| 26 | .testcase 200 |
| 27 | SELECT * FROM t1; |
| 28 | .check <<END |
| 29 | ╭────────────────┬───────────┬──────────────╮ |
| 30 | │ a │ b │ c │ |
| 31 | ╞════════════════╪═══════════╪══════════════╡ |
| 32 | │ one │ twotwotwo │ thirty-three │ |
| 33 | │ ^[[91mRED^[[0m │ fourfour │ fifty-five │ |
| 34 | │ six │ seven │ eighty-eight │ |
| 35 | ╰────────────────┴───────────┴──────────────╯ |
| 36 | END |
| 37 | |
| 38 | .testcase 300 |
| 39 | .mode box -escape symbol |
| 40 | SELECT * FROM t1; |
| 41 | .check <<END |
| 42 | ╭──────────────┬───────────┬──────────────╮ |
| 43 | │ a │ b │ c │ |
| 44 | ╞══════════════╪═══════════╪══════════════╡ |
| 45 | │ one │ twotwotwo │ thirty-three │ |
| 46 | │ ␛[91mRED␛[0m │ fourfour │ fifty-five │ |
| 47 | │ six │ seven │ eighty-eight │ |
| 48 | ╰──────────────┴───────────┴──────────────╯ |
| 49 | END |