Sha256: cb96e46d8cae85f1891000070bb40134114dd45eb888e89a01fc23f4bc00cc8d
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
# Spec helper (must include first to track code coverage with SimpleCov) require File.expand_path('../support/spec_helper', __FILE__) require "acpc_poker_types/seat" include AcpcPokerTypes describe Seat do describe '#position_relative_to' do it 'works for basic examples' do Seat.new(1).position_relative_to(Seat.new(0), 3).must_equal 0 Seat.new(1).position_relative_to(Seat.new(1), 3).must_equal 2 end it 'works for more cases' do (0..10).each do |patient| (0..10).each do |target| (1..10).each do |num_players| next if patient >= num_players || target >= num_players Seat.new(patient).position_relative_to(Seat.new(target), num_players) .must_equal( ( if patient > target patient else patient + num_players end ) - (target + 1) ) end end end end end describe '#seat_from_relative_position' do it 'works for basic examples' do Seat.new(1).seat_from_relative_position(Seat.new(0), 3).must_equal 0 Seat.new(1).seat_from_relative_position(Seat.new(2), 3).must_equal 1 end it 'works for more cases' do (0..10).each do |patient| (0..10).each do |rel_position| (1..10).each do |num_players| next if patient >= num_players || rel_position >= num_players position_adjustment = rel_position + 1 to_seat = Seat.new(patient + num_players - position_adjustment) x_seat = if patient > to_seat || !to_seat.seat_in_bounds?(num_players) patient - position_adjustment else to_seat end Seat.new(patient).seat_from_relative_position( Seat.new(rel_position), num_players ).must_equal(x_seat) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acpc_poker_types-3.3.1 | spec/seat_spec.rb |