mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
more work on websocket support
This commit is contained in:
parent
25813f6d3a
commit
3dc5c8de78
17 changed files with 830 additions and 444 deletions
37
irc/utils/glob_test.go
Normal file
37
irc/utils/glob_test.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2020 Shivaram Lingamneni <slingamn@cs.stanford.edu>
|
||||
// released under the MIT license
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func globMustCompile(glob string) *regexp.Regexp {
|
||||
re, err := CompileGlob(glob)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return re
|
||||
}
|
||||
|
||||
func assertMatches(glob, str string, match bool, t *testing.T) {
|
||||
re := globMustCompile(glob)
|
||||
if re.MatchString(str) != match {
|
||||
t.Errorf("should %s match %s? %t, but got %t instead", glob, str, match, !match)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGlob(t *testing.T) {
|
||||
assertMatches("https://testnet.oragono.io", "https://testnet.oragono.io", true, t)
|
||||
assertMatches("https://*.oragono.io", "https://testnet.oragono.io", true, t)
|
||||
assertMatches("*://*.oragono.io", "https://testnet.oragono.io", true, t)
|
||||
assertMatches("*://*.oragono.io", "https://oragono.io", false, t)
|
||||
assertMatches("*://*.oragono.io", "https://githubusercontent.com", false, t)
|
||||
|
||||
assertMatches("", "", true, t)
|
||||
assertMatches("", "x", false, t)
|
||||
assertMatches("*", "", true, t)
|
||||
assertMatches("*", "x", true, t)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue