3 # Copyright (C) 2011 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
23 # This software is part of the Biopieces framework (www.biopieces.org).
25 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
28 require 'maasha/cigar'
31 class CigarTest < Test::Unit::TestCase
32 def test_Cigar_new_with_bad_cigar_raises
33 assert_raise(CigarError) { Cigar.new("@") }
34 assert_raise(CigarError) { Cigar.new("1M1H1M") }
35 assert_raise(CigarError) { Cigar.new("1M1S1M") }
38 def test_Cigar_new_with_ok_cigar_dont_raise
39 assert_nothing_raised { Cigar.new("1M") }
40 assert_nothing_raised { Cigar.new("1H1M1H") }
41 assert_nothing_raised { Cigar.new("1S1M1S") }
42 assert_nothing_raised { Cigar.new("1H1S1M1S1H") }
45 def test_Cigar_to_s_returns_correctly
46 assert_equal("1M", Cigar.new("1M").to_s)
49 def test_Cigar_each_returns_correctly
50 cigar = Cigar.new("10M")
52 cigar.each { |len, op|
58 def test_Cigar_length_returns_correctly
59 assert_equal(6, Cigar.new("1M2S3H").length)
62 def test_Cigar_matches_returns_correctly
63 assert_equal(1, Cigar.new("1M2S3H").matches)
66 def test_Cigar_insertions_returns_correctly
67 assert_equal(1, Cigar.new("10M1I").insertions)
70 def test_Cigar_deletions_returns_correctly
71 assert_equal(2, Cigar.new("10M2D").deletions)
74 def test_Cigar_clip_hard_returns_correctly
75 assert_equal(3, Cigar.new("10M3H").clip_hard)
78 def test_Cigar_clip_soft_returns_correctly
79 assert_equal(4, Cigar.new("10M4S").clip_soft)