69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package csgo
|
|
|
|
import "testing"
|
|
|
|
func TestGoodSharecodes(t *testing.T) {
|
|
eMatchId := uint64(3505575050994516382)
|
|
eOutcomeId := uint64(3505581094013501947)
|
|
eTokenId := uint16(12909)
|
|
|
|
matchId, outcomeId, tokenId, err := DecodeSharecode("CSGO-P9k3F-eVL9n-LZLXN-DrBGF-VKD7K")
|
|
if err != nil {
|
|
t.Log("error should be nil", err)
|
|
t.Fail()
|
|
}
|
|
|
|
if matchId != eMatchId {
|
|
t.Logf("matchID should be %d, is %d", eMatchId, matchId)
|
|
t.Fail()
|
|
}
|
|
if outcomeId != eOutcomeId {
|
|
t.Logf("outcomeID should be %d, is %d", eOutcomeId, outcomeId)
|
|
t.Fail()
|
|
}
|
|
if tokenId != eTokenId {
|
|
t.Logf("tokenID should be %d, is %d", eTokenId, tokenId)
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestBadSharecodes(t *testing.T) {
|
|
matchId, outcomeId, tokenId, err := DecodeSharecode("CSGO-AAAAA-AAAAA-AAAAA-AAAAA-AAAAA")
|
|
if err != nil {
|
|
t.Log("error should not be set", err)
|
|
t.Fail()
|
|
}
|
|
|
|
if matchId != 0 {
|
|
t.Logf("matchID should be 0, is %d", matchId)
|
|
t.Fail()
|
|
}
|
|
if outcomeId != 0 {
|
|
t.Logf("outcomeID should be 0, is %d", outcomeId)
|
|
t.Fail()
|
|
}
|
|
if tokenId != 0 {
|
|
t.Logf("tokenID should be 0, is %d", tokenId)
|
|
t.Fail()
|
|
}
|
|
|
|
matchId, outcomeId, tokenId, err = DecodeSharecode("CSGO-99999-99999-99999-99999-99999")
|
|
if err == nil {
|
|
t.Log("error should be set", err)
|
|
t.Fail()
|
|
}
|
|
|
|
if matchId != 0 {
|
|
t.Logf("matchID should be 0, is %d", matchId)
|
|
t.Fail()
|
|
}
|
|
if outcomeId != 0 {
|
|
t.Logf("outcomeID should be 0, is %d", outcomeId)
|
|
t.Fail()
|
|
}
|
|
if tokenId != 0 {
|
|
t.Logf("tokenID should be 0, is %d", tokenId)
|
|
t.Fail()
|
|
}
|
|
}
|