Sha256: dbada906c0573a3e20b87c8e476a02b3783e59d49262a41d8d35d3f4247ebf19
Contents?: true
Size: 1.1 KB
Versions: 23
Compression:
Stored size: 1.1 KB
Contents
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'test_helper' include RecursionLab class TestRecursiveAlgoritms < Test::Unit::TestCase def test_00_banner print "\nRecursionLab" end # Make some test arrays, try successful and unsuccessful searches. # Test array sizes students will use (one less than power of two) # plus some odd ones. def test_01_bsearch [14, 15, 16].each do |size| a = TestArray.new(size).sort assert_not_nil bsearch(a, a.random(:success)) assert_nil bsearch(a, a.random(:fail)) end end # Students will run tests with array sizes that are a power of two, # but run some tests on other sizes, too. Also checks to make sure # the array is not modified def test_02_msort [15, 16, 17].each do |size| a = TestArray.new(size) b = a.dup assert_equal msort(a), a.sort assert_equal a, b end end # Array size not a factor here -- just try a few sorts def test_03_qsort [15, 16, 17].each do |size| a = TestArray.new(size) b = a.dup assert_equal qsort(a), a.sort assert_equal a, b end end end
Version data entries
23 entries across 23 versions & 1 rubygems