]> Cypherpunks repositories - gostls13.git/commitdiff
misc/swig/stdio: fix broken nil pointer test
authorShenghou Ma <minux@golang.org>
Wed, 7 Jan 2015 06:23:45 +0000 (01:23 -0500)
committerMinux Ma <minux@golang.org>
Wed, 7 Jan 2015 23:24:23 +0000 (23:24 +0000)
SWIG has always returned a typed interface value for a C++ class,
so the interface value will never be nil even if the pointer itself
is NULL. ptr == NULL in C/C++ should be ptr.Swigcptr() == 0 in Go.

Fixes #9514.

Change-Id: I3778b91acf54d2ff22d7427fbf2b6ec9b9ce3b43
Reviewed-on: https://go-review.googlesource.com/2440
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/swig/stdio/file_test.go

index 6478a7cf37cee2506d29e6115f11f6f55c9330f5..38d0746768e33a82563d2bcb9c72f64b7cf87172 100644 (file)
@@ -10,7 +10,7 @@ import "testing"
 // as expected.
 func TestRead(t *testing.T) {
        f := Fopen("file_test.go", "r")
-       if f == nil {
+       if f.Swigcptr() == 0 {
                t.Fatal("fopen failed")
        }
        if Fgetc(f) != '/' || Fgetc(f) != '/' || Fgetc(f) != ' ' || Fgetc(f) != 'C' {