| 74 | } |
| 75 | |
| 76 | func (s) TestUnmarshalJSON_MarshalUnmarshal(t *testing.T) { |
| 77 | for i := 0; i < _maxCode; i++ { |
| 78 | var cUnMarshaled Code |
| 79 | c := Code(i) |
| 80 | |
| 81 | cJSON, err := json.Marshal(c) |
| 82 | if err != nil { |
| 83 | t.Errorf("marshalling %q failed: %v", c, err) |
| 84 | } |
| 85 | |
| 86 | if err := json.Unmarshal(cJSON, &cUnMarshaled); err != nil { |
| 87 | t.Errorf("unmarshalling code failed: %s", err) |
| 88 | } |
| 89 | |
| 90 | if c != cUnMarshaled { |
| 91 | t.Errorf("code is %q after marshalling/unmarshalling, expected %q", cUnMarshaled, c) |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | func (s) TestUnmarshalJSON_InvalidIntegerCode(t *testing.T) { |
| 97 | const wantErr = "invalid code: 200" // for integer invalid code, expect integer value in error message |