json
(t *testing.T)
| 65 | |
| 66 | // json |
| 67 | func TestBinder_Bind_json_error(t *testing.T) { |
| 68 | |
| 69 | binder := newBinder() |
| 70 | |
| 71 | if binder == nil { |
| 72 | t.Error("binder can not be nil!") |
| 73 | } |
| 74 | |
| 75 | // init DotServer |
| 76 | app := New() |
| 77 | |
| 78 | if app == nil { |
| 79 | t.Error("app can not be nil!") |
| 80 | } |
| 81 | |
| 82 | // expected |
| 83 | expected := &Person{ |
| 84 | Hair: "Brown", |
| 85 | HasGlass: true, |
| 86 | Age: 10, |
| 87 | Legs: []string{"Left", "Right"}, |
| 88 | } |
| 89 | |
| 90 | // init param |
| 91 | param := &InitContextParam{ |
| 92 | t, |
| 93 | expected, |
| 94 | "application/xml", |
| 95 | test.ToJson, |
| 96 | } |
| 97 | |
| 98 | // init param |
| 99 | context := initContext(param) |
| 100 | // actual |
| 101 | person := &Person{} |
| 102 | |
| 103 | err := binder.Bind(person, context) |
| 104 | |
| 105 | // check error must not nil |
| 106 | test.NotNil(t, err) |
| 107 | } |
| 108 | |
| 109 | // xml |
| 110 | func TestBinder_Bind_xml(t *testing.T) { |