mirror of
https://github.com/onyx-and-iris/aoc2023.git
synced 2024-11-15 23:20:49 +00:00
101 lines
1.8 KiB
Go
101 lines
1.8 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGetMatches(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("32T3K", 0)
|
||
|
h2 := newHand("ABC3D", 0)
|
||
|
|
||
|
res1 := map[rune]int{
|
||
|
'3': 2,
|
||
|
'2': 1,
|
||
|
'T': 1,
|
||
|
'K': 1,
|
||
|
}
|
||
|
res2 := map[rune]int{
|
||
|
'A': 1,
|
||
|
'B': 1,
|
||
|
'C': 1,
|
||
|
'3': 1,
|
||
|
'D': 1,
|
||
|
}
|
||
|
|
||
|
t.Run("Should produce equal maps", func(t *testing.T) {
|
||
|
assert.Equal(t, res1, h1.getMatches())
|
||
|
})
|
||
|
|
||
|
t.Run("Should produce equal maps", func(t *testing.T) {
|
||
|
assert.Equal(t, res2, h2.getMatches())
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestIsHighCard(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("ABC12", 0)
|
||
|
|
||
|
t.Run("Should be a high card", func(t *testing.T) {
|
||
|
assert.Equal(t, true, isHighCard(h1))
|
||
|
})
|
||
|
|
||
|
t.Run("Should not be a four of a kind", func(t *testing.T) {
|
||
|
assert.Equal(t, false, isFourOfAKind(h1))
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestIsFourOfAKind(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("UUUU9", 0)
|
||
|
h2 := newHand("UUU99", 0)
|
||
|
|
||
|
t.Run("Should be a four of a kind", func(t *testing.T) {
|
||
|
assert.Equal(t, true, isFourOfAKind(h1))
|
||
|
})
|
||
|
|
||
|
t.Run("Should not be a four of a kind", func(t *testing.T) {
|
||
|
assert.Equal(t, false, isFourOfAKind(h2))
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestIsFullHouse(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("333KK", 0)
|
||
|
h2 := newHand("3338K", 0)
|
||
|
|
||
|
t.Run("Should be a fullhouse", func(t *testing.T) {
|
||
|
assert.Equal(t, true, isFullHouse(h1))
|
||
|
})
|
||
|
|
||
|
t.Run("Should not be a fullhouse", func(t *testing.T) {
|
||
|
assert.Equal(t, false, isFullHouse(h2))
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestIsTwoPair(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("33QQA", 0)
|
||
|
|
||
|
t.Run("Should be a twopair", func(t *testing.T) {
|
||
|
assert.Equal(t, true, isTwoPair(h1))
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func TestIsOnePair(t *testing.T) {
|
||
|
//t.Skip("skipping test")
|
||
|
|
||
|
h1 := newHand("33QKA", 0)
|
||
|
|
||
|
t.Run("Should be a onepair", func(t *testing.T) {
|
||
|
assert.Equal(t, true, isOnePair(h1))
|
||
|
})
|
||
|
}
|