rpatricia.git  about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
blob f16ab65cc1627286be9bba8221df7aebba7d4b4e 679 bytes (raw)
$ git show for-tatsuya:test/test_ipv6.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
require 'test/unit'
require 'rpatricia'

class TestIPv6 < Test::Unit::TestCase
  def test_ipv6
    t = Patricia.new :AF_INET6
    assert_equal :AF_INET6, t.family
    node = t.add('1234:567::/35', 'hello world')
    assert_kind_of Patricia::Node, node
    assert_equal 'hello world', node.data
    assert_equal 'hello world', t.match_best('1234:567::/128').data
  end

  def test_ipv4_mapped_ipv6
    t = Patricia.new :AF_INET6
    assert_equal :AF_INET6, t.family
    node = t.add('::ffff:10.0.0.0/8', 'hello world')
    assert_kind_of Patricia::Node, node
    assert_equal 'hello world', node.data
    assert_equal 'hello world', t.match_best('::ffff:10.0.0.1').data
  end
end

git clone https://yhbt.net/rpatricia.git