Source file misc/swig/stdio/file_test.go

     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  }
    23  
    24  func TestF(t *testing.T) {
    25  	if x := F(); x != 1 {
    26  		t.Fatalf("x = %d, want 1", x)
    27  	}
    28  }
    29  

View as plain text