mirror of
https://github.com/golang/go
synced 2024-11-23 07:50:05 -07:00
583293349b
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>
23 lines
570 B
Go
23 lines
570 B
Go
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package file
|
|
|
|
import "testing"
|
|
|
|
// Open this file itself and verify that the first few characters are
|
|
// as expected.
|
|
func TestRead(t *testing.T) {
|
|
f := Fopen("file_test.go", "r")
|
|
if f.Swigcptr() == 0 {
|
|
t.Fatal("fopen failed")
|
|
}
|
|
if Fgetc(f) != '/' || Fgetc(f) != '/' || Fgetc(f) != ' ' || Fgetc(f) != 'C' {
|
|
t.Error("read unexpected characters")
|
|
}
|
|
if Fclose(f) != 0 {
|
|
t.Error("fclose failed")
|
|
}
|
|
}
|