/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to tests/utils/gobject_to_string.vala

  • Committer: Gustav Hartvigsson
  • Date: 2022-06-01 12:14:52 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20220601121452-ntu94w67q3dhhfeq
More work torwards inperementing the parser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using GLib;
 
2
 
 
3
using Utils;
 
4
using VQDR.Expression;
 
5
 
 
6
 
 
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;}
 
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
 
 
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
 
 
39
 
 
40
void gobject_to_string_test () {
 
41
  
 
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
 
 
136
  
 
137
}