Sha256: 8d6ab6a8a82338f91cec568522a8d430053d2e5f6ea309502e4ed14d690a5704

Contents?: true

Size: 934 Bytes

Versions: 78

Compression:

Stored size: 934 Bytes

Contents

require File.expand_path('../../helper', __FILE__)
require 'citrus/grammars'

Citrus.require 'ipv4address'

class IPv4AddressTest < Test::Unit::TestCase
  def test_dec_octet
    match = IPv4Address.parse('0', :root => :'dec-octet')
    assert(match)

    match = IPv4Address.parse('255', :root => :'dec-octet')
    assert(match)
  end

  def test_1
    match = IPv4Address.parse('0.0.0.0')
    assert(match)
    assert_equal(4, match.version)
  end

  def test_2
    match = IPv4Address.parse('255.255.255.255')
    assert(match)
    assert_equal(4, match.version)
  end

  def test_invalid
    assert_raise Citrus::ParseError do
      IPv4Address.parse('255.255.255.256')
    end
  end

  def test_invalid_short
    assert_raise Citrus::ParseError do
      IPv4Address.parse('255.255.255')
    end
  end

  def test_invalid_long
    assert_raise Citrus::ParseError do
      IPv4Address.parse('255.255.255.255.255')
    end
  end
end

Version data entries

78 entries across 78 versions & 2 rubygems

Version Path
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/grammars/ipv4address_test.rb