Esempio n. 1
0
func TestParseID3(t *testing.T) {
	for _, details := range steamIDTests {
		steamID, err := steamid.ParseV3(details.ExpectedID3)
		if err != nil {
			t.Errorf("ParseV3(%q): error parsing: %s", details.ExpectedID3, err)
			continue
		}

		if u := steamID.Universe(); u != details.Universe {
			t.Errorf("Universe(%q): got %d, expected %d", details.ExpectedID3, u, details.Universe)
		}

		if inst := steamID.AccountInstance(); inst != details.Instance {
			t.Errorf("AccountInstance(%q): got %d, expected %d", details.ExpectedID3, inst, details.Instance)
		}

		if typ := steamID.AccountType(); typ != details.Type {
			t.Errorf("AccountType(%q): got %d, expected %d", details.ExpectedID3, typ, details.Type)
		}

		if id := steamID.AccountID(); id != details.ID {
			t.Errorf("AccountID(%q): got %d, expected %d", details.ExpectedID3, id, details.ID)
		}
	}
}
Esempio n. 2
0
func BenchmarkParseID3(b *testing.B) {
	const testID = "[U:0:2]"

	for i := 0; i < b.N; i++ {
		if _, err := steamid.ParseV3(testID); err != nil {
			b.Fatal(err)
		}
	}
}