Skip to content

Instantly share code, notes, and snippets.

@blanchonvincent
Created July 5, 2019 06:35
Show Gist options
  • Save blanchonvincent/e21ac3becc5111739939a08d7af30ad2 to your computer and use it in GitHub Desktop.
Save blanchonvincent/e21ac3becc5111739939a08d7af30ad2 to your computer and use it in GitHub Desktop.
medium - test package - white box test
package deck
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestDeckShouldBeShuffledOnce(t *testing.T) {
var num uint8 = 5
d := NewDeck(num)
assert.Equal(t, len(d.cards), int(num))
assert.Equal(t, d.shuffled, false, "Deck should init as not shuffled")
orderBefore := fmt.Sprint(d.cards)
d.shuffle()
assert.Equal(t, d.shuffled, true, "Deck has not been marked as shuffled")
orderAfter := fmt.Sprint(d.cards)
assert.NotEqual(t, orderBefore, orderAfter, "Deck once shuffled should have new card order")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment