PageRenderTime 26ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/go/director_abstract_runme.go

#
Go | 62 lines | 46 code | 16 blank | 0 comment | 10 complexity | 34fbd641b37814013c5da3cecd1ff789 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. package main
  2. import "./director_abstract"
  3. type MyFoo struct{}
  4. func (p *MyFoo) Ping() string {
  5. return "MyFoo::ping()"
  6. }
  7. func f1() {
  8. a := director_abstract.NewDirectorFoo(&MyFoo{})
  9. if a.Ping() != "MyFoo::ping()" {
  10. panic(a.Ping())
  11. }
  12. if a.Pong() != "Foo::pong();MyFoo::ping()" {
  13. panic(a.Pong())
  14. }
  15. }
  16. type MyExample1 struct{}
  17. func (p *MyExample1) Color(r, g, b byte) int {
  18. return int(r)
  19. }
  20. type MyExample2 struct{}
  21. func (p *MyExample2) Color(r, g, b byte) int {
  22. return int(g)
  23. }
  24. type MyExample3 struct{}
  25. func (p *MyExample3) Color(r, g, b byte) int {
  26. return int(b)
  27. }
  28. func f2() {
  29. me1 := director_abstract.NewDirectorExample1(&MyExample1{})
  30. if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 {
  31. println(director_abstract.Example1Get_color(me1, 1, 2, 3))
  32. panic(0)
  33. }
  34. me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2)
  35. if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 {
  36. panic(0)
  37. }
  38. me3 := director_abstract.NewDirectorExample3_i(&MyExample3{})
  39. if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 {
  40. panic(0)
  41. }
  42. }
  43. func main() {
  44. f1()
  45. f2()
  46. }