You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
497 B
24 lines
497 B
8 years ago
|
// Copyright 2017 Felix Lange <fjl@twurst.com>.
|
||
|
// Use of this source code is governed by the MIT license,
|
||
|
// which can be found in the LICENSE file.
|
||
|
|
||
|
package reqfield
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestRequiredJSON(t *testing.T) {
|
||
|
input := `{"required": 1}`
|
||
|
var x X
|
||
|
if err := json.Unmarshal([]byte(input), &x); err != nil {
|
||
|
t.Fatal("unexpected error", err)
|
||
|
}
|
||
|
|
||
|
input = `{}`
|
||
|
if err := json.Unmarshal([]byte(input), &x); err == nil {
|
||
|
t.Fatal("expected error, got nil")
|
||
|
}
|
||
|
}
|