You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "tiltwind (via GitHub)" <gi...@apache.org> on 2023/11/01 05:44:54 UTC

Re: [PR] fix Decoder failed to decode int8/int16 type values of map field in struct [dubbo-go-hessian2]

tiltwind commented on code in PR #366:
URL: https://github.com/apache/dubbo-go-hessian2/pull/366#discussion_r1378415059


##########
map_test.go:
##########
@@ -182,3 +182,42 @@ func TestJavaMap(t *testing.T) {
 	RegisterPOJO(customMap)
 	testJavaDecode(t, "customArgTypedFixed_CustomMap", customMap)
 }
+
+type Obj struct {
+	Map8  map[int8]int8
+	Map16 map[int16]int16
+	Map32 map[int32]int32
+}
+
+func (Obj) JavaClassName() string {
+	return ""
+}
+
+func TestMapInObject(t *testing.T) {
+	var (
+		obj Obj
+		e   *Encoder
+		d   *Decoder
+		err error
+		res interface{}
+	)
+
+	obj = 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)
+	if len(e.Buffer()) == 0 {
+		t.Fail()
+	}
+
+	d = NewDecoder(e.Buffer())
+	res, err = d.Decode()
+	if err != nil {
+		t.Errorf("Decode() = %+v", err)
+	}
+	t.Logf("decode(%v) = %v, %v\n", obj, res, err)

Review Comment:
   should check whether the decode value is equal to the original 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org