From a7d89b842cfcb46806b013995dd437d4ae0a032b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 5 Jul 2024 17:25:23 +0200 Subject: [PATCH] Test utils.IsUnixAddr() --- utils/utils_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/utils_test.go b/utils/utils_test.go index 4c50caa1..2134338e 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -151,6 +151,26 @@ func TestMaxInt(t *testing.T) { } } +func TestIsUnixAddr(t *testing.T) { + subtests := []struct { + name string + input string + output bool + }{ + {"empty", "", false}, + {"slash", "/", true}, + {"unix", "/tmp/sock", true}, + {"ipv4", "192.0.2.1", false}, + {"ipv6", "2001:db8::", false}, + } + + for _, st := range subtests { + t.Run(st.name, func(t *testing.T) { + require.Equal(t, st.output, IsUnixAddr(st.input)) + }) + } +} + func TestChanFromSlice(t *testing.T) { t.Run("Nil", func(t *testing.T) { ch := ChanFromSlice[int](nil)