package csgo_test import ( "testing" "somegit.dev/csgowtf/csgowtfd/csgo" ) func TestGoodSharecodes(t *testing.T) { //nolint:paralleltest eMatchID := uint64(3505575050994516382) eOutcomeID := uint64(3505581094013501947) eTokenID := uint16(12909) matchID, outcomeId, tokenId, err := csgo.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 := csgo.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 = csgo.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() } }