Welcome to little lamb

Code » md4c » lila-indent » tree

[lila-indent] / test / coverage.txt

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# Coverage

This file is just a collection of unit tests not covered elsewhere.

Most notably regression tests, tests improving code coverage and other useful
things may drop here.

(However any tests requiring any additional command line option, like enabling
an extension, must be included in their respective files.)


## GitHub Issues

### [Issue 2](https://github.com/mity/md4c/issues/2)

Raw HTML block:

```````````````````````````````` example
<gi att1=tok1 att2=tok2>
.
<gi att1=tok1 att2=tok2>
````````````````````````````````

Inline:

```````````````````````````````` example
foo <gi att1=tok1 att2=tok2> bar
.
<p>foo <gi att1=tok1 att2=tok2> bar</p>
````````````````````````````````

Inline with a line break:

```````````````````````````````` example
foo <gi att1=tok1
att2=tok2> bar
.
<p>foo <gi att1=tok1
att2=tok2> bar</p>
````````````````````````````````


### [Issue 4](https://github.com/mity/md4c/issues/4)

```````````````````````````````` example
![alt text with *entity* &copy;](img.png 'title')
.
<p><img src="img.png" alt="alt text with entity ©" title="title"></p>
````````````````````````````````


### [Issue 9](https://github.com/mity/md4c/issues/9)

```````````````````````````````` example
> [foo
> bar]: /url
>
> [foo bar]
.
<blockquote>
<p><a href="/url">foo
bar</a></p>
</blockquote>
````````````````````````````````


### [Issue 10](https://github.com/mity/md4c/issues/10)

```````````````````````````````` example
[x]:
x
- <?

  x
.
<ul>
<li><?

x
</li>
</ul>
````````````````````````````````


### [Issue 11](https://github.com/mity/md4c/issues/11)

```````````````````````````````` example
x [link](/url "foo &ndash; bar") x
.
<p>x <a href="/url" title="foo – bar">link</a> x</p>
````````````````````````````````


### [Issue 14](https://github.com/mity/md4c/issues/14)

```````````````````````````````` example
a***b* c*
.
<p>a*<em><em>b</em> c</em></p>
````````````````````````````````


### [Issue 15](https://github.com/mity/md4c/issues/15)

```````````````````````````````` example
***b* c*
.
<p>*<em><em>b</em> c</em></p>
````````````````````````````````


### [Issue 21](https://github.com/mity/md4c/issues/21)

```````````````````````````````` example
a*b**c*
.
<p>a<em>b**c</em></p>
````````````````````````````````


### [Issue 33](https://github.com/mity/md4c/issues/33)

