tres: Add address helpers
This commit is contained in:
parent
f7a21ae9b1
commit
d0683cf721
5 changed files with 267 additions and 0 deletions
17
test/ipv4_address_test.exs
Normal file
17
test/ipv4_address_test.exs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
defmodule IPv4AddressTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
describe "IPv4Address.parse/1" do
|
||||
test "with host(/32) address string" do
|
||||
expect = {{192, 168, 10, 1}, {255, 255, 255, 255}}
|
||||
ipaddr = "192.168.10.1"
|
||||
assert Tres.IPv4Address.parse(ipaddr) == expect
|
||||
end
|
||||
|
||||
test "with network(/24) address string" do
|
||||
expect = {{192, 168, 10, 0}, {255, 255, 255, 0}}
|
||||
ipaddr = "192.168.10.0/24"
|
||||
assert Tres.IPv4Address.parse(ipaddr) == expect
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue