Sha256: 242447e2ebee8d0357d2c9fe50dfc4532d98fa3f33204d210addf9786834223c

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

#!/usr/bin/env ruby
require 'test/unit'
require 'util'

class TestArray < Test::Unit::TestCase
	def test_peel_all_arrays_same_length
		tuples = []
		a1 = [1,3,5]
		a2 = [2,4,6]
		a3 = [1,4,9]
		[a1, a2, a3].peel { |x,y,z| tuples << [x,y,z] }
		assert_equal([[1,2,1],[3,4,4],[5,6,9]], tuples)
	end

	def test_peel_one_array_shorter
		tuples = []
		a1 = [1,3,5]
		a2 = [2,4]
		a3 = [1,4,9]
		[a1, a2, a3].peel { |x,y,z| tuples << [x,y,z] }
		assert_equal([[1,2,1],[3,4,4]], tuples)
	end

	def test_collect_peel
		a1 = [1,3,5]
		a2 = [2,4,6]
		assert_equal([3,7,11], [a1, a2].collect_peel { |a,b| a+b })
	end
end

class TestFixnum < Test::Unit::TestCase
	def test_offset_mod
		assert_equal(1, 27.offset_mod(26), "27 wrong")
		assert_equal(26, 26.offset_mod(26), "26 wrong")
		assert_equal(26, 0.offset_mod(26), "0 wrong")
		assert_equal(25, -1.offset_mod(26), "-1 wrong")
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyzip-0.9.1 lib/quiz1/t/solutions/Moses Hohman/test_util.rb