/ Hex Artifact Content
Login

Artifact e5cd3fd946b76fb0d05024156618ed905298f44a:


0000: 23 20 32 30 30 37 20 4d 61 79 20 31 35 0a 23 0a  # 2007 May 15.#.
0010: 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73  # The author dis
0020: 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74  claims copyright
0030: 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20   to this source 
0040: 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20  code.  In place 
0050: 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74  of.# a legal not
0060: 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62  ice, here is a b
0070: 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20  lessing:.#.#    
0080: 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20  May you do good 
0090: 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20  and not evil..# 
00a0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20     May you find 
00b0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20  forgiveness for 
00c0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72  yourself and for
00d0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20  give others..#  
00e0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20    May you share 
00f0: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61  freely, never ta
0100: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79  king more than y
0110: 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a  ou give..#.#****
0120: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 0a 23 20 54 68 69 73 20 66 69 6c 65 20  ***.# This file 
0170: 69 6d 70 6c 65 6d 65 6e 74 73 20 72 65 67 72 65  implements regre
0180: 73 73 69 6f 6e 20 74 65 73 74 73 20 66 6f 72 20  ssion tests for 
0190: 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79 2e 20  SQLite library. 
01a0: 0a 23 0a 23 20 54 68 69 73 20 66 69 6c 65 20 63  .#.# This file c
01b0: 68 65 63 6b 73 20 74 6f 20 6d 61 6b 65 20 73 75  hecks to make su
01c0: 72 65 20 53 51 4c 69 74 65 20 69 73 20 61 62 6c  re SQLite is abl
01d0: 65 20 74 6f 20 67 72 61 63 65 66 75 6c 6c 79 0a  e to gracefully.
01e0: 23 20 68 61 6e 64 6c 65 20 6d 61 6c 66 6f 72 6d  # handle malform
01f0: 65 64 20 55 54 46 2d 38 2e 0a 23 0a 23 20 24 49  ed UTF-8..#.# $I
0200: 64 3a 20 62 61 64 75 74 66 2e 74 65 73 74 2c 76  d: badutf.test,v
0210: 20 31 2e 31 20 32 30 30 37 2f 30 35 2f 31 35 20   1.1 2007/05/15 
0220: 31 38 3a 33 35 3a 32 31 20 64 72 68 20 45 78 70  18:35:21 drh Exp
0230: 20 24 0a 0a 73 65 74 20 74 65 73 74 64 69 72 20   $..set testdir 
0240: 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 24 61  [file dirname $a
0250: 72 67 76 30 5d 0a 73 6f 75 72 63 65 20 24 74 65  rgv0].source $te
0260: 73 74 64 69 72 2f 74 65 73 74 65 72 2e 74 63 6c  stdir/tester.tcl
0270: 0a 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66  ..do_test badutf
0280: 2d 31 2e 31 20 7b 0a 20 20 64 62 20 65 76 61 6c  -1.1 {.  db eval
0290: 20 7b 50 52 41 47 4d 41 20 65 6e 63 6f 64 69 6e   {PRAGMA encodin
02a0: 67 3d 55 54 46 38 7d 0a 20 20 73 71 6c 69 74 65  g=UTF8}.  sqlite
02b0: 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43  3_exec db {SELEC
02c0: 54 20 68 65 78 28 27 25 38 30 27 29 20 41 53 20  T hex('%80') AS 
02d0: 78 7d 0a 7d 20 7b 30 20 7b 78 20 38 30 7d 7d 0a  x}.} {0 {x 80}}.
02e0: 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31  do_test badutf-1
02f0: 2e 32 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65  .2 {.  sqlite3_e
0300: 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20 68  xec db {SELECT h
0310: 65 78 28 27 25 38 31 27 29 20 41 53 20 78 7d 0a  ex('%81') AS x}.
0320: 7d 20 7b 30 20 7b 78 20 38 31 7d 7d 0a 64 6f 5f  } {0 {x 81}}.do_
0330: 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e 33 20  test badutf-1.3 
0340: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0350: 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28   db {SELECT hex(
0360: 27 25 62 66 27 29 20 41 53 20 78 7d 0a 7d 20 7b  '%bf') AS x}.} {
0370: 30 20 7b 78 20 42 46 7d 7d 0a 64 6f 5f 74 65 73  0 {x BF}}.do_tes
0380: 74 20 62 61 64 75 74 66 2d 31 2e 34 20 7b 0a 20  t badutf-1.4 {. 
0390: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
03a0: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 63   {SELECT hex('%c
03b0: 30 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  0') AS x}.} {0 {
03c0: 78 20 43 30 7d 7d 0a 64 6f 5f 74 65 73 74 20 62  x C0}}.do_test b
03d0: 61 64 75 74 66 2d 31 2e 35 20 7b 0a 20 20 73 71  adutf-1.5 {.  sq
03e0: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53  lite3_exec db {S
03f0: 45 4c 45 43 54 20 68 65 78 28 27 25 65 30 27 29  ELECT hex('%e0')
0400: 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 45   AS x}.} {0 {x E
0410: 30 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64 75  0}}.do_test badu
0420: 74 66 2d 31 2e 36 20 7b 0a 20 20 73 71 6c 69 74  tf-1.6 {.  sqlit
0430: 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45  e3_exec db {SELE
0440: 43 54 20 68 65 78 28 27 25 66 30 27 29 20 41 53  CT hex('%f0') AS
0450: 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 46 30 7d 7d   x}.} {0 {x F0}}
0460: 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d  .do_test badutf-
0470: 31 2e 37 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f  1.7 {.  sqlite3_
0480: 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20  exec db {SELECT 
0490: 68 65 78 28 27 25 66 66 27 29 20 41 53 20 78 7d  hex('%ff') AS x}
04a0: 0a 7d 20 7b 30 20 7b 78 20 46 46 7d 7d 0a 0a 64  .} {0 {x FF}}..d
04b0: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e  o_test badutf-1.
04c0: 31 30 20 7b 0a 20 20 73 71 6c 69 74 65 33 20 64  10 {.  sqlite3 d
04d0: 62 32 20 7b 7d 0a 20 20 64 62 32 20 65 76 61 6c  b2 {}.  db2 eval
04e0: 20 7b 50 52 41 47 4d 41 20 65 6e 63 6f 64 69 6e   {PRAGMA encodin
04f0: 67 3d 55 54 46 31 36 62 65 7d 0a 20 20 73 71 6c  g=UTF16be}.  sql
0500: 69 74 65 33 5f 65 78 65 63 20 64 62 32 20 7b 53  ite3_exec db2 {S
0510: 45 4c 45 43 54 20 68 65 78 28 27 25 38 30 27 29  ELECT hex('%80')
0520: 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 30   AS x}.} {0 {x 0
0530: 30 38 30 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61  080}}.do_test ba
0540: 64 75 74 66 2d 31 2e 31 31 20 7b 0a 20 20 73 71  dutf-1.11 {.  sq
0550: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32 20 7b  lite3_exec db2 {
0560: 53 45 4c 45 43 54 20 68 65 78 28 27 25 38 31 27  SELECT hex('%81'
0570: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0580: 30 30 38 31 7d 7d 0a 64 6f 5f 74 65 73 74 20 62  0081}}.do_test b
0590: 61 64 75 74 66 2d 31 2e 31 32 20 7b 0a 20 20 73  adutf-1.12 {.  s
05a0: 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32 20  qlite3_exec db2 
05b0: 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 62 66  {SELECT hex('%bf
05c0: 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78  ') AS x}.} {0 {x
05d0: 20 30 30 42 46 7d 7d 0a 64 6f 5f 74 65 73 74 20   00BF}}.do_test 
05e0: 62 61 64 75 74 66 2d 31 2e 31 33 20 7b 0a 20 20  badutf-1.13 {.  
05f0: 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32  sqlite3_exec db2
0600: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 63   {SELECT hex('%c
0610: 30 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  0') AS x}.} {0 {
0620: 78 20 46 46 46 44 7d 7d 0a 64 6f 5f 74 65 73 74  x FFFD}}.do_test
0630: 20 62 61 64 75 74 66 2d 31 2e 31 34 20 7b 0a 20   badutf-1.14 {. 
0640: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
0650: 32 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25  2 {SELECT hex('%
0660: 63 31 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20  c1') AS x}.} {0 
0670: 7b 78 20 46 46 46 44 7d 7d 0a 64 6f 5f 74 65 73  {x FFFD}}.do_tes
0680: 74 20 62 61 64 75 74 66 2d 31 2e 31 35 20 7b 0a  t badutf-1.15 {.
0690: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
06a0: 62 32 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27  b2 {SELECT hex('
06b0: 25 63 30 25 62 66 27 29 20 41 53 20 78 7d 0a 7d  %c0%bf') AS x}.}
06c0: 20 7b 30 20 7b 78 20 46 46 46 44 7d 7d 0a 64 6f   {0 {x FFFD}}.do
06d0: 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e 31  _test badutf-1.1
06e0: 36 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78  6 {.  sqlite3_ex
06f0: 65 63 20 64 62 32 20 7b 53 45 4c 45 43 54 20 68  ec db2 {SELECT h
0700: 65 78 28 27 25 63 31 25 62 66 27 29 20 41 53 20  ex('%c1%bf') AS 
0710: 78 7d 0a 7d 20 7b 30 20 7b 78 20 46 46 46 44 7d  x}.} {0 {x FFFD}
0720: 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66  }.do_test badutf
0730: 2d 31 2e 31 37 20 7b 0a 20 20 73 71 6c 69 74 65  -1.17 {.  sqlite
0740: 33 5f 65 78 65 63 20 64 62 32 20 7b 53 45 4c 45  3_exec db2 {SELE
0750: 43 54 20 68 65 78 28 27 25 63 33 25 62 66 27 29  CT hex('%c3%bf')
0760: 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 30   AS x}.} {0 {x 0
0770: 30 46 46 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61  0FF}}.do_test ba
0780: 64 75 74 66 2d 31 2e 31 38 20 7b 0a 20 20 73 71  dutf-1.18 {.  sq
0790: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32 20 7b  lite3_exec db2 {
07a0: 53 45 4c 45 43 54 20 68 65 78 28 27 25 65 30 27  SELECT hex('%e0'
07b0: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
07c0: 46 46 46 44 7d 7d 0a 64 6f 5f 74 65 73 74 20 62  FFFD}}.do_test b
07d0: 61 64 75 74 66 2d 31 2e 31 39 20 7b 0a 20 20 73  adutf-1.19 {.  s
07e0: 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32 20  qlite3_exec db2 
07f0: 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 66 30  {SELECT hex('%f0
0800: 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78  ') AS x}.} {0 {x
0810: 20 46 46 46 44 7d 7d 0a 64 6f 5f 74 65 73 74 20   FFFD}}.do_test 
0820: 62 61 64 75 74 66 2d 31 2e 32 30 20 7b 0a 20 20  badutf-1.20 {.  
0830: 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32  sqlite3_exec db2
0840: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 66   {SELECT hex('%f
0850: 66 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  f') AS x}.} {0 {
0860: 78 20 46 46 46 44 7d 7d 0a 0a 0a 64 6f 5f 74 65  x FFFD}}...do_te
0870: 73 74 20 62 61 64 75 74 66 2d 32 2e 31 20 7b 0a  st badutf-2.1 {.
0880: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0890: 62 20 7b 53 45 4c 45 43 54 20 27 25 38 30 27 3d  b {SELECT '%80'=
08a0: 43 41 53 54 28 78 27 38 30 27 20 41 53 20 74 65  CAST(x'80' AS te
08b0: 78 74 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  xt) AS x}.} {0 {
08c0: 78 20 31 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61  x 1}}.do_test ba
08d0: 64 75 74 66 2d 32 2e 32 20 7b 0a 20 20 73 71 6c  dutf-2.2 {.  sql
08e0: 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45  ite3_exec db {SE
08f0: 4c 45 43 54 20 43 41 53 54 28 27 25 38 30 27 20  LECT CAST('%80' 
0900: 41 53 20 62 6c 6f 62 29 3d 78 27 38 30 27 20 41  AS blob)=x'80' A
0910: 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 31 7d 7d  S x}.} {0 {x 1}}
0920: 0a 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66  ..do_test badutf
0930: 2d 33 2e 31 20 7b 0a 20 20 73 71 6c 69 74 65 33  -3.1 {.  sqlite3
0940: 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54  _exec db {SELECT
0950: 20 6c 65 6e 67 74 68 28 27 25 38 30 27 29 20 41   length('%80') A
0960: 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 31 7d 7d  S x}.} {0 {x 1}}
0970: 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d  .do_test badutf-
0980: 33 2e 32 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f  3.2 {.  sqlite3_
0990: 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20  exec db {SELECT 
09a0: 6c 65 6e 67 74 68 28 27 25 36 31 25 36 32 25 36  length('%61%62%6
09b0: 33 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  3') AS x}.} {0 {
09c0: 78 20 33 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61  x 3}}.do_test ba
09d0: 64 75 74 66 2d 33 2e 33 20 7b 0a 20 20 73 71 6c  dutf-3.3 {.  sql
09e0: 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45  ite3_exec db {SE
09f0: 4c 45 43 54 20 6c 65 6e 67 74 68 28 27 25 37 66  LECT length('%7f
0a00: 25 38 30 25 38 31 27 29 20 41 53 20 78 7d 0a 7d  %80%81') AS x}.}
0a10: 20 7b 30 20 7b 78 20 33 7d 7d 0a 64 6f 5f 74 65   {0 {x 3}}.do_te
0a20: 73 74 20 62 61 64 75 74 66 2d 33 2e 34 20 7b 0a  st badutf-3.4 {.
0a30: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0a40: 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67 74 68  b {SELECT length
0a50: 28 27 25 36 31 25 63 30 27 29 20 41 53 20 78 7d  ('%61%c0') AS x}
0a60: 0a 7d 20 7b 30 20 7b 78 20 32 7d 7d 0a 64 6f 5f  .} {0 {x 2}}.do_
0a70: 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e 35 20  test badutf-3.5 
0a80: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0a90: 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67   db {SELECT leng
0aa0: 74 68 28 27 25 36 31 25 63 30 25 38 30 25 38 30  th('%61%c0%80%80
0ab0: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 25  %80%80%80%80%80%
0ac0: 38 30 25 38 30 25 38 30 27 29 20 41 53 20 78 7d  80%80%80') AS x}
0ad0: 0a 7d 20 7b 30 20 7b 78 20 32 7d 7d 0a 64 6f 5f  .} {0 {x 2}}.do_
0ae0: 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e 36 20  test badutf-3.6 
0af0: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0b00: 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67   db {SELECT leng
0b10: 74 68 28 27 25 63 30 25 38 30 25 38 30 25 38 30  th('%c0%80%80%80
0b20: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 25  %80%80%80%80%80%
0b30: 38 30 25 38 30 27 29 20 41 53 20 78 7d 0a 7d 20  80%80') AS x}.} 
0b40: 7b 30 20 7b 78 20 31 7d 7d 0a 64 6f 5f 74 65 73  {0 {x 1}}.do_tes
0b50: 74 20 62 61 64 75 74 66 2d 33 2e 37 20 7b 0a 20  t badutf-3.7 {. 
0b60: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
0b70: 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67 74 68 28   {SELECT length(
0b80: 27 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30  '%80%80%80%80%80
0b90: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 27  %80%80%80%80%80'
0ba0: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0bb0: 31 30 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64  10}}.do_test bad
0bc0: 75 74 66 2d 33 2e 38 20 7b 0a 20 20 73 71 6c 69  utf-3.8 {.  sqli
0bd0: 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c  te3_exec db {SEL
0be0: 45 43 54 20 6c 65 6e 67 74 68 28 27 25 38 30 25  ECT length('%80%
0bf0: 38 30 25 38 30 25 38 30 25 38 30 25 66 30 25 38  80%80%80%80%f0%8
0c00: 30 25 38 30 25 38 30 25 38 30 27 29 20 41 53 20  0%80%80%80') AS 
0c10: 78 7d 0a 7d 20 7b 30 20 7b 78 20 36 7d 7d 0a 64  x}.} {0 {x 6}}.d
0c20: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e  o_test badutf-3.
0c30: 39 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78  9 {.  sqlite3_ex
0c40: 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65  ec db {SELECT le
0c50: 6e 67 74 68 28 27 25 38 30 25 38 30 25 38 30 25  ngth('%80%80%80%
0c60: 38 30 25 38 30 25 66 30 25 38 30 25 38 30 25 38  80%80%f0%80%80%8
0c70: 30 25 66 66 27 29 20 41 53 20 78 7d 0a 7d 20 7b  0%ff') AS x}.} {
0c80: 30 20 7b 78 20 37 7d 7d 0a 0a 64 6f 5f 74 65 73  0 {x 7}}..do_tes
0c90: 74 20 62 61 64 75 74 66 2d 34 2e 31 20 7b 0a 20  t badutf-4.1 {. 
0ca0: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
0cb0: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 74 72 69   {SELECT hex(tri
0cc0: 6d 28 27 25 38 30 25 38 30 25 38 30 25 66 30 25  m('%80%80%80%f0%
0cd0: 38 30 25 38 30 25 38 30 25 66 66 27 2c 27 25 38  80%80%80%ff','%8
0ce0: 30 25 66 66 27 29 29 20 41 53 20 78 7d 0a 7d 20  0%ff')) AS x}.} 
0cf0: 7b 30 20 7b 78 20 46 30 7d 7d 0a 64 6f 5f 74 65  {0 {x F0}}.do_te
0d00: 73 74 20 62 61 64 75 74 66 2d 34 2e 32 20 7b 0a  st badutf-4.2 {.
0d10: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0d20: 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 6c 74  b {SELECT hex(lt
0d30: 72 69 6d 28 27 25 38 30 25 38 30 25 38 30 25 66  rim('%80%80%80%f
0d40: 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c 27  0%80%80%80%ff','
0d50: 25 38 30 25 66 66 27 29 29 20 41 53 20 78 7d 0a  %80%ff')) AS x}.
0d60: 7d 20 7b 30 20 7b 78 20 46 30 38 30 38 30 38 30  } {0 {x F0808080
0d70: 46 46 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64  FF}}.do_test bad
0d80: 75 74 66 2d 34 2e 33 20 7b 0a 20 20 73 71 6c 69  utf-4.3 {.  sqli
0d90: 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c  te3_exec db {SEL
0da0: 45 43 54 20 68 65 78 28 72 74 72 69 6d 28 27 25  ECT hex(rtrim('%
0db0: 38 30 25 38 30 25 38 30 25 66 30 25 38 30 25 38  80%80%80%f0%80%8
0dc0: 30 25 38 30 25 66 66 27 2c 27 25 38 30 25 66 66  0%80%ff','%80%ff
0dd0: 27 29 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  ')) AS x}.} {0 {
0de0: 78 20 38 30 38 30 38 30 46 30 7d 7d 0a 64 6f 5f  x 808080F0}}.do_
0df0: 74 65 73 74 20 62 61 64 75 74 66 2d 34 2e 34 20  test badutf-4.4 
0e00: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0e10: 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28   db {SELECT hex(
0e20: 74 72 69 6d 28 27 25 38 30 25 38 30 25 38 30 25  trim('%80%80%80%
0e30: 66 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c  f0%80%80%80%ff',
0e40: 27 25 66 66 25 38 30 27 29 29 20 41 53 20 78 7d  '%ff%80')) AS x}
0e50: 0a 7d 20 7b 30 20 7b 78 20 38 30 38 30 38 30 46  .} {0 {x 808080F
0e60: 30 38 30 38 30 38 30 46 46 7d 7d 0a 64 6f 5f 74  0808080FF}}.do_t
0e70: 65 73 74 20 62 61 64 75 74 66 2d 34 2e 35 20 7b  est badutf-4.5 {
0e80: 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20  .  sqlite3_exec 
0e90: 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 74  db {SELECT hex(t
0ea0: 72 69 6d 28 27 25 66 66 25 38 30 25 38 30 25 66  rim('%ff%80%80%f
0eb0: 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c 27  0%80%80%80%ff','
0ec0: 25 66 66 25 38 30 27 29 29 20 41 53 20 78 7d 0a  %ff%80')) AS x}.
0ed0: 7d 20 7b 30 20 7b 78 20 38 30 46 30 38 30 38 30  } {0 {x 80F08080
0ee0: 38 30 46 46 7d 7d 0a 64 6f 5f 74 65 73 74 20 62  80FF}}.do_test b
0ef0: 61 64 75 74 66 2d 34 2e 36 20 7b 0a 20 20 73 71  adutf-4.6 {.  sq
0f00: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53  lite3_exec db {S
0f10: 45 4c 45 43 54 20 68 65 78 28 74 72 69 6d 28 27  ELECT hex(trim('
0f20: 25 66 66 25 38 30 25 66 30 25 38 30 25 38 30 25  %ff%80%f0%80%80%
0f30: 38 30 25 66 66 27 2c 27 25 66 66 25 38 30 27 29  80%ff','%ff%80')
0f40: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0f50: 46 30 38 30 38 30 38 30 46 46 7d 7d 0a 64 6f 5f  F0808080FF}}.do_
0f60: 74 65 73 74 20 62 61 64 75 74 66 2d 34 2e 37 20  test badutf-4.7 
0f70: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0f80: 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28   db {SELECT hex(
0f90: 74 72 69 6d 28 27 25 66 66 25 38 30 25 66 30 25  trim('%ff%80%f0%
0fa0: 38 30 25 38 30 25 38 30 25 66 66 27 2c 27 25 66  80%80%80%ff','%f
0fb0: 66 25 38 30 25 38 30 27 29 29 20 41 53 20 78 7d  f%80%80')) AS x}
0fc0: 0a 7d 20 7b 30 20 7b 78 20 46 46 38 30 46 30 38  .} {0 {x FF80F08
0fd0: 30 38 30 38 30 46 46 7d 7d 0a 0a 64 62 32 20 63  08080FF}}..db2 c
0fe0: 6c 6f 73 65 0a 66 69 6e 69 73 68 5f 74 65 73 74  lose.finish_test
0ff0: 0a                                               .