improved base57 decode and tests
This commit is contained in:
@@ -3,10 +3,10 @@ package csgo
|
||||
import "testing"
|
||||
|
||||
//goland:noinspection SpellCheckingInspection
|
||||
func TestSharecode(t *testing.T) {
|
||||
func TestGoodSharecodes(t *testing.T) {
|
||||
eMatchId := uint64(3505575050994516382)
|
||||
eOutcomeId := uint64(3505581094013501947)
|
||||
eTokenId := uint32(12909)
|
||||
eTokenId := uint16(12909)
|
||||
|
||||
matchId, outcomeId, tokenId, err := DecodeSharecode("CSGO-P9k3F-eVL9n-LZLXN-DrBGF-VKD7K")
|
||||
if err != nil {
|
||||
@@ -27,3 +27,43 @@ func TestSharecode(t *testing.T) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user