diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2022-03-31 18:29:20 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2022-05-06 22:58:04 -0400 |
| commit | 254de4e4e97fe1550d7092bbf25a8a6c31f0fd74 (patch) | |
| tree | 43130543e5ddb045db63a8b90d689c44ceb17e6d /internal/tests/integration | |
| parent | 2f294d7884667800579e3ac3a16241e2df8698bb (diff) | |
Rename to CIDR*, generate docs
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'internal/tests/integration')
| -rw-r--r-- | internal/tests/integration/integration_test.go | 9 | ||||
| -rw-r--r-- | internal/tests/integration/net_test.go | 32 |
2 files changed, 25 insertions, 16 deletions
diff --git a/internal/tests/integration/integration_test.go b/internal/tests/integration/integration_test.go index 7b8b7694..b1fd3c63 100644 --- a/internal/tests/integration/integration_test.go +++ b/internal/tests/integration/integration_test.go @@ -33,6 +33,15 @@ func inOutTest(t *testing.T, i, o string) { assert.Equal(t, o, stdout) } +func inOutTestExperimental(t *testing.T, i, o string) { + t.Helper() + + stdout, stderr, err := cmd(t, "--experimental", "-i", i).run() + assert.NoError(t, err) + assert.Equal(t, "", stderr) + assert.Equal(t, o, stdout) +} + func inOutContains(t *testing.T, i, o string) { t.Helper() diff --git a/internal/tests/integration/net_test.go b/internal/tests/integration/net_test.go index ac2c8240..35218eaf 100644 --- a/internal/tests/integration/net_test.go +++ b/internal/tests/integration/net_test.go @@ -8,22 +8,22 @@ func TestNet_LookupIP(t *testing.T) { inOutTest(t, `{{ net.LookupIP "localhost" }}`, "127.0.0.1") } -func TestNet_CidrHost(t *testing.T) { - inOutTest(t, `{{ net.ParseIPPrefix "10.12.127.0/20" | net.CidrHost 16 }}`, "10.12.112.16") - inOutTest(t, `{{ "10.12.127.0/20" | net.CidrHost 16 }}`, "10.12.112.16") - inOutTest(t, `{{ net.CidrHost 268 "10.12.127.0/20" }}`, "10.12.113.12") - inOutTest(t, `{{ net.CidrHost 34 "fd00:fd12:3456:7890:00a2::/72" }}`, "fd00:fd12:3456:7890::22") +func TestNet_CIDRHost(t *testing.T) { + inOutTestExperimental(t, `{{ net.ParseIPPrefix "10.12.127.0/20" | net.CIDRHost 16 }}`, "10.12.112.16") + inOutTestExperimental(t, `{{ "10.12.127.0/20" | net.CIDRHost 16 }}`, "10.12.112.16") + inOutTestExperimental(t, `{{ net.CIDRHost 268 "10.12.127.0/20" }}`, "10.12.113.12") + inOutTestExperimental(t, `{{ net.CIDRHost 34 "fd00:fd12:3456:7890:00a2::/72" }}`, "fd00:fd12:3456:7890::22") } -func TestNet_CidrNetmask(t *testing.T) { - inOutTest(t, `{{ "10.12.127.0/20" | net.CidrNetmask }}`, "255.255.240.0") - inOutTest(t, `{{ net.CidrNetmask "10.0.0.0/12" }}`, "255.240.0.0") - inOutTest(t, `{{ net.CidrNetmask "fd00:fd12:3456:7890:00a2::/72" }}`, "ffff:ffff:ffff:ffff:ff00::") +func TestNet_CIDRNetmask(t *testing.T) { + inOutTestExperimental(t, `{{ "10.12.127.0/20" | net.CIDRNetmask }}`, "255.255.240.0") + inOutTestExperimental(t, `{{ net.CIDRNetmask "10.0.0.0/12" }}`, "255.240.0.0") + inOutTestExperimental(t, `{{ net.CIDRNetmask "fd00:fd12:3456:7890:00a2::/72" }}`, "ffff:ffff:ffff:ffff:ff00::") } -func TestNet_CidrSubnets(t *testing.T) { - inOutTest(t, `{{ index ("10.0.0.0/16" | net.CidrSubnets 2) 1 }}`, "10.0.64.0/18") - inOutTest(t, `{{ range net.CidrSubnets 2 "10.0.0.0/16" }} +func TestNet_CIDRSubnets(t *testing.T) { + inOutTestExperimental(t, `{{ index ("10.0.0.0/16" | net.CIDRSubnets 2) 1 }}`, "10.0.64.0/18") + inOutTestExperimental(t, `{{ range net.CIDRSubnets 2 "10.0.0.0/16" }} {{ . }}{{ end }}`, ` 10.0.0.0/18 10.0.64.0/18 @@ -31,10 +31,10 @@ func TestNet_CidrSubnets(t *testing.T) { 10.0.192.0/18`) } -func TestNet_CidrSubnetSizes(t *testing.T) { - inOutTest(t, `{{ index ("10.0.0.0/16" | net.CidrSubnetSizes 1) 0 }}`, "10.0.0.0/17") - inOutTest(t, `{{ index ("10.1.0.0/16" | net.CidrSubnetSizes 4 4 8 4) 1 }}`, "10.1.16.0/20") - inOutTest(t, `{{ range net.CidrSubnetSizes 16 16 16 32 "fd00:fd12:3456:7890::/56" }} +func TestNet_CIDRSubnetSizes(t *testing.T) { + inOutTestExperimental(t, `{{ index ("10.0.0.0/16" | net.CIDRSubnetSizes 1) 0 }}`, "10.0.0.0/17") + inOutTestExperimental(t, `{{ index ("10.1.0.0/16" | net.CIDRSubnetSizes 4 4 8 4) 1 }}`, "10.1.16.0/20") + inOutTestExperimental(t, `{{ range net.CIDRSubnetSizes 16 16 16 32 "fd00:fd12:3456:7890::/56" }} {{ . }}{{ end }}`, ` fd00:fd12:3456:7800::/72 fd00:fd12:3456:7800:100::/72 |
