From 76c10dada86fd807d36ccafca393e945e381696a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 12 Nov 2016 02:13:42 +0000 Subject: initial --- test/test_msgthr.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/test_msgthr.rb (limited to 'test/test_msgthr.rb') 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 +# License: GPL-2.0+ +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 -- cgit v1.2.3-24-ge0c7