Sha256: ee5970978bb8b2121e4dbc4f0dfc9115669a35a2c7229ab221991faa6815666d

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "minitest/autorun"
require "minitest/unit"
require_relative "../lib/clusterfuck"

class TestSubnet < Minitest::Unit::TestCase
  include Clusterfuck

  def setup
    SubnetFactory.reset
  end

  def test_next_subnet
    subnet = SubnetFactory.next
    assert_equal IPAddr.new("10.0.40.2"), subnet.next
  end

  def test_next_ip_on_subnet
    subnet = SubnetFactory.next
    assert_equal IPAddr.new("10.0.40.2"), subnet.next
    assert_equal IPAddr.new("10.0.40.3"), subnet.next
  end

  def test_next_subnet_twice
    subnet = SubnetFactory.next
    assert_equal IPAddr.new("10.0.40.2"), subnet.next

    subnet = SubnetFactory.next
    assert_equal IPAddr.new("10.0.41.2"), subnet.next
  end

  def test_next_16_subnet
    subnet = SubnetFactory.next(16)
    assert_equal IPAddr.new("10.1.0.2"), subnet.next
  end

  def test_mask_returns_classic_syntax_netmask
    subnet = SubnetFactory.next
    assert_equal "255.255.255.0", subnet.next.netmask
  end

  def test_cidr_on_subet
    assert_equal 24, IPAddr.new("10.0.0.0/24").cidr
  end

  def test_to_cidr_on_subet
    assert_equal "10.0.0.0/24", IPAddr.new("10.0.0.0/24").to_cidr
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-clusterfuck-0.0.1 test/subnet_test.rb