Sha256: 8b57e4e7d1f33b05082ff7b9a877d006ad8c0bb21406dd918386b778d00129e6

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# -*- coding: utf-8 -*-
require "sixarm_ruby_ramp_test"

class EnumerableSelectTest < Minitest::Test

  ITEMS = ['a','b','c']

  def test_select_while
    assert_equal([           ], ITEMS.select_while{|x| x < 'a' },'< a')
    assert_equal(['a'        ], ITEMS.select_while{|x| x < 'b' },'< b')
    assert_equal(['a','b'    ], ITEMS.select_while{|x| x < 'c' },'< c')
    assert_equal(['a','b','c'], ITEMS.select_while{|x| x < 'd' },'< d')
    assert_equal(['a','b','c'], ITEMS.select_while{|x| x < 'e' },'< e')
  end

  def test_select_until_condition
    assert_equal([           ], ITEMS.select_until{|x| x == 'a' },'a')
    assert_equal(['a'        ], ITEMS.select_until{|x| x == 'b' },'b')
    assert_equal(['a','b'    ], ITEMS.select_until{|x| x == 'c' },'c')
    assert_equal(['a','b','c'], ITEMS.select_until{|x| x == 'd' },'d')
    assert_equal(['a','b','c'], ITEMS.select_until{|x| x == 'e' },'e')
  end

  def test_select_with_index
    assert_equal([           ], ITEMS.select_with_index{|x,i| i < 0 },'i < 0')
    assert_equal(['a'        ], ITEMS.select_with_index{|x,i| i < 1 },'i < 1')
    assert_equal(['a','b'    ], ITEMS.select_with_index{|x,i| i < 2 },'i < 2')
    assert_equal(['a','b','c'], ITEMS.select_with_index{|x,i| i < 3 },'i < 3')
    assert_equal(['a','b','c'], ITEMS.select_with_index{|x,i| i < 4 },'i < 4')
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sixarm_ruby_ramp-5.0.2 test/sixarm_ruby_ramp_test/enumerable/select_test.rb
sixarm_ruby_ramp-5.0.1 test/sixarm_ruby_ramp_test/enumerable/select_test.rb
sixarm_ruby_ramp-5.0.0 test/sixarm_ruby_ramp_test/enumerable/select_test.rb
sixarm_ruby_ramp-4.2.7 test/sixarm_ruby_ramp_test/enumerable/select_test.rb
sixarm_ruby_ramp-4.2.5 test/sixarm_ruby_ramp_test/enumerable/select_test.rb