/ Hex Artifact Content
Login

Artifact d5360fc31f643d37a973ab0d8b4fb85799c3169f:


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 32 20 32 30 30 37 2f 30 39 2f 31 32 20   1.2 2007/09/12 
0220: 31 37 3a 30 31 3a 34 35 20 64 61 6e 69 65 6c 6b  17:01:45 danielk
0230: 31 39 37 37 20 45 78 70 20 24 0a 0a 73 65 74 20  1977 Exp $..set 
0240: 74 65 73 74 64 69 72 20 5b 66 69 6c 65 20 64 69  testdir [file di
0250: 72 6e 61 6d 65 20 24 61 72 67 76 30 5d 0a 73 6f  rname $argv0].so
0260: 75 72 63 65 20 24 74 65 73 74 64 69 72 2f 74 65  urce $testdir/te
0270: 73 74 65 72 2e 74 63 6c 0a 0a 64 6f 5f 74 65 73  ster.tcl..do_tes
0280: 74 20 62 61 64 75 74 66 2d 31 2e 31 20 7b 0a 20  t badutf-1.1 {. 
0290: 20 64 62 20 65 76 61 6c 20 7b 50 52 41 47 4d 41   db eval {PRAGMA
02a0: 20 65 6e 63 6f 64 69 6e 67 3d 55 54 46 38 7d 0a   encoding=UTF8}.
02b0: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
02c0: 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25  b {SELECT hex('%
02d0: 38 30 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20  80') AS x}.} {0 
02e0: 7b 78 20 38 30 7d 7d 0a 64 6f 5f 74 65 73 74 20  {x 80}}.do_test 
02f0: 62 61 64 75 74 66 2d 31 2e 32 20 7b 0a 20 20 73  badutf-1.2 {.  s
0300: 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b  qlite3_exec db {
0310: 53 45 4c 45 43 54 20 68 65 78 28 27 25 38 31 27  SELECT hex('%81'
0320: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0330: 38 31 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64  81}}.do_test bad
0340: 75 74 66 2d 31 2e 33 20 7b 0a 20 20 73 71 6c 69  utf-1.3 {.  sqli
0350: 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c  te3_exec db {SEL
0360: 45 43 54 20 68 65 78 28 27 25 62 66 27 29 20 41  ECT hex('%bf') A
0370: 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 42 46 7d  S x}.} {0 {x BF}
0380: 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66  }.do_test badutf
0390: 2d 31 2e 34 20 7b 0a 20 20 73 71 6c 69 74 65 33  -1.4 {.  sqlite3
03a0: 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54  _exec db {SELECT
03b0: 20 68 65 78 28 27 25 63 30 27 29 20 41 53 20 78   hex('%c0') AS x
03c0: 7d 0a 7d 20 7b 30 20 7b 78 20 43 30 7d 7d 0a 64  }.} {0 {x C0}}.d
03d0: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e  o_test badutf-1.
03e0: 35 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78  5 {.  sqlite3_ex
03f0: 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65  ec db {SELECT he
0400: 78 28 27 25 65 30 27 29 20 41 53 20 78 7d 0a 7d  x('%e0') AS x}.}
0410: 20 7b 30 20 7b 78 20 45 30 7d 7d 0a 64 6f 5f 74   {0 {x E0}}.do_t
0420: 65 73 74 20 62 61 64 75 74 66 2d 31 2e 36 20 7b  est badutf-1.6 {
0430: 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20  .  sqlite3_exec 
0440: 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27  db {SELECT hex('
0450: 25 66 30 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30  %f0') AS x}.} {0
0460: 20 7b 78 20 46 30 7d 7d 0a 64 6f 5f 74 65 73 74   {x F0}}.do_test
0470: 20 62 61 64 75 74 66 2d 31 2e 37 20 7b 0a 20 20   badutf-1.7 {.  
0480: 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 20  sqlite3_exec db 
0490: 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 66 66  {SELECT hex('%ff
04a0: 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78  ') AS x}.} {0 {x
04b0: 20 46 46 7d 7d 0a 0a 73 71 6c 69 74 65 33 20 64   FF}}..sqlite3 d
04c0: 62 32 20 7b 7d 0a 69 66 63 61 70 61 62 6c 65 20  b2 {}.ifcapable 
04d0: 75 74 66 31 36 20 7b 0a 20 20 64 6f 5f 74 65 73  utf16 {.  do_tes
04e0: 74 20 62 61 64 75 74 66 2d 31 2e 31 30 20 7b 0a  t badutf-1.10 {.
04f0: 20 20 20 20 64 62 32 20 65 76 61 6c 20 7b 50 52      db2 eval {PR
0500: 41 47 4d 41 20 65 6e 63 6f 64 69 6e 67 3d 55 54  AGMA encoding=UT
0510: 46 31 36 62 65 7d 0a 20 20 20 20 73 71 6c 69 74  F16be}.    sqlit
0520: 65 33 5f 65 78 65 63 20 64 62 32 20 7b 53 45 4c  e3_exec db2 {SEL
0530: 45 43 54 20 68 65 78 28 27 25 38 30 27 29 20 41  ECT hex('%80') A
0540: 53 20 78 7d 0a 20 20 7d 20 7b 30 20 7b 78 20 30  S x}.  } {0 {x 0
0550: 30 38 30 7d 7d 0a 20 20 64 6f 5f 74 65 73 74 20  080}}.  do_test 
0560: 62 61 64 75 74 66 2d 31 2e 31 31 20 7b 0a 20 20  badutf-1.11 {.  
0570: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0580: 62 32 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27  b2 {SELECT hex('
0590: 25 38 31 27 29 20 41 53 20 78 7d 0a 20 20 7d 20  %81') AS x}.  } 
05a0: 7b 30 20 7b 78 20 30 30 38 31 7d 7d 0a 20 20 64  {0 {x 0081}}.  d
05b0: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e  o_test badutf-1.
05c0: 31 32 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33  12 {.    sqlite3
05d0: 5f 65 78 65 63 20 64 62 32 20 7b 53 45 4c 45 43  _exec db2 {SELEC
05e0: 54 20 68 65 78 28 27 25 62 66 27 29 20 41 53 20  T hex('%bf') AS 
05f0: 78 7d 0a 20 20 7d 20 7b 30 20 7b 78 20 30 30 42  x}.  } {0 {x 00B
0600: 46 7d 7d 0a 20 20 64 6f 5f 74 65 73 74 20 62 61  F}}.  do_test ba
0610: 64 75 74 66 2d 31 2e 31 33 20 7b 0a 20 20 20 20  dutf-1.13 {.    
0620: 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32  sqlite3_exec db2
0630: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27 25 63   {SELECT hex('%c
0640: 30 27 29 20 41 53 20 78 7d 0a 20 20 7d 20 7b 30  0') AS x}.  } {0
0650: 20 7b 78 20 46 46 46 44 7d 7d 0a 20 20 64 6f 5f   {x FFFD}}.  do_
0660: 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e 31 34  test badutf-1.14
0670: 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33 5f 65   {.    sqlite3_e
0680: 78 65 63 20 64 62 32 20 7b 53 45 4c 45 43 54 20  xec db2 {SELECT 
0690: 68 65 78 28 27 25 63 31 27 29 20 41 53 20 78 7d  hex('%c1') AS x}
06a0: 0a 20 20 7d 20 7b 30 20 7b 78 20 46 46 46 44 7d  .  } {0 {x FFFD}
06b0: 7d 0a 20 20 64 6f 5f 74 65 73 74 20 62 61 64 75  }.  do_test badu
06c0: 74 66 2d 31 2e 31 35 20 7b 0a 20 20 20 20 73 71  tf-1.15 {.    sq
06d0: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 32 20 7b  lite3_exec db2 {
06e0: 53 45 4c 45 43 54 20 68 65 78 28 27 25 63 30 25  SELECT hex('%c0%
06f0: 62 66 27 29 20 41 53 20 78 7d 0a 20 20 7d 20 7b  bf') AS x}.  } {
0700: 30 20 7b 78 20 46 46 46 44 7d 7d 0a 20 20 64 6f  0 {x FFFD}}.  do
0710: 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31 2e 31  _test badutf-1.1
0720: 36 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33 5f  6 {.    sqlite3_
0730: 65 78 65 63 20 64 62 32 20 7b 53 45 4c 45 43 54  exec db2 {SELECT
0740: 20 68 65 78 28 27 25 63 31 25 62 66 27 29 20 41   hex('%c1%bf') A
0750: 53 20 78 7d 0a 20 20 7d 20 7b 30 20 7b 78 20 46  S x}.  } {0 {x F
0760: 46 46 44 7d 7d 0a 20 20 64 6f 5f 74 65 73 74 20  FFD}}.  do_test 
0770: 62 61 64 75 74 66 2d 31 2e 31 37 20 7b 0a 20 20  badutf-1.17 {.  
0780: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0790: 62 32 20 7b 53 45 4c 45 43 54 20 68 65 78 28 27  b2 {SELECT hex('
07a0: 25 63 33 25 62 66 27 29 20 41 53 20 78 7d 0a 20  %c3%bf') AS x}. 
07b0: 20 7d 20 7b 30 20 7b 78 20 30 30 46 46 7d 7d 0a   } {0 {x 00FF}}.
07c0: 20 20 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66    do_test badutf
07d0: 2d 31 2e 31 38 20 7b 0a 20 20 20 20 73 71 6c 69  -1.18 {.    sqli
07e0: 74 65 33 5f 65 78 65 63 20 64 62 32 20 7b 53 45  te3_exec db2 {SE
07f0: 4c 45 43 54 20 68 65 78 28 27 25 65 30 27 29 20  LECT hex('%e0') 
0800: 41 53 20 78 7d 0a 20 20 7d 20 7b 30 20 7b 78 20  AS x}.  } {0 {x 
0810: 46 46 46 44 7d 7d 0a 20 20 64 6f 5f 74 65 73 74  FFFD}}.  do_test
0820: 20 62 61 64 75 74 66 2d 31 2e 31 39 20 7b 0a 20   badutf-1.19 {. 
0830: 20 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20     sqlite3_exec 
0840: 64 62 32 20 7b 53 45 4c 45 43 54 20 68 65 78 28  db2 {SELECT hex(
0850: 27 25 66 30 27 29 20 41 53 20 78 7d 0a 20 20 7d  '%f0') AS x}.  }
0860: 20 7b 30 20 7b 78 20 46 46 46 44 7d 7d 0a 20 20   {0 {x FFFD}}.  
0870: 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 31  do_test badutf-1
0880: 2e 32 30 20 7b 0a 20 20 20 20 73 71 6c 69 74 65  .20 {.    sqlite
0890: 33 5f 65 78 65 63 20 64 62 32 20 7b 53 45 4c 45  3_exec db2 {SELE
08a0: 43 54 20 68 65 78 28 27 25 66 66 27 29 20 41 53  CT hex('%ff') AS
08b0: 20 78 7d 0a 20 20 7d 20 7b 30 20 7b 78 20 46 46   x}.  } {0 {x FF
08c0: 46 44 7d 7d 0a 7d 0a 0a 0a 69 66 63 61 70 61 62  FD}}.}...ifcapab
08d0: 6c 65 20 62 6c 6f 62 6c 69 74 20 7b 0a 20 20 64  le bloblit {.  d
08e0: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 32 2e  o_test badutf-2.
08f0: 31 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33 5f  1 {.    sqlite3_
0900: 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20  exec db {SELECT 
0910: 27 25 38 30 27 3d 43 41 53 54 28 78 27 38 30 27  '%80'=CAST(x'80'
0920: 20 41 53 20 74 65 78 74 29 20 41 53 20 78 7d 0a   AS text) AS x}.
0930: 20 20 7d 20 7b 30 20 7b 78 20 31 7d 7d 0a 20 20    } {0 {x 1}}.  
0940: 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 32  do_test badutf-2
0950: 2e 32 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33  .2 {.    sqlite3
0960: 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54  _exec db {SELECT
0970: 20 43 41 53 54 28 27 25 38 30 27 20 41 53 20 62   CAST('%80' AS b
0980: 6c 6f 62 29 3d 78 27 38 30 27 20 41 53 20 78 7d  lob)=x'80' AS x}
0990: 0a 20 20 7d 20 7b 30 20 7b 78 20 31 7d 7d 0a 7d  .  } {0 {x 1}}.}
09a0: 0a 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66  ..do_test badutf
09b0: 2d 33 2e 31 20 7b 0a 20 20 73 71 6c 69 74 65 33  -3.1 {.  sqlite3
09c0: 5f 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54  _exec db {SELECT
09d0: 20 6c 65 6e 67 74 68 28 27 25 38 30 27 29 20 41   length('%80') A
09e0: 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20 31 7d 7d  S x}.} {0 {x 1}}
09f0: 0a 64 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d  .do_test badutf-
0a00: 33 2e 32 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f  3.2 {.  sqlite3_
0a10: 65 78 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20  exec db {SELECT 
0a20: 6c 65 6e 67 74 68 28 27 25 36 31 25 36 32 25 36  length('%61%62%6
0a30: 33 27 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  3') AS x}.} {0 {
0a40: 78 20 33 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61  x 3}}.do_test ba
0a50: 64 75 74 66 2d 33 2e 33 20 7b 0a 20 20 73 71 6c  dutf-3.3 {.  sql
0a60: 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45  ite3_exec db {SE
0a70: 4c 45 43 54 20 6c 65 6e 67 74 68 28 27 25 37 66  LECT length('%7f
0a80: 25 38 30 25 38 31 27 29 20 41 53 20 78 7d 0a 7d  %80%81') AS x}.}
0a90: 20 7b 30 20 7b 78 20 33 7d 7d 0a 64 6f 5f 74 65   {0 {x 3}}.do_te
0aa0: 73 74 20 62 61 64 75 74 66 2d 33 2e 34 20 7b 0a  st badutf-3.4 {.
0ab0: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0ac0: 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67 74 68  b {SELECT length
0ad0: 28 27 25 36 31 25 63 30 27 29 20 41 53 20 78 7d  ('%61%c0') AS x}
0ae0: 0a 7d 20 7b 30 20 7b 78 20 32 7d 7d 0a 64 6f 5f  .} {0 {x 2}}.do_
0af0: 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e 35 20  test badutf-3.5 
0b00: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0b10: 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67   db {SELECT leng
0b20: 74 68 28 27 25 36 31 25 63 30 25 38 30 25 38 30  th('%61%c0%80%80
0b30: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 25  %80%80%80%80%80%
0b40: 38 30 25 38 30 25 38 30 27 29 20 41 53 20 78 7d  80%80%80') AS x}
0b50: 0a 7d 20 7b 30 20 7b 78 20 32 7d 7d 0a 64 6f 5f  .} {0 {x 2}}.do_
0b60: 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e 36 20  test badutf-3.6 
0b70: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0b80: 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67   db {SELECT leng
0b90: 74 68 28 27 25 63 30 25 38 30 25 38 30 25 38 30  th('%c0%80%80%80
0ba0: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 25  %80%80%80%80%80%
0bb0: 38 30 25 38 30 27 29 20 41 53 20 78 7d 0a 7d 20  80%80') AS x}.} 
0bc0: 7b 30 20 7b 78 20 31 7d 7d 0a 64 6f 5f 74 65 73  {0 {x 1}}.do_tes
0bd0: 74 20 62 61 64 75 74 66 2d 33 2e 37 20 7b 0a 20  t badutf-3.7 {. 
0be0: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
0bf0: 20 7b 53 45 4c 45 43 54 20 6c 65 6e 67 74 68 28   {SELECT length(
0c00: 27 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30  '%80%80%80%80%80
0c10: 25 38 30 25 38 30 25 38 30 25 38 30 25 38 30 27  %80%80%80%80%80'
0c20: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0c30: 31 30 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64  10}}.do_test bad
0c40: 75 74 66 2d 33 2e 38 20 7b 0a 20 20 73 71 6c 69  utf-3.8 {.  sqli
0c50: 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c  te3_exec db {SEL
0c60: 45 43 54 20 6c 65 6e 67 74 68 28 27 25 38 30 25  ECT length('%80%
0c70: 38 30 25 38 30 25 38 30 25 38 30 25 66 30 25 38  80%80%80%80%f0%8
0c80: 30 25 38 30 25 38 30 25 38 30 27 29 20 41 53 20  0%80%80%80') AS 
0c90: 78 7d 0a 7d 20 7b 30 20 7b 78 20 36 7d 7d 0a 64  x}.} {0 {x 6}}.d
0ca0: 6f 5f 74 65 73 74 20 62 61 64 75 74 66 2d 33 2e  o_test badutf-3.
0cb0: 39 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78  9 {.  sqlite3_ex
0cc0: 65 63 20 64 62 20 7b 53 45 4c 45 43 54 20 6c 65  ec db {SELECT le
0cd0: 6e 67 74 68 28 27 25 38 30 25 38 30 25 38 30 25  ngth('%80%80%80%
0ce0: 38 30 25 38 30 25 66 30 25 38 30 25 38 30 25 38  80%80%f0%80%80%8
0cf0: 30 25 66 66 27 29 20 41 53 20 78 7d 0a 7d 20 7b  0%ff') AS x}.} {
0d00: 30 20 7b 78 20 37 7d 7d 0a 0a 64 6f 5f 74 65 73  0 {x 7}}..do_tes
0d10: 74 20 62 61 64 75 74 66 2d 34 2e 31 20 7b 0a 20  t badutf-4.1 {. 
0d20: 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64 62   sqlite3_exec db
0d30: 20 7b 53 45 4c 45 43 54 20 68 65 78 28 74 72 69   {SELECT hex(tri
0d40: 6d 28 27 25 38 30 25 38 30 25 38 30 25 66 30 25  m('%80%80%80%f0%
0d50: 38 30 25 38 30 25 38 30 25 66 66 27 2c 27 25 38  80%80%80%ff','%8
0d60: 30 25 66 66 27 29 29 20 41 53 20 78 7d 0a 7d 20  0%ff')) AS x}.} 
0d70: 7b 30 20 7b 78 20 46 30 7d 7d 0a 64 6f 5f 74 65  {0 {x F0}}.do_te
0d80: 73 74 20 62 61 64 75 74 66 2d 34 2e 32 20 7b 0a  st badutf-4.2 {.
0d90: 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20 64    sqlite3_exec d
0da0: 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 6c 74  b {SELECT hex(lt
0db0: 72 69 6d 28 27 25 38 30 25 38 30 25 38 30 25 66  rim('%80%80%80%f
0dc0: 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c 27  0%80%80%80%ff','
0dd0: 25 38 30 25 66 66 27 29 29 20 41 53 20 78 7d 0a  %80%ff')) AS x}.
0de0: 7d 20 7b 30 20 7b 78 20 46 30 38 30 38 30 38 30  } {0 {x F0808080
0df0: 46 46 7d 7d 0a 64 6f 5f 74 65 73 74 20 62 61 64  FF}}.do_test bad
0e00: 75 74 66 2d 34 2e 33 20 7b 0a 20 20 73 71 6c 69  utf-4.3 {.  sqli
0e10: 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53 45 4c  te3_exec db {SEL
0e20: 45 43 54 20 68 65 78 28 72 74 72 69 6d 28 27 25  ECT hex(rtrim('%
0e30: 38 30 25 38 30 25 38 30 25 66 30 25 38 30 25 38  80%80%80%f0%80%8
0e40: 30 25 38 30 25 66 66 27 2c 27 25 38 30 25 66 66  0%80%ff','%80%ff
0e50: 27 29 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b  ')) AS x}.} {0 {
0e60: 78 20 38 30 38 30 38 30 46 30 7d 7d 0a 64 6f 5f  x 808080F0}}.do_
0e70: 74 65 73 74 20 62 61 64 75 74 66 2d 34 2e 34 20  test badutf-4.4 
0e80: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
0e90: 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28   db {SELECT hex(
0ea0: 74 72 69 6d 28 27 25 38 30 25 38 30 25 38 30 25  trim('%80%80%80%
0eb0: 66 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c  f0%80%80%80%ff',
0ec0: 27 25 66 66 25 38 30 27 29 29 20 41 53 20 78 7d  '%ff%80')) AS x}
0ed0: 0a 7d 20 7b 30 20 7b 78 20 38 30 38 30 38 30 46  .} {0 {x 808080F
0ee0: 30 38 30 38 30 38 30 46 46 7d 7d 0a 64 6f 5f 74  0808080FF}}.do_t
0ef0: 65 73 74 20 62 61 64 75 74 66 2d 34 2e 35 20 7b  est badutf-4.5 {
0f00: 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63 20  .  sqlite3_exec 
0f10: 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28 74  db {SELECT hex(t
0f20: 72 69 6d 28 27 25 66 66 25 38 30 25 38 30 25 66  rim('%ff%80%80%f
0f30: 30 25 38 30 25 38 30 25 38 30 25 66 66 27 2c 27  0%80%80%80%ff','
0f40: 25 66 66 25 38 30 27 29 29 20 41 53 20 78 7d 0a  %ff%80')) AS x}.
0f50: 7d 20 7b 30 20 7b 78 20 38 30 46 30 38 30 38 30  } {0 {x 80F08080
0f60: 38 30 46 46 7d 7d 0a 64 6f 5f 74 65 73 74 20 62  80FF}}.do_test b
0f70: 61 64 75 74 66 2d 34 2e 36 20 7b 0a 20 20 73 71  adutf-4.6 {.  sq
0f80: 6c 69 74 65 33 5f 65 78 65 63 20 64 62 20 7b 53  lite3_exec db {S
0f90: 45 4c 45 43 54 20 68 65 78 28 74 72 69 6d 28 27  ELECT hex(trim('
0fa0: 25 66 66 25 38 30 25 66 30 25 38 30 25 38 30 25  %ff%80%f0%80%80%
0fb0: 38 30 25 66 66 27 2c 27 25 66 66 25 38 30 27 29  80%ff','%ff%80')
0fc0: 29 20 41 53 20 78 7d 0a 7d 20 7b 30 20 7b 78 20  ) AS x}.} {0 {x 
0fd0: 46 30 38 30 38 30 38 30 46 46 7d 7d 0a 64 6f 5f  F0808080FF}}.do_
0fe0: 74 65 73 74 20 62 61 64 75 74 66 2d 34 2e 37 20  test badutf-4.7 
0ff0: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 65 78 65 63  {.  sqlite3_exec
1000: 20 64 62 20 7b 53 45 4c 45 43 54 20 68 65 78 28   db {SELECT hex(
1010: 74 72 69 6d 28 27 25 66 66 25 38 30 25 66 30 25  trim('%ff%80%f0%
1020: 38 30 25 38 30 25 38 30 25 66 66 27 2c 27 25 66  80%80%80%ff','%f
1030: 66 25 38 30 25 38 30 27 29 29 20 41 53 20 78 7d  f%80%80')) AS x}
1040: 0a 7d 20 7b 30 20 7b 78 20 46 46 38 30 46 30 38  .} {0 {x FF80F08
1050: 30 38 30 38 30 46 46 7d 7d 0a 0a 64 62 32 20 63  08080FF}}..db2 c
1060: 6c 6f 73 65 0a 66 69 6e 69 73 68 5f 74 65 73 74  lose.finish_test
1070: 0a                                               .