render_example_test.gno
1.15 Kb · 33 lines
1package rledemo
2
3// ExampleRender pins the realm's root Render output as a testable example.
4func ExampleRender() {
5 print(Render(""))
6 // Output:
7 // # Run-Length Encoding
8 //
9 // `<count><char>` pairs, demoing the [`p/moul/x/daily/rle`](/p/moul/x/daily/rle/v0) library.
10 //
11 // | input | encoded | size | round-trips |
12 // |---|---|---|---|
13 // | `aaaaaaaaaabbbbbbbbbb` | `10a10b` | 30% | ✅ |
14 // | `aaabbc` | `3a2b1c` | 100% | ✅ |
15 // | `abcdef` | `1a1b1c1d1e1f` | 200% | ✅ |
16 //
17 // > Over 100% means the encoding made the data **bigger**. RLE only wins on runny input, and `abcdef` is the honest counter-example.
18 //
19 // > Append text to the path to encode it — digits are rejected, since they would be ambiguous with a run count.
20}
21
22// ExampleRender_rejectsDigits pins the refusal path: digits cannot be encoded
23// because they are indistinguishable from a run count on the way back, and a
24// refused input is not echoed.
25func ExampleRender_rejectsDigits() {
26 print(Render("/ab3c"))
27 // Output:
28 // # Run-Length Encoding
29 //
30 // `<count><char>` pairs, demoing the [`p/moul/x/daily/rle`](/p/moul/x/daily/rle/v0) library.
31 //
32 // _rle: input must not contain digits_
33}