escape_test.gno
1.12 Kb · 23 lines
1package rledemo
2
3import (
4 "testing"
5
6 "gno.land/p/nt/uassert/v0"
7)
8
9// payload closes a one-backtick code span and opens an image. Written raw, as
10// v0 does, it renders as markup the realm appears to have authored.
11const payload = "x`  `y"
12
13// TestRenderEscapesInput pins that an accepted input is echoed as a code span
14// it cannot close, and so is its encoding, which carries the backtick through.
15func TestRenderEscapesInput(t *testing.T) {
16 uassert.Equal(t, "# Run-Length Encoding\n\n`<count><char>` pairs, demoing the [`p/moul/x/daily/rle`](/p/moul/x/daily/rle/v0) library.\n\n## ``x`  `y``\n\n- encoded: ``1x1`1 1!1[1p1]1(1h2t1p1s1:1e1.1i1o1)1 1`1y``\n- size: **190%**\n- round-trips: ✅\n", Render("/"+payload))
17}
18
19// TestRenderRejectsBeforeEcho pins the order: rle refuses digits, and the
20// refused input is never written back. v0 wrote the heading first.
21func TestRenderRejectsBeforeEcho(t *testing.T) {
22 uassert.Equal(t, "# Run-Length Encoding\n\n`<count><char>` pairs, demoing the [`p/moul/x/daily/rle`](/p/moul/x/daily/rle/v0) library.\n\n_rle: input must not contain digits_\n", Render("/1"+payload))
23}