1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package main
import (
"fmt"
"os"
"swigtests/example"
)
func Compare(name string, got string, exp string) error {
fmt.Printf("%s; Got: '%s'; Expected: '%s'\n", name, got, exp)
if got != exp {
return fmt.Errorf("%s returned unexpected string! Got: '%s'; Expected: '%s'\n", name, got, exp)
}
return nil
}
func TestFooBarCpp() error {
fb := example.NewFooBarCpp()
defer example.DeleteFooBarCpp(fb)
return Compare("FooBarCpp.FooBar()", fb.FooBar(), "C++ Foo, C++ Bar")
}
func TestFooBarGo() error {
fb := example.NewFooBarGo()
defer example.DeleteFooBarGo(fb)
return Compare("FooBarGo.FooBar()", fb.FooBar(), "Go Foo, Go Bar")
}
func main() {
fmt.Println("Test output:")
fmt.Println("------------")
err := TestFooBarCpp()
err = TestFooBarGo()
fmt.Println("------------")
if err != nil {
fmt.Fprintf(os.Stderr, "Tests failed! Last error: %s\n", err.Error())
os.Exit(1)
}
}
|