2
// This is just too hard to make a test for.
9
class MyTestClass : GLib.Object {
10
public int prop_int {get; set;}
11
public string prop_string {get; set;}
12
public bool prop_bool {get; set;}
15
class MyTestClassString : GLib.Object {
16
public string prop_string {get; set;}
19
class MyTestClassInt : GLib.Object {
20
public int prop_int {get; set;}
23
class MyTestClassBool : GLib.Object {
24
public bool prop_bool {get; set;}
27
class MyTestClassVariant : GLib.Object {
28
public GLib.Variant prop_var {get; set;}
31
class MyTestClassA : GLib.Object {
32
public int prop_int {get;set;}
35
class MyTestClassB : GLib.Object {
36
public MyTestClassA object_prop {get; set;}
38
public bool prop_bool {get;set;}
42
void gobject_to_string_test () {
44
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "int", () => {
45
var v1 = GLib.Object.new (typeof (MyTestClassInt),
47
string got_string = object_to_string (v1);
51
string expected = "(MyTestClassInt)}\n\t(gint) prop-int: 1337\n}";
55
if (expected != got_string) {
57
Test.message ("The output sting does not match the expected string.");
61
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "string", () => {
62
var v1 = GLib.Object.new (typeof (MyTestClassString),
63
prop_string: "string");
65
string got_string = object_to_string (v1);
69
string expected = "(MyTestClassString):\n\t(gchararray) prop-string: string\n";
73
if (expected != got_string) {
75
Test.message ("The output sting does not match the expected string.");
79
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "bool", () => {
80
var v1 = GLib.Object.new (typeof (MyTestClassBool),
83
string got_string = object_to_string (v1);
87
string expected = "(MyTestClassBool):\n\t(gboolean) prop-bool: true\n";
91
if (expected != got_string) {
93
Test.message ("The output sting does not match the expected string.");
97
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "variant", () => {
98
var my_var = new Variant ("(ssibb)", "aa", "bb", 10, false, true);
99
var v1 = GLib.Object.new (typeof (MyTestClassVariant),
102
string got_string = object_to_string (v1);
107
"(MyTestClassVariant):
108
\t(GVariant) prop-var: (ssibb)
120
if (str_cmp (expected, got_string) != 0) {
122
Test.message ("The output sting does not match the expected string.");
126
Test.add_func (UTIL_TEST_GOBJECT_PREFIX + "/nested", () => {
127
MyTestClassB obj = new MyTestClassB ();
128
obj.object_prop = new MyTestClassA ();
130
obj.object_prop.prop_int = 117733;
132
obj.prop_bool = true;
134
GLib.stdout.printf ("%s\n", object_to_string (obj));