-
Notifications
You must be signed in to change notification settings - Fork 3
/
misctypes_test.go
50 lines (44 loc) · 1.1 KB
/
misctypes_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2015 Shannon Wynter. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package steamauth
import (
"encoding/json"
"testing"
)
func TestSteamID(t *testing.T) {
jsondata := `{"steam_id": "76561198263585543"}`
jsonout := struct {
SteamID SteamID `json:"steam_id"`
}{}
err := json.Unmarshal([]byte(jsondata), &jsonout)
if err != nil {
t.Error(err)
}
if jsonout.SteamID != SteamID(76561198263585543) {
t.Error("mismatched")
}
}
func TestCaptchaGID(t *testing.T) {
cases := []struct {
input string
result CaptchaGID
output string
}{
{`-1`, CaptchaGID("-1"), "-1"},
{`"756965923036385917"`, CaptchaGID("756965923036385917"), "756965923036385917"},
}
for _, test := range cases {
result := CaptchaGID("")
err := json.Unmarshal([]byte(test.input), &result)
if err != nil {
t.Error(err)
}
if result != test.result {
t.Errorf("mismatched `%#v` <> `%#v`", result, test.result)
}
if result.String() != test.output {
t.Errorf("string mismatched `%s` <> `%s`", result.String(), test.output)
}
}
}