mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-11-25 20:59:36 +01:00
test ContainsIP utility
This commit is contained in:
parent
bc5060b218
commit
1672322fc1
1 changed files with 10 additions and 1 deletions
|
@ -1,10 +1,12 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/require"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRandomString(t *testing.T) {
|
func TestRandomString(t *testing.T) {
|
||||||
|
@ -42,6 +44,13 @@ func TestContains(t *testing.T) {
|
||||||
require.False(t, Contains(s, 3))
|
require.False(t, Contains(s, 3))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContainsIP(t *testing.T) {
|
||||||
|
require.True(t, ContainsIP([]netip.Prefix{netip.MustParsePrefix("fd00::/8"), netip.MustParsePrefix("1.1.0.0/16")}, netip.MustParseAddr("1.1.1.1")))
|
||||||
|
require.True(t, ContainsIP([]netip.Prefix{netip.MustParsePrefix("fd00::/8"), netip.MustParsePrefix("1.1.0.0/16")}, netip.MustParseAddr("fd12:1234:5678::9876")))
|
||||||
|
require.False(t, ContainsIP([]netip.Prefix{netip.MustParsePrefix("fd00::/8"), netip.MustParsePrefix("1.1.0.0/16")}, netip.MustParseAddr("1.2.0.1")))
|
||||||
|
require.False(t, ContainsIP([]netip.Prefix{netip.MustParsePrefix("fd00::/8"), netip.MustParsePrefix("1.1.0.0/16")}, netip.MustParseAddr("fc00::1")))
|
||||||
|
}
|
||||||
|
|
||||||
func TestSplitNoEmpty(t *testing.T) {
|
func TestSplitNoEmpty(t *testing.T) {
|
||||||
require.Equal(t, []string{}, SplitNoEmpty("", ","))
|
require.Equal(t, []string{}, SplitNoEmpty("", ","))
|
||||||
require.Equal(t, []string{}, SplitNoEmpty(",,,", ","))
|
require.Equal(t, []string{}, SplitNoEmpty(",,,", ","))
|
||||||
|
|
Loading…
Reference in a new issue