github.com/huandu/go@v0.0.0-20151114150818-04e615e41150/misc/swig/stdio/file_test.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package file 6 7 import "testing" 8 9 // Open this file itself and verify that the first few characters are 10 // as expected. 11 func TestRead(t *testing.T) { 12 f := Fopen("file_test.go", "r") 13 if f.Swigcptr() == 0 { 14 t.Fatal("fopen failed") 15 } 16 if Fgetc(f) != '/' || Fgetc(f) != '/' || Fgetc(f) != ' ' || Fgetc(f) != 'C' { 17 t.Error("read unexpected characters") 18 } 19 if Fclose(f) != 0 { 20 t.Error("fclose failed") 21 } 22 }