From 4d75c543d2718384e68b371cdb7cb16f83f4777c Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 8 Oct 2018 14:38:51 +1000 Subject: [PATCH] Refactored most of the string-string tests to reduce the amount of boilerplate. --- misc_test.go | 245 +++++++++++++++++++++++++------------------------ plugin_test.go | 212 +++++++++++++++++++++--------------------- 2 files changed, 233 insertions(+), 224 deletions(-) diff --git a/misc_test.go b/misc_test.go index 1ed083fe..104d57c2 100644 --- a/misc_test.go +++ b/misc_test.go @@ -1017,31 +1017,31 @@ func TestWordFilters(t *testing.T) { func TestSlugs(t *testing.T) { var res string - var msgList []MEPair + var msgList = &MEPairList{nil} common.Config.BuildSlugs = true // Flip this switch, otherwise all the tests will fail - msgList = addMEPair(msgList, "Unknown", "unknown") - msgList = addMEPair(msgList, "Unknown2", "unknown2") - msgList = addMEPair(msgList, "Unknown ", "unknown") - msgList = addMEPair(msgList, "Unknown 2", "unknown-2") - msgList = addMEPair(msgList, "Unknown 2", "unknown-2") - msgList = addMEPair(msgList, "Admin Alice", "admin-alice") - msgList = addMEPair(msgList, "Admin_Alice", "adminalice") - msgList = addMEPair(msgList, "Admin_Alice-", "adminalice") - msgList = addMEPair(msgList, "-Admin_Alice-", "adminalice") - msgList = addMEPair(msgList, "-Admin@Alice-", "adminalice") - msgList = addMEPair(msgList, "-Admin😀Alice-", "adminalice") - msgList = addMEPair(msgList, "u", "u") - msgList = addMEPair(msgList, "", "untitled") - msgList = addMEPair(msgList, " ", "untitled") - msgList = addMEPair(msgList, "-", "untitled") - msgList = addMEPair(msgList, "--", "untitled") - msgList = addMEPair(msgList, "é", "é") - msgList = addMEPair(msgList, "-é-", "é") - msgList = addMEPair(msgList, "-你好-", "untitled") - msgList = addMEPair(msgList, "-こにちは-", "untitled") + msgList.Add("Unknown", "unknown") + msgList.Add("Unknown2", "unknown2") + msgList.Add("Unknown ", "unknown") + msgList.Add("Unknown 2", "unknown-2") + msgList.Add("Unknown 2", "unknown-2") + msgList.Add("Admin Alice", "admin-alice") + msgList.Add("Admin_Alice", "adminalice") + msgList.Add("Admin_Alice-", "adminalice") + msgList.Add("-Admin_Alice-", "adminalice") + msgList.Add("-Admin@Alice-", "adminalice") + msgList.Add("-Admin😀Alice-", "adminalice") + msgList.Add("u", "u") + msgList.Add("", "untitled") + msgList.Add(" ", "untitled") + msgList.Add("-", "untitled") + msgList.Add("--", "untitled") + msgList.Add("é", "é") + msgList.Add("-é-", "é") + msgList.Add("-你好-", "untitled") + msgList.Add("-こにちは-", "untitled") - for _, item := range msgList { + for _, item := range msgList.Items { t.Log("Testing string '" + item.Msg + "'") res = common.NameToSlug(item.Msg) if res != item.Expects { @@ -1151,14 +1151,19 @@ type METri struct { Expects string } -func addMETri(msgList []METri, args ...string) []METri { +type METriList struct { + Items []METri +} + +func (tlist *METriList) Add(args ...string) { if len(args) < 2 { panic("need 2 or more args") } if len(args) > 2 { - return append(msgList, METri{args[0], args[1], args[2]}) + tlist.Items = append(tlist.Items, METri{args[0], args[1], args[2]}) + } else { + tlist.Items = append(tlist.Items, METri{"", args[0], args[1]}) } - return append(msgList, METri{"", args[0], args[1]}) } type CountTest struct { @@ -1215,91 +1220,91 @@ func TestWordCount(t *testing.T) { } func TestPreparser(t *testing.T) { - var msgList []METri + var msgList = &METriList{nil} // Note: The open tag is evaluated without knowledge of the close tag for efficiency and simplicity, so the parser autofills the associated close tag when it finds an open tag without a partner - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, " ", "") - msgList = addMETri(msgList, " hi", "hi") - msgList = addMETri(msgList, "hi ", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, ":grinning:", "😀") - msgList = addMETri(msgList, "😀", "😀") - msgList = addMETri(msgList, " ", "") - msgList = addMETri(msgList, "

", "") - msgList = addMETri(msgList, "

", "") - msgList = addMETri(msgList, "

", "") + msgList.Add("", "") + msgList.Add(" ", "") + msgList.Add(" hi", "hi") + msgList.Add("hi ", "hi") + msgList.Add("hi", "hi") + msgList.Add(":grinning:", "😀") + msgList.Add("😀", "😀") + msgList.Add(" ", "") + msgList.Add("

", "") + msgList.Add("

", "") + msgList.Add("

", "") - msgList = addMETri(msgList, "<", "<") - msgList = addMETri(msgList, ">", ">") - msgList = addMETri(msgList, "", "<meow>") - msgList = addMETri(msgList, "<", "&lt;") - msgList = addMETri(msgList, "&", "&") + msgList.Add("<", "<") + msgList.Add(">", ">") + msgList.Add("", "<meow>") + msgList.Add("<", "&lt;") + msgList.Add("&", "&") // Note: strings.TrimSpace strips newlines, if there's nothing before or after them - msgList = addMETri(msgList, "
", "") - msgList = addMETri(msgList, "
", "") - msgList = addMETri(msgList, "\\n", "\n", "") - msgList = addMETri(msgList, "\\n\\n", "\n\n", "") - msgList = addMETri(msgList, "\\n\\n\\n", "\n\n\n", "") - msgList = addMETri(msgList, "\\r\\n", "\r\n", "") // Windows style line ending - msgList = addMETri(msgList, "\\n\\r", "\n\r", "") + msgList.Add("
", "") + msgList.Add("
", "") + msgList.Add("\\n", "\n", "") + msgList.Add("\\n\\n", "\n\n", "") + msgList.Add("\\n\\n\\n", "\n\n\n", "") + msgList.Add("\\r\\n", "\r\n", "") // Windows style line ending + msgList.Add("\\n\\r", "\n\r", "") - msgList = addMETri(msgList, "ho
ho", "ho\n\nho") - msgList = addMETri(msgList, "ho
ho", "ho\n\nho") - msgList = addMETri(msgList, "ho\\nho", "ho\nho", "ho\nho") - msgList = addMETri(msgList, "ho\\n\\nho", "ho\n\nho", "ho\n\nho") - //msgList = addMETri(msgList, "ho\\n\\n\\n\\nho", "ho\n\n\n\nho", "ho\n\n\nho") - msgList = addMETri(msgList, "ho\\r\\nho", "ho\r\nho", "ho\nho") // Windows style line ending - msgList = addMETri(msgList, "ho\\n\\rho", "ho\n\rho", "ho\nho") + msgList.Add("ho
ho", "ho\n\nho") + msgList.Add("ho
ho", "ho\n\nho") + msgList.Add("ho\\nho", "ho\nho", "ho\nho") + msgList.Add("ho\\n\\nho", "ho\n\nho", "ho\n\nho") + //msgList.Add("ho\\n\\n\\n\\nho", "ho\n\n\n\nho", "ho\n\n\nho") + msgList.Add("ho\\r\\nho", "ho\r\nho", "ho\nho") // Windows style line ending + msgList.Add("ho\\n\\rho", "ho\n\rho", "ho\nho") - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "
hi
", "<div>hi</div>") - msgList = addMETri(msgList, "hi", "hi") // This is stripped since the editor (Trumbowyg) likes blasting useless spans - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, ">hi", ">hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi</b>") - msgList = addMETri(msgList, "", "</b>") - msgList = addMETri(msgList, "", "</del>") - msgList = addMETri(msgList, "", "</strong>") - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "hi", "hi") - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, "", "") - msgList = addMETri(msgList, "<>", "<></>") - msgList = addMETri(msgList, "<>", "</><>") - msgList = addMETri(msgList, "<>", "<>") - msgList = addMETri(msgList, "", "</>") - msgList = addMETri(msgList, "@", "@") - msgList = addMETri(msgList, "@Admin", "@1") - msgList = addMETri(msgList, "@Bah", "@Bah") - msgList = addMETri(msgList, " @Admin", "@1") - msgList = addMETri(msgList, "\n@Admin", "@1") - msgList = addMETri(msgList, "@Admin\n", "@1") - msgList = addMETri(msgList, "@Admin\ndd", "@1\ndd") - msgList = addMETri(msgList, "d@Admin", "d@Admin") - //msgList = addMETri(msgList, "byte 0", string([]byte{0}), "") - msgList = addMETri(msgList, "byte 'a'", string([]byte{'a'}), "a") - //msgList = addMETri(msgList, "byte 255", string([]byte{255}), "") - //msgList = addMETri(msgList, "rune 0", string([]rune{0}), "") + msgList.Add("", "") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("
hi
", "<div>hi</div>") + msgList.Add("hi", "hi") // This is stripped since the editor (Trumbowyg) likes blasting useless spans + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add(">hi", ">hi") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi</b>") + msgList.Add("
", "</b>") + msgList.Add("", "</del>") + msgList.Add("", "</strong>") + msgList.Add("", "") + msgList.Add("hi", "hi") + msgList.Add("hi", "hi") + msgList.Add("", "") + msgList.Add("", "") + msgList.Add("", "") + msgList.Add("<>", "<></>") + msgList.Add("<>", "</><>") + msgList.Add("<>", "<>") + msgList.Add("", "</>") + msgList.Add("@", "@") + msgList.Add("@Admin", "@1") + msgList.Add("@Bah", "@Bah") + msgList.Add(" @Admin", "@1") + msgList.Add("\n@Admin", "@1") + msgList.Add("@Admin\n", "@1") + msgList.Add("@Admin\ndd", "@1\ndd") + msgList.Add("d@Admin", "d@Admin") + //msgList.Add("byte 0", string([]byte{0}), "") + msgList.Add("byte 'a'", string([]byte{'a'}), "a") + //msgList.Add("byte 255", string([]byte{255}), "") + //msgList.Add("rune 0", string([]rune{0}), "") // TODO: Do a test with invalid UTF-8 input - for _, item := range msgList { + for _, item := range msgList.Items { res := common.PreparseMessage(item.Msg) if res != item.Expects { if item.Name != "" { @@ -1314,28 +1319,28 @@ func TestPreparser(t *testing.T) { } func TestParser(t *testing.T) { - var msgList []METri + var msgList = &METriList{nil} - msgList = addMETri(msgList, "//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora") - msgList = addMETri(msgList, "https://github.com/Azareal/Gosora", "https://github.com/Azareal/Gosora") - msgList = addMETri(msgList, "http://github.com/Azareal/Gosora", "http://github.com/Azareal/Gosora") - msgList = addMETri(msgList, "//github.com/Azareal/Gosora\n", "//github.com/Azareal/Gosora
") - msgList = addMETri(msgList, "\n//github.com/Azareal/Gosora", "
//github.com/Azareal/Gosora") - msgList = addMETri(msgList, "\n//github.com/Azareal/Gosora\n", "
//github.com/Azareal/Gosora
") - msgList = addMETri(msgList, "//github.com/Azareal/Gosora\n//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora
//github.com/Azareal/Gosora") - msgList = addMETri(msgList, "//github.com/Azareal/Gosora\n\n//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora

//github.com/Azareal/Gosora") - msgList = addMETri(msgList, "//"+common.Site.URL, "//"+common.Site.URL+"") - msgList = addMETri(msgList, "//"+common.Site.URL+"\n", "//"+common.Site.URL+"
") - msgList = addMETri(msgList, "//"+common.Site.URL+"\n//"+common.Site.URL, "//"+common.Site.URL+"
//"+common.Site.URL+"") + msgList.Add("//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora") + msgList.Add("https://github.com/Azareal/Gosora", "https://github.com/Azareal/Gosora") + msgList.Add("http://github.com/Azareal/Gosora", "http://github.com/Azareal/Gosora") + msgList.Add("//github.com/Azareal/Gosora\n", "//github.com/Azareal/Gosora
") + msgList.Add("\n//github.com/Azareal/Gosora", "
//github.com/Azareal/Gosora") + msgList.Add("\n//github.com/Azareal/Gosora\n", "
//github.com/Azareal/Gosora
") + msgList.Add("//github.com/Azareal/Gosora\n//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora
//github.com/Azareal/Gosora") + msgList.Add("//github.com/Azareal/Gosora\n\n//github.com/Azareal/Gosora", "//github.com/Azareal/Gosora

//github.com/Azareal/Gosora") + msgList.Add("//"+common.Site.URL, "//"+common.Site.URL+"") + msgList.Add("//"+common.Site.URL+"\n", "//"+common.Site.URL+"
") + msgList.Add("//"+common.Site.URL+"\n//"+common.Site.URL, "//"+common.Site.URL+"
//"+common.Site.URL+"") - msgList = addMETri(msgList, "#tid-1", "#tid-1") - msgList = addMETri(msgList, "https://github.com/Azareal/Gosora/#tid-1", "https://github.com/Azareal/Gosora/#tid-1") - msgList = addMETri(msgList, "#fid-1", "#fid-1") - msgList = addMETri(msgList, "@1", "@Admin") - msgList = addMETri(msgList, "@0", "[Invalid Profile]") - msgList = addMETri(msgList, "@-1", "[Invalid Profile]1") + msgList.Add("#tid-1", "#tid-1") + msgList.Add("https://github.com/Azareal/Gosora/#tid-1", "https://github.com/Azareal/Gosora/#tid-1") + msgList.Add("#fid-1", "#fid-1") + msgList.Add("@1", "@Admin") + msgList.Add("@0", "[Invalid Profile]") + msgList.Add("@-1", "[Invalid Profile]1") - for _, item := range msgList { + for _, item := range msgList.Items { res := common.ParseMessage(item.Msg, 1, "forums") if res != item.Expects { if item.Name != "" { diff --git a/plugin_test.go b/plugin_test.go index 0caeaf66..a34fdd79 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -10,8 +10,12 @@ type MEPair struct { Expects string } -func addMEPair(msgList []MEPair, msg string, expects string) []MEPair { - return append(msgList, MEPair{msg, expects}) +type MEPairList struct { + Items []MEPair +} + +func (tlist *MEPairList) Add(msg string, expects string) { + tlist.Items = append(tlist.Items, MEPair{msg, expects}) } func TestBBCodeRender(t *testing.T) { @@ -22,47 +26,47 @@ func TestBBCodeRender(t *testing.T) { } var res string - var msgList []MEPair - msgList = addMEPair(msgList, "", "") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, "[b]", "") - msgList = addMEPair(msgList, "[b][/b]", "") - msgList = addMEPair(msgList, "hi", "hi") - msgList = addMEPair(msgList, "😀", "😀") - msgList = addMEPair(msgList, "[b]😀[/b]", "😀") - msgList = addMEPair(msgList, "[b]😀😀😀[/b]", "😀😀😀") - msgList = addMEPair(msgList, "[b]hi[/b]", "hi") - msgList = addMEPair(msgList, "[u]hi[/u]", "hi") - msgList = addMEPair(msgList, "[i]hi[/i]", "hi") - msgList = addMEPair(msgList, "[s]hi[/s]", "hi") - msgList = addMEPair(msgList, "[c]hi[/c]", "[c]hi[/c]") + var msgList = &MEPairList{nil} + msgList.Add("", "") + msgList.Add(" ", " ") + msgList.Add(" ", " ") + msgList.Add(" ", " ") + msgList.Add("[b]", "") + msgList.Add("[b][/b]", "") + msgList.Add("hi", "hi") + msgList.Add("😀", "😀") + msgList.Add("[b]😀[/b]", "😀") + msgList.Add("[b]😀😀😀[/b]", "😀😀😀") + msgList.Add("[b]hi[/b]", "hi") + msgList.Add("[u]hi[/u]", "hi") + msgList.Add("[i]hi[/i]", "hi") + msgList.Add("[s]hi[/s]", "hi") + msgList.Add("[c]hi[/c]", "[c]hi[/c]") if !testing.Short() { - //msgList = addMEPair(msgList, "[b]hi[/i]", "[b]hi[/i]") - //msgList = addMEPair(msgList, "[/b]hi[b]", "[/b]hi[b]") - //msgList = addMEPair(msgList, "[/b]hi[/b]", "[/b]hi[/b]") - //msgList = addMEPair(msgList, "[b][b]hi[/b]", "hi") - //msgList = addMEPair(msgList, "[b][b]hi", "[b][b]hi") - //msgList = addMEPair(msgList, "[b][b][b]hi", "[b][b][b]hi") - //msgList = addMEPair(msgList, "[/b]hi", "[/b]hi") + //msgList.Add("[b]hi[/i]", "[b]hi[/i]") + //msgList.Add("[/b]hi[b]", "[/b]hi[b]") + //msgList.Add("[/b]hi[/b]", "[/b]hi[/b]") + //msgList.Add("[b][b]hi[/b]", "hi") + //msgList.Add("[b][b]hi", "[b][b]hi") + //msgList.Add("[b][b][b]hi", "[b][b][b]hi") + //msgList.Add("[/b]hi", "[/b]hi") } - msgList = addMEPair(msgList, "[code]hi[/code]", "hi") - msgList = addMEPair(msgList, "[code][b]hi[/b][/code]", "[b]hi[/b]") - msgList = addMEPair(msgList, "[code][b]hi[/code][/b]", "[b]hi[/b]") - msgList = addMEPair(msgList, "[quote]hi[/quote]", "hi") - msgList = addMEPair(msgList, "[quote][b]hi[/b][/quote]", "hi") - msgList = addMEPair(msgList, "[quote][b]h[/b][/quote]", "h") - msgList = addMEPair(msgList, "[quote][b][/b][/quote]", "") - msgList = addMEPair(msgList, "[url][/url]", "") - msgList = addMEPair(msgList, "[url]https://github.com/Azareal/Gosora[/url]", "https://github.com/Azareal/Gosora") - msgList = addMEPair(msgList, "[url]http://github.com/Azareal/Gosora[/url]", "http://github.com/Azareal/Gosora") - msgList = addMEPair(msgList, "[url]//github.com/Azareal/Gosora[/url]", "//github.com/Azareal/Gosora") - msgList = addMEPair(msgList, "-你好-", "-你好-") - msgList = addMEPair(msgList, "[i]-你好-[/i]", "-你好-") // TODO: More of these Unicode tests? Emoji, Chinese, etc.? + msgList.Add("[code]hi[/code]", "hi") + msgList.Add("[code][b]hi[/b][/code]", "[b]hi[/b]") + msgList.Add("[code][b]hi[/code][/b]", "[b]hi[/b]") + msgList.Add("[quote]hi[/quote]", "hi") + msgList.Add("[quote][b]hi[/b][/quote]", "hi") + msgList.Add("[quote][b]h[/b][/quote]", "h") + msgList.Add("[quote][b][/b][/quote]", "") + msgList.Add("[url][/url]", "") + msgList.Add("[url]https://github.com/Azareal/Gosora[/url]", "https://github.com/Azareal/Gosora") + msgList.Add("[url]http://github.com/Azareal/Gosora[/url]", "http://github.com/Azareal/Gosora") + msgList.Add("[url]//github.com/Azareal/Gosora[/url]", "//github.com/Azareal/Gosora") + msgList.Add("-你好-", "-你好-") + msgList.Add("[i]-你好-[/i]", "-你好-") // TODO: More of these Unicode tests? Emoji, Chinese, etc.? t.Log("Testing bbcodeFullParse") - for _, item := range msgList { + for _, item := range msgList.Items { res = bbcodeFullParse(item.Msg) if res != item.Expects { t.Error("Testing string '" + item.Msg + "'") @@ -211,70 +215,70 @@ func TestMarkdownRender(t *testing.T) { } var res string - var msgList []MEPair + var msgList = &MEPairList{nil} // TODO: Fix more of these odd cases - msgList = addMEPair(msgList, "", "") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, " ", " ") - msgList = addMEPair(msgList, "\t", "\t") - msgList = addMEPair(msgList, "\n", "\n") - msgList = addMEPair(msgList, "*", "*") - //msgList = addMEPair(msgList, "**", "") - msgList = addMEPair(msgList, "h", "h") - msgList = addMEPair(msgList, "hi", "hi") - msgList = addMEPair(msgList, "**h**", "h") - msgList = addMEPair(msgList, "**hi**", "hi") - msgList = addMEPair(msgList, "_h_", "h") - msgList = addMEPair(msgList, "_hi_", "hi") - msgList = addMEPair(msgList, "*h*", "h") - msgList = addMEPair(msgList, "*hi*", "hi") - msgList = addMEPair(msgList, "~h~", "h") - msgList = addMEPair(msgList, "~hi~", "hi") - msgList = addMEPair(msgList, "*hi**", "hi*") - msgList = addMEPair(msgList, "**hi***", "hi*") - //msgList = addMEPair(msgList, "**hi*", "*hi") - msgList = addMEPair(msgList, "***hi***", "hi") - msgList = addMEPair(msgList, "***h***", "h") - msgList = addMEPair(msgList, "\\***h**\\*", "*h*") - msgList = addMEPair(msgList, "\\*\\**h*\\*\\*", "**h**") - msgList = addMEPair(msgList, "\\*hi\\*", "*hi*") - msgList = addMEPair(msgList, "d\\*hi\\*", "d*hi*") - msgList = addMEPair(msgList, "\\*hi\\*d", "*hi*d") - msgList = addMEPair(msgList, "d\\*hi\\*d", "d*hi*d") - msgList = addMEPair(msgList, "\\", "\\") - msgList = addMEPair(msgList, "\\\\", "\\\\") - msgList = addMEPair(msgList, "\\d", "\\d") - msgList = addMEPair(msgList, "\\\\d", "\\\\d") - msgList = addMEPair(msgList, "\\\\\\d", "\\\\\\d") - msgList = addMEPair(msgList, "d\\", "d\\") - msgList = addMEPair(msgList, "\\d\\", "\\d\\") - msgList = addMEPair(msgList, "*_hi_*", "hi") - msgList = addMEPair(msgList, "*~hi~*", "hi") - //msgList = addMEPair(msgList, "~*hi*~", "hi") - //msgList = addMEPair(msgList, "~ *hi* ~", " hi ") - msgList = addMEPair(msgList, "_~hi~_", "hi") - msgList = addMEPair(msgList, "***~hi~***", "hi") - msgList = addMEPair(msgList, "**", "**") - msgList = addMEPair(msgList, "***", "***") - msgList = addMEPair(msgList, "****", "****") - msgList = addMEPair(msgList, "*****", "*****") - msgList = addMEPair(msgList, "******", "******") - msgList = addMEPair(msgList, "*******", "*******") - msgList = addMEPair(msgList, "~~", "~~") - msgList = addMEPair(msgList, "~~~", "~~~") - msgList = addMEPair(msgList, "~~~~", "~~~~") - msgList = addMEPair(msgList, "~~~~~", "~~~~~") - msgList = addMEPair(msgList, "__", "__") - msgList = addMEPair(msgList, "___", "___") - msgList = addMEPair(msgList, "_ _", " ") - msgList = addMEPair(msgList, "* *", " ") - msgList = addMEPair(msgList, "** **", " ") - msgList = addMEPair(msgList, "*** ***", " ") - msgList = addMEPair(msgList, "-你好-", "-你好-") - msgList = addMEPair(msgList, "*-你好-*", "-你好-") // TODO: More of these Unicode tests? Emoji, Chinese, etc.? + msgList.Add("", "") + msgList.Add(" ", " ") + msgList.Add(" ", " ") + msgList.Add(" ", " ") + msgList.Add("\t", "\t") + msgList.Add("\n", "\n") + msgList.Add("*", "*") + //msgList.Add("**", "") + msgList.Add("h", "h") + msgList.Add("hi", "hi") + msgList.Add("**h**", "h") + msgList.Add("**hi**", "hi") + msgList.Add("_h_", "h") + msgList.Add("_hi_", "hi") + msgList.Add("*h*", "h") + msgList.Add("*hi*", "hi") + msgList.Add("~h~", "h") + msgList.Add("~hi~", "hi") + msgList.Add("*hi**", "hi*") + msgList.Add("**hi***", "hi*") + //msgList.Add("**hi*", "*hi") + msgList.Add("***hi***", "hi") + msgList.Add("***h***", "h") + msgList.Add("\\***h**\\*", "*h*") + msgList.Add("\\*\\**h*\\*\\*", "**h**") + msgList.Add("\\*hi\\*", "*hi*") + msgList.Add("d\\*hi\\*", "d*hi*") + msgList.Add("\\*hi\\*d", "*hi*d") + msgList.Add("d\\*hi\\*d", "d*hi*d") + msgList.Add("\\", "\\") + msgList.Add("\\\\", "\\\\") + msgList.Add("\\d", "\\d") + msgList.Add("\\\\d", "\\\\d") + msgList.Add("\\\\\\d", "\\\\\\d") + msgList.Add("d\\", "d\\") + msgList.Add("\\d\\", "\\d\\") + msgList.Add("*_hi_*", "hi") + msgList.Add("*~hi~*", "hi") + //msgList.Add("~*hi*~", "hi") + //msgList.Add("~ *hi* ~", " hi ") + msgList.Add("_~hi~_", "hi") + msgList.Add("***~hi~***", "hi") + msgList.Add("**", "**") + msgList.Add("***", "***") + msgList.Add("****", "****") + msgList.Add("*****", "*****") + msgList.Add("******", "******") + msgList.Add("*******", "*******") + msgList.Add("~~", "~~") + msgList.Add("~~~", "~~~") + msgList.Add("~~~~", "~~~~") + msgList.Add("~~~~~", "~~~~~") + msgList.Add("__", "__") + msgList.Add("___", "___") + msgList.Add("_ _", " ") + msgList.Add("* *", " ") + msgList.Add("** **", " ") + msgList.Add("*** ***", " ") + msgList.Add("-你好-", "-你好-") + msgList.Add("*-你好-*", "-你好-") // TODO: More of these Unicode tests? Emoji, Chinese, etc.? - for _, item := range msgList { + for _, item := range msgList.Items { res = markdownParse(item.Msg) if res != item.Expects { t.Error("Testing string '" + item.Msg + "'") @@ -284,7 +288,7 @@ func TestMarkdownRender(t *testing.T) { } } - /*for _, item := range msgList { + /*for _, item := range msgList.Items { res = markdownParse("\n" + item.Msg) if res != "\n"+item.Expects { t.Error("Testing string '\n" + item.Msg + "'") @@ -294,7 +298,7 @@ func TestMarkdownRender(t *testing.T) { } } - for _, item := range msgList { + for _, item := range msgList.Items { res = markdownParse("\t" + item.Msg) if res != "\t"+item.Expects { t.Error("Testing string '\t" + item.Msg + "'") @@ -304,7 +308,7 @@ func TestMarkdownRender(t *testing.T) { } }*/ - for _, item := range msgList { + for _, item := range msgList.Items { res = markdownParse("d" + item.Msg) if res != "d"+item.Expects { t.Error("Testing string 'd" + item.Msg + "'")