-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to link to original post in ALLPOST
- Loading branch information
1 parent
7b58b33
commit b58c37f
Showing
4 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pttbbs | ||
|
||
import "testing" | ||
|
||
func TestBrdNameFromAllPostTitle(t *testing.T) { | ||
for _, test := range []struct { | ||
desc string | ||
title string | ||
want string | ||
}{ | ||
{ | ||
desc: "normal title with board name", | ||
title: "測試 (Test)", | ||
want: "Test", | ||
}, | ||
{ | ||
desc: "empty title with board name", | ||
title: "(SYSOP)", | ||
want: "SYSOP", | ||
}, | ||
{ | ||
desc: "normal title but bad board name", | ||
title: "測試 (SYS%%) ", | ||
}, | ||
{ | ||
desc: "bad title", | ||
title: "(Bad) ", | ||
}, | ||
{ | ||
desc: "empty title", | ||
title: "", | ||
}, | ||
} { | ||
t.Run(test.desc, func(t *testing.T) { | ||
wantOk := test.want != "" | ||
|
||
got, gotOk := BrdNameFromAllPostTitle(test.title) | ||
if got != test.want || gotOk != wantOk { | ||
t.Errorf("BrdNameFromAllPostTitle(%q) = (%q, %t); want (%q, %t)", | ||
test.title, got, gotOk, test.want, wantOk) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters