Sha256: c8db07ae8eae83b865a5a79a85f9d12ce6551b846225c39f926eba6b3225f082

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require 'test_helper'

class HandTest < Hands::TestCase
  def test_ordering_hands
    pair = Hands::Hand.new
    pair << Hands::Card[2, :hearts]
    pair << Hands::Card[2, :clubs]

    flush = Hands::Hand.new
    flush << Hands::Card[6, :hearts]
    flush << Hands::Card[7, :hearts]
    flush << Hands::Card[8, :hearts]
    flush << Hands::Card[2, :hearts]
    flush << Hands::Card[4, :hearts]
    assert flush > pair
  end

  def test_order_same_hand
    small_pair = Hands::Hand.new
    small_pair << Hands::Card[2, :hearts]
    small_pair << Hands::Card[2, :clubs]

    large_pair = Hands::Hand.new
    large_pair << Hands::Card['A', :hearts]
    large_pair << Hands::Card['A', :clubs]
    assert large_pair > small_pair

    small_kicker = Hands::Hand.new
    small_kicker << Hands::Card['A', :spades]
    small_kicker << Hands::Card['A', :diamonds]
    small_kicker << Hands::Card[2, :diamonds]
    small_kicker << Hands::Card[3, :diamonds]
    small_kicker << Hands::Card[4, :diamonds]

    big_kicker = Hands::Hand.new
    big_kicker << Hands::Card['A', :hearts]
    big_kicker << Hands::Card['A', :clubs]
    big_kicker << Hands::Card[10, :diamonds]
    big_kicker << Hands::Card[9, :diamonds]
    big_kicker << Hands::Card[7, :diamonds]
    assert big_kicker > small_kicker
  end

  def test_collecting_suits
    hand = Hands::Hand.new
    hand << Hands::Card[2, :hearts]
    hand << Hands::Card[2, :clubs]
    assert_equal [:hearts, :clubs], hand.suits

    hand << Hands::Card[3, :clubs]
    assert_equal [:hearts, :clubs], hand.suits
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hands-0.3.0 test/units/hand_test.rb
hands-0.2.1 test/units/hand_test.rb
hands-0.2.0 test/units/hand_test.rb
hands-0.1.0 test/units/hand_test.rb