|
a8b0c5f…
|
mistachkin
|
1 |
# |
|
edd288b…
|
mistachkin
|
2 |
# Copyright (c) 2016 D. Richard Hipp |
|
a8b0c5f…
|
mistachkin
|
3 |
# |
|
a8b0c5f…
|
mistachkin
|
4 |
# This program is free software; you can redistribute it and/or |
|
a8b0c5f…
|
mistachkin
|
5 |
# modify it under the terms of the Simplified BSD License (also |
|
a8b0c5f…
|
mistachkin
|
6 |
# known as the "2-Clause License" or "FreeBSD License".) |
|
a8b0c5f…
|
mistachkin
|
7 |
# |
|
a8b0c5f…
|
mistachkin
|
8 |
# This program is distributed in the hope that it will be useful, |
|
a8b0c5f…
|
mistachkin
|
9 |
# but without any warranty; without even the implied warranty of |
|
a8b0c5f…
|
mistachkin
|
10 |
# merchantability or fitness for a particular purpose. |
|
a8b0c5f…
|
mistachkin
|
11 |
# |
|
a8b0c5f…
|
mistachkin
|
12 |
# Author contact information: |
|
a8b0c5f…
|
mistachkin
|
13 |
# [email protected] |
|
a8b0c5f…
|
mistachkin
|
14 |
# http://www.hwaci.com/drh/ |
|
a8b0c5f…
|
mistachkin
|
15 |
# |
|
a8b0c5f…
|
mistachkin
|
16 |
############################################################################ |
|
a8b0c5f…
|
mistachkin
|
17 |
# |
|
a8b0c5f…
|
mistachkin
|
18 |
# The focus of this file is to test pre-commit warnings. |
|
a8b0c5f…
|
mistachkin
|
19 |
# |
|
a8b0c5f…
|
mistachkin
|
20 |
|
|
7f4b50b…
|
jan.nijtmans
|
21 |
test_setup |
|
02bfb9b…
|
rberteig
|
22 |
|
|
02bfb9b…
|
rberteig
|
23 |
# binary |
|
02bfb9b…
|
rberteig
|
24 |
write_file binary "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" |
|
02bfb9b…
|
rberteig
|
25 |
|
|
02bfb9b…
|
rberteig
|
26 |
# text with CRLF lines |
|
02bfb9b…
|
rberteig
|
27 |
write_file crlf.txt [subst -nocommands -novariables \ |
|
02bfb9b…
|
rberteig
|
28 |
{ordinary text\r |
|
02bfb9b…
|
rberteig
|
29 |
cariage returns and line feeds\r |
|
02bfb9b…
|
rberteig
|
30 |
on several lines\r\n}] |
|
02bfb9b…
|
rberteig
|
31 |
|
|
02bfb9b…
|
rberteig
|
32 |
# text with mixed line endings |
|
02bfb9b…
|
rberteig
|
33 |
write_file cr-only.txt "AAA\rBBB\rCCC\r" |
|
02bfb9b…
|
rberteig
|
34 |
write_file cr-lf-crlf.txt "AAA\rBBB\nCCC\r\n" |
|
02bfb9b…
|
rberteig
|
35 |
|
|
02bfb9b…
|
rberteig
|
36 |
# unix plain text includes the empty file by generalization |
|
02bfb9b…
|
rberteig
|
37 |
write_file empty "" |
|
02bfb9b…
|
rberteig
|
38 |
write_file plain.txt { |
|
02bfb9b…
|
rberteig
|
39 |
Lorem ipsum |
|
02bfb9b…
|
rberteig
|
40 |
dolor sic amet |
|
02bfb9b…
|
rberteig
|
41 |
} |
|
02bfb9b…
|
rberteig
|
42 |
|
|
02bfb9b…
|
rberteig
|
43 |
# try long lines |
|
02bfb9b…
|
rberteig
|
44 |
set a3 "abcdefgh" |
|
02bfb9b…
|
rberteig
|
45 |
set a4 $a3$a3 |
|
02bfb9b…
|
rberteig
|
46 |
set a5 $a4$a4 |
|
02bfb9b…
|
rberteig
|
47 |
set a6 $a5$a5 |
|
02bfb9b…
|
rberteig
|
48 |
write_file line-0064 "$a6\n" |
|
02bfb9b…
|
rberteig
|
49 |
set a7 $a6$a6 |
|
02bfb9b…
|
rberteig
|
50 |
set a8 $a7$a7 |
|
02bfb9b…
|
rberteig
|
51 |
set a9 $a8$a8 |
|
02bfb9b…
|
rberteig
|
52 |
set a10 $a9$a9 |
|
02bfb9b…
|
rberteig
|
53 |
write_file line-1024 "$a10\n" |
|
02bfb9b…
|
rberteig
|
54 |
set a11 $a10$a10 |
|
17e1217…
|
mistachkin
|
55 |
write_file line-2048 "$a11\n" |
|
02bfb9b…
|
rberteig
|
56 |
set a12 $a11$a11 |
|
02bfb9b…
|
rberteig
|
57 |
write_file line-4096 "$a12\n" |
|
02bfb9b…
|
rberteig
|
58 |
set a13 $a12$a12 |
|
02bfb9b…
|
rberteig
|
59 |
write_file line-8192 "$a13\n" |
|
02bfb9b…
|
rberteig
|
60 |
set a14 $a13$a13 |
|
17e1217…
|
mistachkin
|
61 |
write_file line-16K "$a14\n" |
|
02bfb9b…
|
rberteig
|
62 |
set a15 $a14$a14 |
|
17e1217…
|
mistachkin
|
63 |
write_file line-32K "$a15\n" |
|
02bfb9b…
|
rberteig
|
64 |
set a16 $a15$a15 |
|
02bfb9b…
|
rberteig
|
65 |
write_file line-64K "$a16\n" |
|
02bfb9b…
|
rberteig
|
66 |
|
|
02bfb9b…
|
rberteig
|
67 |
# UTF-8 extends 7-bit ASCII using bytes 80 and above to encode |
|
7f4b50b…
|
jan.nijtmans
|
68 |
# larger character codes. Unicode uses U+0 through U+10FFFF only, |
|
02bfb9b…
|
rberteig
|
69 |
# with U+D800 through U+DFFF reserved for surrogate pairs. |
|
7f4b50b…
|
jan.nijtmans
|
70 |
# UTF-8 is valid if it is the shortest possible coding, encodes a |
|
02bfb9b…
|
rberteig
|
71 |
# valid Unicode code point. But it's complicated. |
|
02bfb9b…
|
rberteig
|
72 |
write_file utf-mod-c0-80 "11 bit NUL:\xC0\x80 is sometimes ok\n" |
|
02bfb9b…
|
rberteig
|
73 |
write_file utf-bad-e0-80-80 "16 bit NUL:\xE0\x80\x80 is bad\n" |
|
02bfb9b…
|
rberteig
|
74 |
write_file utf-bad-f0-80-80-80 "21 bit NUL:\xF0\x80\x80\x80 is bad\n" |
|
02bfb9b…
|
rberteig
|
75 |
write_file utf-bad-f8-80-80-80-80 "26 bit NUL:\xF8\x80\x80\x80\x80 is bad\n" |
|
02bfb9b…
|
rberteig
|
76 |
write_file utf-bad-fc-80-80-80-80-80 "31 bit NUL:\xFC\x80\x80\x80\x80\x80 is bad\n" |
|
02bfb9b…
|
rberteig
|
77 |
write_file utf-bad-fe-80-80-80-80-80-80 "36 bit NUL:\xFC\x80\x80\x80\x80\x80 is bad\n" |
|
02bfb9b…
|
rberteig
|
78 |
write_file utf-bad-c0-81 "overlong SOH:\xC0\x81 is bad\n" |
|
02bfb9b…
|
rberteig
|
79 |
write_file utf-bad-c0-bf "overlong '?':\xC0\xBF is bad\n" |
|
02bfb9b…
|
rberteig
|
80 |
write_file utf-bad-c1-bf "overlong DEL:\xC1\xBF is bad\n" |
|
02bfb9b…
|
rberteig
|
81 |
write_file utf-bad-f4-90-80-80 "U+110000 not allowed:\xF4\x90\x80 not unicode\n" |
|
02bfb9b…
|
rberteig
|
82 |
write_file utf-bad-f9-80-80-80-80 "U+2000000 not allowed:\xF9\x80\x80\x80\x80 not unicode\n" |
|
02bfb9b…
|
rberteig
|
83 |
write_file utf-bad-ff "no byte FF:\xFF\n" |
|
8705a52…
|
rberteig
|
84 |
write_file utf-ill16-lead "lead surrogate U+D800:\xED\xA0\x80 is ill formed\n" |
|
8705a52…
|
rberteig
|
85 |
write_file utf-ill16-trail "trail surrogate U+DC00:\xED\xB0\x80 is ill formed\n" |
|
02bfb9b…
|
rberteig
|
86 |
write_file utf-ill16-pair "surrogate pair U+10000:\xED\xA0\x80\xED\xB0\x80 is ill formed\n" |
|
02bfb9b…
|
rberteig
|
87 |
set emoji "micro-smile \xC2\xB5\xE2\x98\xBA\npale facepalm \xF0\x9F\xA4\xA6\xF0\x9F\x8F\xBB\n" |
|
02bfb9b…
|
rberteig
|
88 |
protOut $emoji |
|
02bfb9b…
|
rberteig
|
89 |
write_file utf-8-emoji $emoji |
|
8705a52…
|
rberteig
|
90 |
write_file utf-8-bom-emoji "\xef\xbb\xbf$emoji" |
|
8705a52…
|
rberteig
|
91 |
|
|
8705a52…
|
rberteig
|
92 |
# UTF-16 uses 16-bit values to cover all valid unicode code points |
|
8705a52…
|
rberteig
|
93 |
# from U+0 to U+10FFFF, using surrogate pairs to escape the BMP. |
|
8705a52…
|
rberteig
|
94 |
# Interchange require knowing (and preserving) byte order. |
|
4bbd5c3…
|
rberteig
|
95 |
set hello16LE "h\x00e\x00l\x00l\x00o\x00\n\x00" |
|
4bbd5c3…
|
rberteig
|
96 |
set hello16BE "\x00h\x00e\x00l\x00l\x00o\x00\n" |
|
4bbd5c3…
|
rberteig
|
97 |
write_file utf-16le-hello $hello16LE |
|
4bbd5c3…
|
rberteig
|
98 |
write_file utf-16be-hello $hello16BE |
|
4bbd5c3…
|
rberteig
|
99 |
set bomLE "\xff\xfe" |
|
4bbd5c3…
|
rberteig
|
100 |
set bomBE "\xfe\xff" |
|
4bbd5c3…
|
rberteig
|
101 |
write_file utf-16le-bomle-hello "$bomLE$hello16LE" |
|
4bbd5c3…
|
rberteig
|
102 |
write_file utf-16be-bombe-hello "$bomBE$hello16BE" |
|
4bbd5c3…
|
rberteig
|
103 |
write_file utf-16le-bombe-hello "$bomBE$hello16LE" |
|
4bbd5c3…
|
rberteig
|
104 |
write_file utf-16be-bomle-hello "$bomLE$hello16BE" |
|
8705a52…
|
rberteig
|
105 |
set le16 [read_file [file join $testdir utf16le.txt]] |
|
8705a52…
|
rberteig
|
106 |
set be16 [read_file [file join $testdir utf16be.txt]] |
|
7f4b50b…
|
jan.nijtmans
|
107 |
write_file utf-16le.txt $le16 |
|
8705a52…
|
rberteig
|
108 |
write_file utf-16be.txt $be16 |
|
7f4b50b…
|
jan.nijtmans
|
109 |
write_file utf-nobom-16le.txt [string range $le16 2 end] |
|
8705a52…
|
rberteig
|
110 |
write_file utf-nobom-16be.txt [string range $be16 2 end] |
|
7f4b50b…
|
jan.nijtmans
|
111 |
#write_file [file join $::env(TEMP) utf-nobom-16le.txt] [string range $le16 2 end] |
|
8705a52…
|
rberteig
|
112 |
#write_file [file join $::env(TEMP) utf-nobom-16be.txt] [string range $be16 2 end] |
|
02bfb9b…
|
rberteig
|
113 |
|
|
02bfb9b…
|
rberteig
|
114 |
# make all the test files known to fossil, then test |
|
02bfb9b…
|
rberteig
|
115 |
fossil addremove |
|
02bfb9b…
|
rberteig
|
116 |
fossil test-commit-warning --no-settings -v |
|
02bfb9b…
|
rberteig
|
117 |
test pre-commit-warnings-1 {[normalize_result] eq \ |
|
02bfb9b…
|
rberteig
|
118 |
[subst -nocommands -novariables [string trim { |
|
02bfb9b…
|
rberteig
|
119 |
1\tbinary\tbinary data |
|
02bfb9b…
|
rberteig
|
120 |
1\tcr-lf-crlf.txt\tmixed line endings |
|
02bfb9b…
|
rberteig
|
121 |
1\tcr-only.txt\tCR line endings |
|
02bfb9b…
|
rberteig
|
122 |
1\tcrlf.txt\tCR/LF line endings |
|
02bfb9b…
|
rberteig
|
123 |
0\tempty\t |
|
02bfb9b…
|
rberteig
|
124 |
0\tline-0064\t |
|
02bfb9b…
|
rberteig
|
125 |
0\tline-1024\t |
|
17e1217…
|
mistachkin
|
126 |
0\tline-16K\t |
|
17e1217…
|
mistachkin
|
127 |
0\tline-2048\t |
|
17e1217…
|
mistachkin
|
128 |
1\tline-32K\tlong lines |
|
02bfb9b…
|
rberteig
|
129 |
0\tline-4096\t |
|
02bfb9b…
|
rberteig
|
130 |
1\tline-64K\tlong lines |
|
17e1217…
|
mistachkin
|
131 |
0\tline-8192\t |
|
02bfb9b…
|
rberteig
|
132 |
0\tplain.txt\t |
|
4bbd5c3…
|
rberteig
|
133 |
1\tutf-16be-bombe-hello\tUnicode |
|
4bbd5c3…
|
rberteig
|
134 |
1\tutf-16be-bomle-hello\tUnicode |
|
8705a52…
|
rberteig
|
135 |
1\tutf-16be-hello\tbinary data |
|
8705a52…
|
rberteig
|
136 |
1\tutf-16be.txt\tUnicode |
|
8705a52…
|
rberteig
|
137 |
1\tutf-16le-bombe-hello\tUnicode |
|
8705a52…
|
rberteig
|
138 |
1\tutf-16le-bomle-hello\tUnicode |
|
8705a52…
|
rberteig
|
139 |
1\tutf-16le-hello\tbinary data |
|
8705a52…
|
rberteig
|
140 |
1\tutf-16le.txt\tUnicode |
|
8705a52…
|
rberteig
|
141 |
0\tutf-8-bom-emoji\t |
|
02bfb9b…
|
rberteig
|
142 |
0\tutf-8-emoji\t |
|
02bfb9b…
|
rberteig
|
143 |
1\tutf-bad-c0-81\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
144 |
1\tutf-bad-c0-bf\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
145 |
1\tutf-bad-c1-bf\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
146 |
1\tutf-bad-e0-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
147 |
1\tutf-bad-f0-80-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
148 |
1\tutf-bad-f4-90-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
149 |
1\tutf-bad-f8-80-80-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
150 |
1\tutf-bad-f9-80-80-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
151 |
1\tutf-bad-fc-80-80-80-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
152 |
1\tutf-bad-fe-80-80-80-80-80-80\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
153 |
1\tutf-bad-ff\tinvalid UTF-8 |
|
02bfb9b…
|
rberteig
|
154 |
0\tutf-ill16-lead\t |
|
02bfb9b…
|
rberteig
|
155 |
0\tutf-ill16-pair\t |
|
02bfb9b…
|
rberteig
|
156 |
0\tutf-ill16-trail\t |
|
02bfb9b…
|
rberteig
|
157 |
0\tutf-mod-c0-80\t |
|
8705a52…
|
rberteig
|
158 |
1\tutf-nobom-16be.txt\tbinary data |
|
8705a52…
|
rberteig
|
159 |
1\tutf-nobom-16le.txt\tbinary data |
|
8705a52…
|
rberteig
|
160 |
1}]]} |
|
8705a52…
|
rberteig
|
161 |
|
|
8705a52…
|
rberteig
|
162 |
|
|
8705a52…
|
rberteig
|
163 |
############################################################################### |
|
8705a52…
|
rberteig
|
164 |
|
|
a8b0c5f…
|
mistachkin
|
165 |
|
|
a8b0c5f…
|
mistachkin
|
166 |
test_cleanup |