source: code/trunk/irc_test.go@ 805

Last change on this file since 805 was 804, checked in by koizumi.aoi, 2 years ago

Drunk as I like

Signed-off-by: Aoi K <koizumi.aoi@…>

File size: 963 bytes
RevLine 
[804]1package suika
[785]2
3import (
4 "testing"
5)
6
7func TestIsHighlight(t *testing.T) {
8 nick := "SojuUser"
9 testCases := []struct {
10 name string
11 text string
12 hl bool
13 }{
14 {"noContains", "hi there Soju User!", false},
15 {"middle", "hi there SojuUser!", true},
16 {"start", "SojuUser: how are you doing?", true},
17 {"end", "maybe ask SojuUser", true},
18 {"inWord", "but OtherSojuUserSan is a different nick", false},
19 {"startWord", "and OtherSojuUser is another different nick", false},
20 {"endWord", "and SojuUserSan is yet a different nick", false},
21 {"underscore", "and SojuUser_san has nothing to do with me", false},
22 {"zeroWidthSpace", "writing S\u200BojuUser shouldn't trigger a highlight", false},
23 }
24
25 for _, tc := range testCases {
26 tc := tc // capture range variable
27 t.Run(tc.name, func(t *testing.T) {
28 hl := isHighlight(tc.text, nick)
29 if hl != tc.hl {
30 t.Errorf("isHighlight(%q, %q) = %v, but want %v", tc.text, nick, hl, tc.hl)
31 }
32 })
33 }
34}
Note: See TracBrowser for help on using the repository browser.