swig/Examples/test-suite/go/friends_runme.go
Olly Betts 0e0f283e48 Fix friends_runme.*
Most of these test D_d twice when they really should be testing
D_d once and D_i once (the variable name is `di` and the values
assigned are integers).

This was wrong in the initial version for Python in
708021a809 and it looks like subsequent
additions for other languages have just copied that mistake.
2022-07-22 17:50:47 +12:00

50 lines
767 B
Go

package main
import "swigtests/friends"
func main() {
a := friends.NewA(2)
if friends.Get_val1(a).(int) != 2 {
panic(0)
}
if friends.Get_val2(a) != 4 {
panic(0)
}
if friends.Get_val3(a) != 6 {
panic(0)
}
// nice overload working fine
if friends.Get_val1(1, 2, 3).(int) != 1 {
panic(0)
}
b := friends.NewB(3)
// David's case
if friends.Mix(a, b) != 5 {
panic(0)
}
di := friends.NewD_i(2)
dd := friends.NewD_d(3.3)
// incredible template overloading working just fine
if friends.Get_val1(di).(int) != 2 {
panic(0)
}
if friends.Get_val1(dd).(float64) != 3.3 {
panic(0)
}
friends.Set(di, 4)
friends.Set(dd, 1.3)
if friends.Get_val1(di).(int) != 4 {
panic(0)
}
if friends.Get_val1(dd).(float64) != 1.3 {
panic(0)
}
}