Skip to content

Commit 6d793e4

Browse files
committed
tests for getCommunityID()
1 parent 7f5a03d commit 6d793e4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

game_events_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,26 @@ func TestGetEquipmentInstance_Grenade_Thrown(t *testing.T) {
212212

213213
assert.Equal(t, &he, wep)
214214
}
215+
216+
func TestGetCommunityId(t *testing.T) {
217+
xuid, err := getCommunityID("abcdefgh1:3")
218+
assert.Nil(t, err)
219+
expected := int64(76561197960265728 + 6 + 1)
220+
assert.Equal(t, expected, xuid)
221+
}
222+
223+
func TestGetCommunityId_BOT(t *testing.T) {
224+
xuid, err := getCommunityID("BOT")
225+
assert.Zero(t, xuid)
226+
assert.Nil(t, err)
227+
}
228+
229+
func TestGetCommunityId_Errors(t *testing.T) {
230+
_, err := getCommunityID("12345678a90123")
231+
assert.NotNil(t, err)
232+
assert.Equal(t, "strconv.ParseInt: parsing \"a\": invalid syntax", err.Error())
233+
234+
_, err = getCommunityID("1234567890abc")
235+
assert.NotNil(t, err)
236+
assert.Equal(t, "strconv.ParseInt: parsing \"abc\": invalid syntax", err.Error())
237+
}

0 commit comments

Comments
 (0)