Sha256: df769f0d67f0665114d979092e01368eb3b757de910b23dd5e6b76b4e53a078a

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

require 'spec_helper'
require 'ronin/extensions/regexp'

describe Regexp do
  describe Regexp::IPv4 do
    subject { Regexp::IPv4 }

    it "should match valid addresses" do
      ip = '127.0.0.1'

      subject.match(ip)[0].should == ip
    end

    it "should match the Any address" do
      ip = '0.0.0.0'

      subject.match(ip)[0].should == ip
    end

    it "should match the broadcast address" do
      ip = '255.255.255.255'

      subject.match(ip)[0].should == ip
    end

    it "should not match addresses with octets > 255" do
      ip = '10.1.256.1'

      subject.match(ip).should be_nil
    end

    it "should not match addresses with more than three digits per octet" do
      ip = '10.1111.1.1'

      subject.match(ip).should be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-support-0.4.0.rc2 spec/extensions/regexp_spec.rb
ronin-support-0.4.0.rc1 spec/extensions/regexp_spec.rb