From 1b633959b1153b40ff8fcddd8430e0c6b0e9574b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 8 Jun 2017 23:37:05 +0000 Subject: improve API documentation and testing Oh, so that's why I hadn't released this project earlier... --- test/test_msgthr.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test/test_msgthr.rb') 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 = <] + 0. d +EOF + assert_equal exp, out end end -- cgit v1.2.3-24-ge0c7