Skip to content

Commit

Permalink
Problem: no test for start and end of range
Browse files Browse the repository at this point in the history
  • Loading branch information
c-rack committed Nov 7, 2015
1 parent 21e970b commit 838716f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/cidr_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ defmodule CIDRTest do
assert "::1/256" |> CIDR.parse == {:error, "Invalid mask 256"}
end

test "Start and end of IPv4 address range" do
cidr = "127.0.0.1/24" |> CIDR.parse
assert cidr.start == {127, 0, 0, 0}
assert cidr.end == {127, 0, 0, 255}
end

test "Start and end of IPv6 address range" do
cidr = "::1/24" |> CIDR.parse
assert cidr.start == {0, 0, 0, 0, 0, 0, 0, 0}
assert cidr.end == {0, 255, 65535, 65535, 65535, 65535, 65535, 65535}
end

test "Parse of single IP should return exactly 1 host" do
cidr1 = CIDR.parse("127.0.0.1")
assert cidr1.hosts == 1
Expand Down

0 comments on commit 838716f

Please sign in to comment.