```````````````````````````````` example
```&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
.
<pre><code class="language-&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;"></code></pre>
````````````````````````````````


### [Issue 36](https://github.com/mity/md4c/issues/36)

```````````````````````````````` example
__x_ _x___
.
<p><em><em>x</em> <em>x</em></em>_</p>
````````````````````````````````


### [Issue 39](https://github.com/mity/md4c/issues/39)

```````````````````````````````` example
[\\]: x
.
````````````````````````````````


### [Issue 40](https://github.com/mity/md4c/issues/40)

```````````````````````````````` example
[x](url
'title'
)x
.
<p><a href="url" title="title">x</a>x</p>
````````````````````````````````


### [Issue 65](https://github.com/mity/md4c/issues/65)

```````````````````````````````` example
`
.
<p>`</p>
````````````````````````````````


### [Issue 74](https://github.com/mity/md4c/issues/74)

```````````````````````````````` example
[f]:
-
    xx
-
.
<pre><code>xx
</code></pre>
<ul>
<li></li>
</ul>
````````````````````````````````


### [Issue 78](https://github.com/mity/md4c/issues/78)

```````````````````````````````` example
[SS ẞ]: /url
[ẞ SS]
.
<p><a href="/url">ẞ SS</a></p>
````````````````````````````````


### [Issue 83](https://github.com/mity/md4c/issues/83)

```````````````````````````````` example
foo
>
.
<p>foo</p>
<blockquote>
</blockquote>

````````````````````````````````


### [Issue 95](https://github.com/mity/md4c/issues/95)

```````````````````````````````` example
. foo
.
<p>. foo</p>
````````````````````````````````


### [Issue 96](https://github.com/mity/md4c/issues/96)

```````````````````````````````` example
[ab]: /foo
[a] [ab] [abc]
.
<p>[a] <a href="/foo">ab</a> [abc]</p>
````````````````````````````````

```````````````````````````````` example
[a b]: /foo
[a   b]
.
<p><a href="/foo">a   b</a></p>
````````````````````````````````


### [Issue 97](https://github.com/mity/md4c/issues/97)

```````````````````````````````` example
*a **b c* d**
.
<p><em>a <em><em>b c</em> d</em></em></p>

````````````````````````````````


### [Issue 100](https://github.com/mity/md4c/issues/100)

```````````````````````````````` example
<foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123>
.
<p><a href="mailto:foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123">foo@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123</a></p>
````````````````````````````````

```````````````````````````````` example
<foo@123456789012345678901234567890123456789012345678901234567890123x.123456789012345678901234567890123456789012345678901234567890123>
.
<p>&lt;foo@123456789012345678901234567890123456789012345678901234567890123x.123456789012345678901234567890123456789012345678901234567890123&gt;</p>
````````````````````````````````
(Note the `x` here which turns it over the max. allowed length limit.)


### [Issue 107](https://github.com/mity/md4c/issues/107)

```````````````````````````````` example
***foo *bar baz***
.
<p>*<strong>foo <em>bar baz</em></strong></p>

````````````````````````````````


### [Issue 124](https://github.com/mity/md4c/issues/124)

```````````````````````````````` example
~~~
                x
~~~

~~~
                 x
~~~
.
<pre><code>                x
</code></pre>
<pre><code>                 x
</code></pre>
````````````````````````````````


### [Issue 131](https://github.com/mity/md4c/issues/131)

```````````````````````````````` example
[![alt][img]][link]

[img]: img_url
[link]: link_url
.
<p><a href="link_url"><img src="img_url" alt="alt"></a></p>
````````````````````````````````


### [Issue 142](https://github.com/mity/md4c/issues/142)

```````````````````````````````` example
[fooﬗ]: /url
[fooﬕ]
.
<p>[fooﬕ]</p>
````````````````````````````````


### [Issue 149](https://github.com/mity/md4c/issues/149)

```````````````````````````````` example
- <script>
- foo
bar
</script>
.
<ul>
<li><script>
</li>
<li>foo
bar
</script></li>
</ul>
````````````````````````````````


## Code coverage

### `md_is_unicode_whitespace__()`

Unicode whitespace (here U+2000) forms a word boundary so these cannot be
resolved as emphasis span because there is no closer mark.

```````````````````````````````` example
*foo *bar
.
<p>*foo *bar</p>
````````````````````````````````


### `md_is_unicode_punct__()`

Ditto for Unicode punctuation (here U+00A1).

```````````````````````````````` example
*foo¡*bar
.
<p>*foo¡*bar</p>
````````````````````````````````


### `md_get_unicode_fold_info()`

```````````````````````````````` example
[Příliš žluťoučký kůň úpěl ďábelské ódy.]

[PŘÍLIŠ ŽLUŤOUČKÝ KŮŇ ÚPĚL ĎÁBELSKÉ ÓDY.]: /url
.
<p><a href="/url">Příliš žluťoučký kůň úpěl ďábelské ódy.</a></p>
````````````````````````````````


### `md_decode_utf8__()` and `md_decode_utf8_before__()`

```````````````````````````````` example
á*Á (U+00E1, i.e. two byte UTF-8 sequence)
 *  (U+2000, i.e. three byte UTF-8 sequence)
.
<p>á*Á (U+00E1, i.e. two byte UTF-8 sequence)
 *  (U+2000, i.e. three byte UTF-8 sequence)</p>
````````````````````````````````


### `md_is_link_destination_A()`

```````````````````````````````` example
[link](</url\.with\.escape>)
.
<p><a href="/url.with.escape">link</a></p>
````````````````````````````````


### `md_link_label_eq()`

```````````````````````````````` example
[foo bar]

[foo bar]: /url
.
<p><a href="/url">foo bar</a></p>
````````````````````````````````


### `md_is_inline_link_spec()`

```````````````````````````````` example
> [link](/url 'foo
> bar')
.
<blockquote>
<p><a href="/url" title="foo
bar">link</a></p>
</blockquote>
````````````````````````````````


### `md_build_ref_def_hashtable()`

All link labels in the following example all have the same FNV1a hash (after
normalization of the label, which means after converting to a vector of Unicode
codepoints and lowercase folding).

So the example triggers quite complex code paths which are not otherwise easily
tested.

```````````````````````````````` example
[foo]: /foo
[qnptgbh]: /qnptgbh
[abgbrwcv]: /abgbrwcv
[abgbrwcv]: /abgbrwcv2
[abgbrwcv]: /abgbrwcv3
[abgbrwcv]: /abgbrwcv4
[alqadfgn]: /alqadfgn

[foo]
[qnptgbh]
[abgbrwcv]
[alqadfgn]
[axgydtdu]
.
<p><a href="/foo">foo</a>
<a href="/qnptgbh">qnptgbh</a>
<a href="/abgbrwcv">abgbrwcv</a>
<a href="/alqadfgn">alqadfgn</a>
[axgydtdu]</p>
````````````````````````````````

For the sake of completeness, the following C program was used to find the hash
collisions by brute force:

~~~

#include <stdio.h>
#include <string.h>


static unsigned etalon;



#define MD_FNV1A_BASE       2166136261
#define MD_FNV1A_PRIME      16777619

static inline unsigned
fnv1a(unsigned base, const void* data, size_t n)
{
    const unsigned char* buf = (const unsigned char*) data;
    unsigned hash = base;
    size_t i;

    for(i = 0; i < n; i++) {
        hash ^= buf[i];
        hash *= MD_FNV1A_PRIME;
    }

    return hash;
}


static unsigned
unicode_hash(const char* data, size_t n)
{
    unsigned value;
    unsigned hash = MD_FNV1A_BASE;
    int i;

    for(i = 0; i < n; i++) {
        value = data[i];
        hash = fnv1a(hash, &value, sizeof(unsigned));
    }

    return hash;
}


static void
recurse(char* buffer, size_t off, size_t len)
{
    int ch;

    if(off < len - 1) {
        for(ch = 'a'; ch <= 'z'; ch++) {
            buffer[off] = ch;
            recurse(buffer, off+1, len);
        }
    } else {
        for(ch = 'a'; ch <= 'z'; ch++) {
            buffer[off] = ch;
            if(unicode_hash(buffer, len) == etalon) {
                printf("Dup: %.*s\n", (int)len, buffer);
            }
        }
    }
}

int
main(int argc, char** argv)
{
    char buffer[32];
    int len;

    if(argc < 2)
        etalon = unicode_hash("foo", 3);
    else
        etalon = unicode_hash(argv[1], strlen(argv[1]));

    for(len = 1; len <= sizeof(buffer); len++)
        recurse(buffer, 0, len);

    return 0;
}
~~~