diff options
author | Eric Wong <e@80x24.org> | 2016-11-12 02:13:42 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-01-01 03:30:41 +0000 |
commit | 76c10dada86fd807d36ccafca393e945e381696a (patch) | |
tree | 88227412057f87821a78e6f97c0ec864e9431ce5 /test | |
download | msgthr-76c10dada86fd807d36ccafca393e945e381696a.tar.gz |
Diffstat (limited to 'test')
-rw-r--r-- | test/test_msgthr.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_msgthr.rb b/test/test_msgthr.rb new file mode 100644 index 0000000..2e398c1 --- /dev/null +++ b/test/test_msgthr.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2016 all contributors <msgthr-public@80x24.org> +# License: GPL-2.0+ <https://www.gnu.org/licenses/gpl-2.0.txt> +require 'test/unit' +require 'msgthr' + +class TestMsgthr < Test::Unit::TestCase + def test_msgthr + thr = Msgthr.new + thr.add('a', %w(c b), 'abc') + thr.add('b', %w(c), 'B') + thr.add('c', nil, 'c') + thr.add('D', nil, 'D') + thr.add('d', nil, 'd') + thr.thread! + rootset = thr.order! { |c| c.sort! { |a, b| a.mid <=> b.mid } } + assert_equal %w(D c d), rootset.map(&:mid) + assert_equal 'D', rootset[0].msg + assert_equal %w(b), rootset[1].children.map(&:mid) + end +end |