diff options
Diffstat (limited to 'test/test_invalid_inputs.rb')
-rw-r--r-- | test/test_invalid_inputs.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/test_invalid_inputs.rb b/test/test_invalid_inputs.rb new file mode 100644 index 0000000..93e7a96 --- /dev/null +++ b/test/test_invalid_inputs.rb @@ -0,0 +1,27 @@ +require 'test/unit' +require 'rpatricia' + +class TestInvalidInput < Test::Unit::TestCase + + def setup + @t = Patricia.new + 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 |