PageRenderTime 23ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 1ms

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

#
Go | 90 lines | 72 code | 12 blank | 6 comment | 36 complexity | 4eaf8c703aac678f6024a66a8577071e MD5 | raw file
 1package main
 2
 3import "./li_attribute"
 4
 5func main() {
 6	aa := li_attribute.NewA(1, 2, 3)
 7
 8	if aa.GetA() != 1 {
 9		panic(0)
10	}
11	aa.SetA(3)
12	if aa.GetA() != 3 {
13		panic(aa.GetA())
14	}
15
16	if aa.GetB() != 2 {
17		panic(aa.GetB())
18	}
19	aa.SetB(5)
20	if aa.GetB() != 5 {
21		panic(0)
22	}
23
24	if aa.GetD() != aa.GetB() {
25		panic(0)
26	}
27
28	if aa.GetC() != 3 {
29		panic(0)
30	}
31
32	pi := li_attribute.NewParam_i(7)
33	if pi.GetValue() != 7 {
34		panic(0)
35	}
36	pi.SetValue(3)
37	if pi.GetValue() != 3 {
38		panic(0)
39	}
40
41	b := li_attribute.NewB(aa)
42
43	if b.GetA().GetC() != 3 {
44		panic(0)
45	}
46
47	// class/struct attribute with get/set methods using
48	// return/pass by reference
49	myFoo := li_attribute.NewMyFoo()
50	myFoo.SetX(8)
51	myClass := li_attribute.NewMyClass()
52	myClass.SetFoo(myFoo)
53	if myClass.GetFoo().GetX() != 8 {
54		panic(0)
55	}
56
57	// class/struct attribute with get/set methods using
58	// return/pass by value
59	myClassVal := li_attribute.NewMyClassVal()
60	if myClassVal.GetReadWriteFoo().GetX() != -1 {
61		panic(0)
62	}
63	if myClassVal.GetReadOnlyFoo().GetX() != -1 {
64		panic(0)
65	}
66	myClassVal.SetReadWriteFoo(myFoo)
67	if myClassVal.GetReadWriteFoo().GetX() != 8 {
68		panic(0)
69	}
70	if myClassVal.GetReadOnlyFoo().GetX() != 8 {
71		panic(0)
72	}
73
74	// string attribute with get/set methods using return/pass by
75	// value
76	myStringyClass := li_attribute.NewMyStringyClass("initial string")
77	if myStringyClass.GetReadWriteString() != "initial string" {
78		panic(0)
79	}
80	if myStringyClass.GetReadOnlyString() != "initial string" {
81		panic(0)
82	}
83	myStringyClass.SetReadWriteString("changed string")
84	if myStringyClass.GetReadWriteString() != "changed string" {
85		panic(0)
86	}
87	if myStringyClass.GetReadOnlyString() != "changed string" {
88		panic(0)
89	}
90}