...
1
2
3
4
5
6
7
8
9
10 package main
11
12
13 import "C"
14 import (
15 "fmt"
16 "os"
17 )
18
19 func F() int { return int(C.F()) }
20
21 func main() {
22 if x := int(C.F()); x != 1 {
23 fatal("x = %d, want 1", x)
24 }
25
26
27
28 f := Fopen("main.go", "r")
29 if f.Swigcptr() == 0 {
30 fatal("fopen failed")
31 }
32 if Fgetc(f) != '/' || Fgetc(f) != '/' || Fgetc(f) != ' ' || Fgetc(f) != 'C' {
33 fatal("read unexpected characters")
34 }
35 if Fclose(f) != 0 {
36 fatal("fclose failed")
37 }
38
39 println("OK")
40 }
41
42 func fatal(f string, args ...any) {
43 fmt.Fprintln(os.Stderr, fmt.Sprintf(f, args...))
44 os.Exit(1)
45 }
46
View as plain text