rpatricia.git  about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
blob 32b700314d0539df6657237aa57705be99a8403b 745 bytes (raw)
$ git show for-tatsuya:test/test_invalid_inputs.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
30
31
 
require 'test/unit'
require 'rpatricia'

class TestInvalidInput < Test::Unit::TestCase

  def setup
    @t = Patricia.new
  end

  def test_embedded_null
    assert_raises(ArgumentError) { @t.add("100.0.0.0/8\0") }
  end

  def test_invalid_add
    assert_raises(ArgumentError) { @t.add('1000.0.0.0/8') }
    assert_raises(ArgumentError) { @t.add("\0") }
    assert_raises(ArgumentError) { @t.add("\0\0\0\0\0\0" * 1024 * 1024) }
  end

  def test_invalid_remove
    assert_raises(ArgumentError) { @t.remove('1000.0.0.0/8') }
  end

  def test_invalid_match_best
    assert_raises(ArgumentError) { @t.match_best('1000.0.0.0/8') }
  end

  def test_invalid_match_exact
    assert_raises(ArgumentError) { @t.match_exact('1000.0.0.0/8') }
  end
end

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