summaryrefslogtreecommitdiffstats
path: root/model/utils_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-06-01 16:05:36 -0400
committerCorey Hulen <corey@hulen.com>2016-06-01 13:05:36 -0700
commit2ea54b9d1e382db8eeb4254dc637e7d04316d01e (patch)
tree7ddf3586979f6582e578d933b6c7820776f5b8e3 /model/utils_test.go
parent3ce6dfc71eb8f1bf2e9f2d860cf086424cf1c46d (diff)
downloadchat-2ea54b9d1e382db8eeb4254dc637e7d04316d01e.tar.gz
chat-2ea54b9d1e382db8eeb4254dc637e7d04316d01e.tar.bz2
chat-2ea54b9d1e382db8eeb4254dc637e7d04316d01e.zip
PLT-2283 Improved trimming of punctuation from hashtags and search terms (#3178)
* Improved trimming of punctuation from hashtags and search terms * Separated punctuation regexes used for hashtags and for search terms
Diffstat (limited to 'model/utils_test.go')
-rw-r--r--model/utils_test.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/model/utils_test.go b/model/utils_test.go
index 02a08d113..5d9289a9a 100644
--- a/model/utils_test.go
+++ b/model/utils_test.go
@@ -82,7 +82,7 @@ func TestEtag(t *testing.T) {
}
}
-var hashtags map[string]string = map[string]string{
+var hashtags = map[string]string{
"#test": "#test",
"test": "",
"#test123": "#test123",
@@ -101,6 +101,7 @@ var hashtags map[string]string = map[string]string{
"<#less_than<": "#less_than",
">#greater_than>": "#greater_than",
"-#minus-": "#minus",
+ "_#under_": "#under",
"+#plus+": "#plus",
"=#equals=": "#equals",
"%#pct%": "#pct",
@@ -111,12 +112,21 @@ var hashtags map[string]string = map[string]string{
"|#pipe|": "#pipe",
":#colon:": "#colon",
";#semi;": "#semi",
+ "#Mötley;": "#Mötley",
+ ".#period.": "#period",
+ "¿#upside¿": "#upside",
+ "\"#quote\"": "#quote",
+ "/#slash/": "#slash",
+ "\\#backslash\\": "#backslash",
+ "#a": "",
+ "#1": "",
+ "foo#bar": "",
}
func TestParseHashtags(t *testing.T) {
for input, output := range hashtags {
if o, _ := ParseHashtags(input); o != output {
- t.Fatal("expected=" + output + " actual=" + o)
+ t.Fatal("failed to parse hashtags from input=" + input + " expected=" + output + " actual=" + o)
}
}
}