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.64 Kb · 68 lines
 1package hexdumpdemo
 2
 3// ExampleRender pins the realm's Render output as a testable example.
 4func ExampleRender() {
 5	print(Render(""))
 6	// Output:
 7	// # Hexdump
 8	//
 9	// Bytes in the classic `xxd -C` layout, demoing the [`p/moul/x/daily/hexdump`](/p/moul/x/daily/hexdump/v0) library.
10	//
11	// ## A plain string
12	//
13	// ```
14	// 00000000  48 65 6c 6c 6f 2c 20 67  6e 6f 2e 6c 61 6e 64 21  |Hello, gno.land!|
15	// ```
16	//
17	// _`Hello, gno.land!` → 16 bytes._
18	//
19	// ## Alignment on a partial line
20	//
21	// The last line is short, so the hex columns are padded and the ASCII gutter stays put — that alignment is the whole point of the layout.
22	//
23	// ```
24	// 00000000  30 31 32 33 34 35 36 37  38 39 61 62 63 64 65 66  |0123456789abcdef|
25	// 00000010  68 69                                             |hi|
26	// ```
27	//
28	// _`0123456789abcdefhi` → 18 bytes._
29	//
30	// ## What a rendered string hides
31	//
32	// These two look identical in any UI:
33	//
34	// - `"hi"`
35	// - `"hi "` — one trailing space
36	//
37	// ```
38	// 00000000  68 69                                             |hi|
39	// ```
40	//
41	// _`hi` → 2 bytes._
42	//
43	// ```
44	// 00000000  68 69 20                                          |hi |
45	// ```
46	//
47	// _`hi ` → 3 bytes._
48	//
49	// ## Multi-byte UTF-8
50	//
51	// `"café"` is 5 bytes, not 4: `é` is `c3 a9`. Non-printables render as `.`.
52	//
53	// ```
54	// 00000000  63 61 66 c3 a9                                    |caf..|
55	// ```
56	//
57	// _`café` → 5 bytes._
58	//
59	// ## Control characters
60	//
61	// A NUL, a newline and a tab are invisible in text and obvious here.
62	//
63	// ```
64	// 00000000  00 0a 09 6f 6b                                    |...ok|
65	// ```
66	//
67	// _5 bytes._
68}