From cc97561a19e8ca81950d4745bd0755a8711248a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Gul=C3=A1csi?= Date: Thu, 18 Aug 2022 08:38:04 +0200 Subject: [PATCH] Add test for isBogusDataIP --- ftp_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ftp_test.go diff --git a/ftp_test.go b/ftp_test.go new file mode 100644 index 0000000..c1ca5ad --- /dev/null +++ b/ftp_test.go @@ -0,0 +1,22 @@ +package ftp + +import ( + "net" + "testing" +) + +func TestBogusDataIP(t *testing.T) { + for _, tC := range []struct { + cmd, data net.IP + bogus bool + }{ + {net.IPv4(192, 168, 1, 1), net.IPv4(192, 168, 1, 1), false}, + {net.IPv4(192, 168, 1, 1), net.IPv4(1, 1, 1, 1), true}, + {net.IPv4(10, 65, 1, 1), net.IPv4(1, 1, 1, 1), true}, + {net.IPv4(10, 65, 25, 1), net.IPv4(10, 65, 8, 1), false}, + } { + if got, want := isBogusDataIP(tC.cmd, tC.data), tC.bogus; got != want { + t.Errorf("%s,%s got %t, wanted %t", tC.cmd, tC.data, got, want) + } + } +}