From 43428e759d9fbc5a319c2b929bfb4469938cc386 Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 23 Dec 2021 01:54:47 +0000 Subject: Add EscapeAll and escape all spaces in links --- simpletext_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'simpletext_test.go') diff --git a/simpletext_test.go b/simpletext_test.go index c5b4cf9..d75a741 100644 --- a/simpletext_test.go +++ b/simpletext_test.go @@ -92,6 +92,35 @@ func TestEscapeSpace(t *testing.T) { } } +var allEscapes = map[string]string{ + "": ``, + "ContNet": `ContNet`, + "\t": `\t`, + "\n": `\n`, + "\f": `\f`, + "\r": `\r`, + " ": `\ `, + "\\": `\\`, + "\x00": `\x00`, + " ": `\ \ \ \ \ \ \ `, + " ": `\ \ \ \ \ \ `, + " ": `\ \ \ \ `, + " ": `\ \ \ `, + " ": `\ \ `, + "\b\v\\\x00\xff\u00ff\\xff": "\b\v\\\\\\x00\xff\u00ff\\\\xff", +} + +func TestEscapeAll(t *testing.T) { + for k, v := range allEscapes { + t.Run(k, func(t *testing.T) { + e := EscapeAll(k) + if e != v { + t.Errorf("EscapeAll(%q) -> %q, expected %q", k, e, v) + } + }) + } +} + var simpleUnescapes = map[string]string{ ``: "", `ContNet`: "ContNet", -- cgit