Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

render_example_test.gno

1.06 Kb · 31 lines
 1package base32demo
 2
 3// ExampleRender pins the realm's Render output as a testable example. The RFC
 4// 4648 column is the §10 vector set, so this doubles as a conformance test.
 5func ExampleRender() {
 6	print(Render(""))
 7	// Output:
 8	// # Base32
 9	//
10	// RFC 4648 and Crockford, demoing the [`p/moul/x/daily/base32`](/p/moul/x/daily/base32/v0) library.
11	//
12	// | input | RFC 4648 | Crockford |
13	// |---|---|---|
14	// | _(empty)_ | `` | `` |
15	// | `f` | `MY======` | `CR` |
16	// | `fo` | `MZXQ====` | `CSQG` |
17	// | `foo` | `MZXW6===` | `CSQPY` |
18	// | `foob` | `MZXW6YQ=` | `CSQPYRG` |
19	// | `fooba` | `MZXW6YTB` | `CSQPYRK1` |
20	// | `foobar` | `MZXW6YTBOI======` | `CSQPYRK1E8` |
21	//
22	// ## Crockford forgives
23	//
24	// `hello` encodes to `D1JPRV3F`, and all of these decode back to it:
25	//
26	// - `D1JPRV3F` → `hello` ✅
27	// - `d1jprv3f` → `hello` ✅
28	// - `D1-JPRV3F` → `hello` ✅
29	//
30	// > Crockford folds case, reads `I`/`L` as `1` and `O` as `0`, and ignores hyphens — so an identifier survives being read aloud and typed back. `U` is left out of the alphabet on purpose.
31}