diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_gc.rb | 4 | ||||
-rw-r--r-- | test/test_old_segfaults.rb | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/test/test_gc.rb b/test/test_gc.rb index d567696..5829deb 100644 --- a/test/test_gc.rb +++ b/test/test_gc.rb @@ -17,7 +17,7 @@ class TestGc < Test::Unit::TestCase def test_gc assert_nothing_raised do - 10_000_000.times do + 5_000_000.times do t = Patricia.new t.add('10.0.0.0/8', {}) t.add('127.0.0.0/24', "home sweet home") @@ -25,7 +25,7 @@ class TestGc < Test::Unit::TestCase end # ensure what we created originally didn't get GC-ed' - 100.times do + 5_000_000.times do assert_equal [], @arrays.match_best('127.0.0.1').data assert_equal "localhost", @strings.match_best('127.0.0.1').data end diff --git a/test/test_old_segfaults.rb b/test/test_old_segfaults.rb new file mode 100644 index 0000000..0814150 --- /dev/null +++ b/test/test_old_segfaults.rb @@ -0,0 +1,21 @@ +require 'test/unit' +require 'rpatricia' + +# things that used to segfault before the introduction of +# Patricia::Node will now raise NoMethodError +class TestOldSegfaults < Test::Unit::TestCase + + def test_used_to_segfault + assert_raises(NoMethodError) { Patricia.new.data } + end + + def test_node_method + t = Patricia.new + t.add('10.0.0.0/8', 'big_lan') + if matched = t.match_best('10.1.2.3') + assert_kind_of Patricia::Node, matched + assert_equal 'big_lan', matched.data + assert_raises(NoMethodError) { matched.destroy } + end + end +end |