about summary refs log tree commit
path: root/test/test_show_nodes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_show_nodes.rb')
-rw-r--r--test/test_show_nodes.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_show_nodes.rb b/test/test_show_nodes.rb
new file mode 100644
index 0000000..b4aa3a0
--- /dev/null
+++ b/test/test_show_nodes.rb
@@ -0,0 +1,32 @@
+require 'test/unit'
+require 'rpatricia'
+require 'stringio'
+
+class TestShowNodes < Test::Unit::TestCase
+
+  def test_show_nodes
+    t = Patricia.new
+    assert_nothing_raised do
+      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", "pref_10")
+    end
+    begin
+      oldout = $stdout
+      $stdout = tmpout = StringIO.new
+      assert_nothing_raised { t.show_nodes }
+    ensure
+      $stdout = oldout
+    end
+    expect = [
+      "node: 10.0.0.0/8",
+      "node: 127.0.0.0/24",
+      "node: 192.168.1.0/24",
+      "node: 192.168.2.0/24",
+      "node: 192.168.3.100/32"
+    ].join("\n") << "\n"
+    assert_equal expect, tmpout.string
+  end
+end