Skip to content

Commit

Permalink
test: check if TestMapInObject decoded value is equal to original value
Browse files Browse the repository at this point in the history
  • Loading branch information
ahaostudy committed Nov 1, 2023
1 parent 4ce3eae commit fbdccbe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package hessian

import (
"reflect"
"testing"
)

Expand Down Expand Up @@ -195,21 +196,21 @@ func (Obj) JavaClassName() string {

func TestMapInObject(t *testing.T) {
var (
obj Obj
req *Obj
e *Encoder
d *Decoder
err error
res interface{}
)

obj = Obj{
req = &Obj{
Map8: map[int8]int8{1: 2, 3: 4},
Map16: map[int16]int16{1: 2, 3: 4},
Map32: map[int32]int32{1: 2, 3: 4},
}

e = NewEncoder()
e.Encode(obj)
e.Encode(req)
if len(e.Buffer()) == 0 {
t.Fail()
}
Expand All @@ -219,5 +220,9 @@ func TestMapInObject(t *testing.T) {
if err != nil {
t.Errorf("Decode() = %+v", err)
}
t.Logf("decode(%v) = %v, %v\n", obj, res, err)
t.Logf("decode(%v) = %v, %v\n", req, res, err)

if !reflect.DeepEqual(req, res) {
t.Fatalf("req: %#v != res: %#v", req, res)
}
}

0 comments on commit fbdccbe

Please sign in to comment.