]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/test: make issue5548 test pickier
authorRuss Cox <rsc@golang.org>
Fri, 5 Sep 2014 18:59:09 +0000 (14:59 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 5 Sep 2014 18:59:09 +0000 (14:59 -0400)
If there is doubt about passing arguments correctly
(as there is in this test), there should be doubt about
getting the results back intact too. Using 0 and 1
(especially 0 for success) makes it easy to get a PASS
accidentally when the return value is not actually
being propagated. Use less common values.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/141110043

misc/cgo/test/issue5548.go

index b41f4656236b903d4071c9fc1c3ee5a7bae6770d..c879f2ae91d59d5f9ec5da1cb3c3f23b25786e88 100644 (file)
@@ -14,13 +14,14 @@ import "C"
 //export issue5548FromC
 func issue5548FromC(s string, i int) int {
        if len(s) == 4 && s == "test" && i == 42 {
-               return 1
+               return 12345
        }
-       return 0
+       println("got", len(s), i)
+       return 9876
 }
 
 func test5548(t *testing.T) {
-       if C.issue5548_in_c() == 0 {
-               t.Fail()
+       if x := C.issue5548_in_c(); x != 12345 {
+               t.Errorf("issue5548_in_c = %d, want %d", x, 12345)
        }
 }