rpatricia.git  about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
blob 303ad46cf4700e1ef9d85eb6d99e22063cf2b37b 566 bytes (raw)
$ git show ipv6:test/test_include.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
23
24
25
 
require 'test/unit'
require 'rpatricia'

class TestInclude < Test::Unit::TestCase

  def setup
    @t = Patricia.new
  end

  def test_include_exact
    @t.add '127.0.0.1'
    assert_equal true, @t.include?('127.0.0.1')
    assert_equal false, @t.include?('127.0.0.2')
    @t.clear
    assert_equal false, @t.include?('127.0.0.1')
  end

  def test_include_match_prefix
    @t.add '127.0.0.0/8'
    assert_equal true, @t.include?('127.0.0.32')
    assert_equal false, @t.include?('12.0.0.32')
    @t.clear
    assert_equal false, @t.include?('127.0.0.32')
  end
end

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