You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/06/04 15:34:26 UTC

[GitHub] [dubbo-go-hessian2] willson-chen commented on a change in pull request #196: Fix #181: float32 accuracy issue

willson-chen commented on a change in pull request #196:
URL: https://github.com/apache/dubbo-go-hessian2/pull/196#discussion_r435351743



##########
File path: double_test.go
##########
@@ -42,6 +42,28 @@ func TestEncDouble(t *testing.T) {
 	t.Logf("decode(%v) = %v, %v\n", v, res, err)
 }
 
+func TestIssue181(t *testing.T) {
+	var (
+		v   float32
+		err error
+		e   *Encoder
+		d   *Decoder
+		res interface{}
+	)
+
+	e = NewEncoder()
+	v = 99.8
+	e.Encode(v)
+	if len(e.Buffer()) == 0 {
+		t.Fail()
+	}
+
+	// res would be '99.800003' without patches in PR #196
+	d = NewDecoder(e.Buffer())
+	res, err = d.Decode()
+	t.Logf("decode(%v) = %v, %v\n", v, res, err)
+}
+

Review comment:
       I followed the previous test case `func TestEncDouble` to add the test case for Issue181. But I am puzzled by that only one judgement on `Encode()` and no judgement on if the result is right.




----------------------------------------------------------------
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.

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