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;}
13
class MyTestClassString : GLib.Object {
14
public string prop_string {get; set;}
17
class MyTestClassInt : GLib.Object {
18
public int prop_int {get; set;}
21
class MyTestClassBool : GLib.Object {
22
public bool prop_bool {get; set;}
25
class MyTestClassVariant : GLib.Object {
26
public GLib.Variant prop_var {get; set;}
29
class MyTestClassA : GLib.Object {
30
public int prop_int {get;set;}
33
class MyTestClassB : GLib.Object {
34
public MyTestClassA object_prop {get; set;}
36
public bool prop_bool {get;set;}
40
void gobject_to_string_test () {
42
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "int", () => {
43
// var v1 = GLib.Object.new (typeof (MyTestClassInt),
45
// string got_string = object_to_string (v1);
47
// debug (got_string);
49
// string expected = "(MyTestClassInt)}\n\t(gint) prop-int: 1337\n}";
53
// if (expected != got_string) {
55
// Test.message ("The output sting does not match the expected string.");
59
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "string", () => {
60
// var v1 = GLib.Object.new (typeof (MyTestClassString),
61
// prop_string: "string");
63
// string got_string = object_to_string (v1);
65
// debug (got_string);
67
// string expected = "(MyTestClassString):\n\t(gchararray) prop-string: string\n";
71
// if (expected != got_string) {
73
// Test.message ("The output sting does not match the expected string.");
77
// Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "bool", () => {
78
// var v1 = GLib.Object.new (typeof (MyTestClassBool),
81
// string got_string = object_to_string (v1);
83
// debug (got_string);
85
// string expected = "(MyTestClassBool):\n\t(gboolean) prop-bool: true\n";
89
// if (expected != got_string) {
91
// Test.message ("The output sting does not match the expected string.");
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),
100
// string got_string = object_to_string (v1);
102
// debug (got_string);
105
//"(MyTestClassVariant):
106
//\t(GVariant) prop-var: (ssibb)
118
// if (str_cmp (expected, got_string) != 0) {
120
// Test.message ("The output sting does not match the expected string.");
124
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "/nested", () => {
125
MyTestClassB obj = new MyTestClassB ();
126
obj.object_prop = new MyTestClassA ();
128
obj.object_prop.prop_int = 117733;
130
obj.prop_bool = true;
132
GLib.stdout.printf ("%s\n", object_to_string (obj));