rpatricia.git  about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
blob 580a1f9b3b6a0314636ec378362637020de13fce 772 bytes (raw)
$ git show HEAD:test/test_nodes.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
26
27
28
29
 
require 'test/unit'
require 'rpatricia'

class TestShowNodes < Test::Unit::TestCase

  def test_nodes
    t = Patricia.new
    string = "pref_10"
    array = [:something]
    t.add("127.0.0.0/24")
    t.add("192.168.1.0/24")
    t.add("192.168.2.0/24")
    t.add("192.168.3.100")
    t.add("10.0.0.0/8", string)
    t.add("10.0.0.0/9", array)

    assert_equal({"10.0.0.0/8" => "pref_10",
                  "10.0.0.0/9" => [:something],
                  "127.0.0.0/24" => "",
                  "192.168.1.0/24" => "",
                  "192.168.2.0/24" => "",
                  "192.168.3.100/32" => ""},
                  t.nodes)

    assert(string.object_id != t.nodes["10.0.0.0/8"].object_id)
    assert(array.object_id == t.nodes["10.0.0.0/9"].object_id)
  end

end

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