bzr branch
http://gegoxaren.bato24.eu/bzr/vqdr/trunk
|
9
by Gustav Hartvigsson
* object_to_string () - Prittier prints, |
1 |
using GLib; |
2 |
||
|
36
by Gustav Hartvigsson
Refactoring. |
3 |
using Utils; |
|
7
by Gustav Hartvigsson
* Woops. |
4 |
using VQDR.Expression; |
5 |
||
|
36
by Gustav Hartvigsson
Refactoring. |
6 |
|
|
7
by Gustav Hartvigsson
* Woops. |
7 |
class MyTestClass : GLib.Object { |
8 |
public int prop_int {get; set;} |
|
9 |
public string prop_string {get; set;} |
|
10 |
public bool prop_bool {get; set;} |
|
|
9
by Gustav Hartvigsson
* object_to_string () - Prittier prints, |
11 |
}
|
12 |
||
13 |
class MyTestClassString : GLib.Object { |
|
14 |
public string prop_string {get; set;} |
|
15 |
}
|
|
16 |
||
17 |
class MyTestClassInt : GLib.Object { |
|
18 |
public int prop_int {get; set;} |
|
19 |
}
|
|
20 |
||
21 |
class MyTestClassBool : GLib.Object { |
|
22 |
public bool prop_bool {get; set;} |
|
23 |
}
|
|
24 |
||
25 |
class MyTestClassVariant : GLib.Object { |
|
26 |
public GLib.Variant prop_var {get; set;} |
|
27 |
}
|
|
28 |
||
|
40
by Gustav Hartvigsson
Sort of fixed object_to_string ()... |
29 |
class MyTestClassA : GLib.Object { |
30 |
public int prop_int {get;set;} |
|
31 |
}
|
|
32 |
||
33 |
class MyTestClassB : GLib.Object { |
|
34 |
public MyTestClassA object_prop {get; set;} |
|
35 |
||
36 |
public bool prop_bool {get;set;} |
|
37 |
}
|
|
38 |
||
|
9
by Gustav Hartvigsson
* object_to_string () - Prittier prints, |
39 |
|
40 |
void gobject_to_string_test () { |
|
41 |
|
|
|
40
by Gustav Hartvigsson
Sort of fixed object_to_string ()... |
42 |
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "int", () => {
|
43 |
// var v1 = GLib.Object.new (typeof (MyTestClassInt),
|
|
44 |
// prop_int: 1337);
|
|
45 |
// string got_string = object_to_string (v1);
|
|
46 |
//
|
|
47 |
// debug (got_string);
|
|
48 |
//
|
|
49 |
// string expected = "(MyTestClassInt)}\n\t(gint) prop-int: 1337\n}";
|
|
50 |
//
|
|
51 |
// debug (expected);
|
|
52 |
//
|
|
53 |
// if (expected != got_string) {
|
|
54 |
// Test.fail ();
|
|
55 |
// Test.message ("The output sting does not match the expected string.");
|
|
56 |
// }
|
|
57 |
// });
|
|
58 |
//
|
|
59 |
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "string", () => {
|
|
60 |
// var v1 = GLib.Object.new (typeof (MyTestClassString),
|
|
61 |
// prop_string: "string");
|
|
62 |
//
|
|
63 |
// string got_string = object_to_string (v1);
|
|
64 |
//
|
|
65 |
// debug (got_string);
|
|
66 |
//
|
|
67 |
// string expected = "(MyTestClassString):\n\t(gchararray) prop-string: string\n";
|
|
68 |
//
|
|
69 |
// debug (expected);
|
|
70 |
//
|
|
71 |
// if (expected != got_string) {
|
|
72 |
// Test.fail ();
|
|
73 |
// Test.message ("The output sting does not match the expected string.");
|
|
74 |
// }
|
|
75 |
// });
|
|
76 |
//
|
|
77 |
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "bool", () => {
|
|
78 |
// var v1 = GLib.Object.new (typeof (MyTestClassBool),
|
|
79 |
// prop_bool: true);
|
|
80 |
//
|
|
81 |
// string got_string = object_to_string (v1);
|
|
82 |
//
|
|
83 |
// debug (got_string);
|
|
84 |
//
|
|
85 |
// string expected = "(MyTestClassBool):\n\t(gboolean) prop-bool: true\n";
|
|
86 |
//
|
|
87 |
// debug (expected);
|
|
88 |
//
|
|
89 |
// if (expected != got_string) {
|
|
90 |
// Test.fail ();
|
|
91 |
// Test.message ("The output sting does not match the expected string.");
|
|
92 |
// }
|
|
93 |
// });
|
|
94 |
//
|
|
95 |
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "variant", () => {
|
|
96 |
// var my_var = new Variant ("(ssibb)", "aa", "bb", 10, false, true);
|
|
97 |
// var v1 = GLib.Object.new (typeof (MyTestClassVariant),
|
|
98 |
// prop_var: my_var);
|
|
99 |
//
|
|
100 |
// string got_string = object_to_string (v1);
|
|
101 |
//
|
|
102 |
// debug (got_string);
|
|
103 |
//
|
|
104 |
// string expected =
|
|
105 |
//"(MyTestClassVariant):
|
|
106 |
//\t(GVariant) prop-var: (ssibb)
|
|
107 |
//\t(
|
|
108 |
//\t\t((s): 'aa')
|
|
109 |
//\t\t((s): 'bb')
|
|
110 |
//\t\t((i): 10)
|
|
111 |
//\t\t((b): false)
|
|
112 |
//\t\t((b): true)
|
|
113 |
//\t)
|
|
114 |
//";
|
|
115 |
//
|
|
116 |
// debug (expected);
|
|
117 |
//
|
|
118 |
// if (str_cmp (expected, got_string) != 0) {
|
|
119 |
// Test.fail ();
|
|
120 |
// Test.message ("The output sting does not match the expected string.");
|
|
121 |
// }
|
|
122 |
// });
|
|
123 |
||
124 |
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "/nested", () => { |
|
125 |
MyTestClassB obj = new MyTestClassB (); |
|
126 |
obj.object_prop = new MyTestClassA (); |
|
127 |
||
128 |
obj.object_prop.prop_int = 117733; |
|
129 |
||
130 |
obj.prop_bool = true; |
|
131 |
||
132 |
GLib.stdout.printf ("%s\n", object_to_string (obj)); |
|
133 |
||
134 |
}); |
|
135 |
||
|
9
by Gustav Hartvigsson
* object_to_string () - Prittier prints, |
136 |
|
|
7
by Gustav Hartvigsson
* Woops. |
137 |
}
|