Created
July 5, 2019 06:35
-
-
Save blanchonvincent/e21ac3becc5111739939a08d7af30ad2 to your computer and use it in GitHub Desktop.
medium - test package - white box test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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