Sha256: 2c4acdd808e97a082fc14385ba0aaa560628dac20d1ed058865a3eaa141df163
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require 'test/unit' require 'sbn/combination' class TestCombination < Test::Unit::TestCase # :nodoc: def setup @c = Sbn::Combination.new([[1, 2], [3, 4, 5]]) end def test_current test_first test_last end def test_each @c.first combinations = [[1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5]] index = 0 @c.each do |comb| assert_equal combinations[index], comb index += 1 end end def test_first @c.first assert_equal @c.current, [1, 3] end def test_last @c.last assert_equal @c.current, [2, 5] end def test_next_combination @c.first assert_equal @c.next_combination, [1, 4] assert_equal @c.next_combination, [1, 5] assert_equal @c.next_combination, [2, 3] assert_equal @c.next_combination, [2, 4] assert_equal @c.next_combination, [2, 5] end def test_prev_combination @c.last assert_equal @c.prev_combination, [2, 4] assert_equal @c.prev_combination, [2, 3] assert_equal @c.prev_combination, [1, 5] assert_equal @c.prev_combination, [1, 4] assert_equal @c.prev_combination, [1, 3] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sbn-0.9.1 | test/test_combination.rb |