about summary refs log tree commit homepage
path: root/test/test_msgthr.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-08 23:37:05 +0000
committerEric Wong <e@80x24.org>2017-06-08 23:38:24 +0000
commit1b633959b1153b40ff8fcddd8430e0c6b0e9574b (patch)
treeed372d868c1df615504ecacf53bf908e190fe899 /test/test_msgthr.rb
parentb52e67f318794d2c4dde267ad4a540a62ae55b2e (diff)
downloadmsgthr-1b633959b1153b40ff8fcddd8430e0c6b0e9574b.tar.gz
Oh, so that's why I hadn't released this project earlier...
Diffstat (limited to 'test/test_msgthr.rb')
-rw-r--r--test/test_msgthr.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test_msgthr.rb b/test/test_msgthr.rb
index 19441c8..19cec75 100644
--- a/test/test_msgthr.rb
+++ b/test/test_msgthr.rb
@@ -10,11 +10,27 @@ class TestMsgthr < Test::Unit::TestCase
     thr.add('b', %w(c), 'B')
     thr.add('c', nil, 'c')
     thr.add('D', nil, 'D')
-    thr.add('d', nil, 'd')
+    thr.add('d', %w(missing), 'd')
     thr.thread!
     rootset = thr.order! { |c| c.sort_by!(&:mid) }
-    assert_equal %w(D c d), rootset.map(&:mid)
+    assert_equal %w(D c missing), rootset.map(&:mid)
     assert_equal 'D', rootset[0].msg
     assert_equal %w(b), rootset[1].children.map(&:mid)
+    out = ''.b
+    thr.walk_thread do |level, container, index|
+      msg = container.msg
+      summary = msg ? msg : "[missing: <#{container.mid}>]"
+      indent = '  ' * level
+      out << sprintf("#{indent} % 3d. %s\n", index, summary)
+    end
+    exp = <<EOF.b
+   0. D
+   1. c
+     0. B
+       0. abc
+   2. [missing: <missing>]
+     0. d
+EOF
+    assert_equal exp, out
   end
 end