~ubuntu-branches/ubuntu/oneiric/json-glib/oneiric

« back to all changes in this revision

Viewing changes to json-glib/tests/serialize-complex.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2011-09-12 09:08:07 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: package-import@ubuntu.com-20110912090807-3br793wiakn3yr8r
Tags: 0.13.90-1
* New upstream release.
* Drop 0001-Fix-GVariant-creation-on-some-architectures-bug-6504.patch:
  Applied upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
  gboolean bar;
34
34
  gchar *baz;
35
35
  TestBoxed blah;
 
36
  gdouble meh;
36
37
};
37
38
 
38
39
struct _TestObjectClass
83
84
  PROP_FOO,
84
85
  PROP_BAR,
85
86
  PROP_BAZ,
86
 
  PROP_BLAH
 
87
  PROP_BLAH,
 
88
  PROP_MEH
87
89
};
88
90
 
89
91
static JsonSerializableIface *serializable_iface = NULL;
167
169
      g_free (TEST_OBJECT (gobject)->baz);
168
170
      TEST_OBJECT (gobject)->baz = g_value_dup_string (value);
169
171
      break;
 
172
    case PROP_MEH:
 
173
      TEST_OBJECT (gobject)->meh = g_value_get_double (value);
 
174
      break;
170
175
    default:
171
176
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
172
177
    }
192
197
    case PROP_BLAH:
193
198
      g_value_set_boxed (value, &(TEST_OBJECT (gobject)->blah));
194
199
      break;
 
200
    case PROP_MEH:
 
201
      g_value_set_double (value, TEST_OBJECT (gobject)->meh);
 
202
      break;
195
203
    default:
196
204
      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
197
205
    }
226
234
                                   g_param_spec_boxed ("blah", "Blah", "Blah",
227
235
                                                       TEST_TYPE_BOXED,
228
236
                                                       G_PARAM_READABLE));
 
237
  g_object_class_install_property (gobject_class,
 
238
                                   PROP_MEH,
 
239
                                   g_param_spec_double ("meh", "Meh", "Meh",
 
240
                                                        0.0, 1.0, 0.0,
 
241
                                                        G_PARAM_READWRITE |
 
242
                                                        G_PARAM_CONSTRUCT));
229
243
}
230
244
 
231
245
static void
234
248
  object->foo = 42;
235
249
  object->bar = TRUE;
236
250
  object->baz = g_strdup ("Test");
 
251
  object->meh = 0.0;
237
252
 
238
253
  object->blah.foo = object->foo;
239
254
  object->blah.bar = object->bar;
246
261
                                  "foo", 47,
247
262
                                  "bar", FALSE,
248
263
                                  "baz", "Hello, World!",
 
264
                                  "meh", 0.5,
249
265
                                  NULL);
250
266
  JsonParser *parser = json_parser_new ();
251
267
  GError *error = NULL;
271
287
  g_assert_cmpint (json_object_get_int_member (object, "foo"), ==, 47);
272
288
  g_assert (!json_object_get_boolean_member (object, "bar"));
273
289
  g_assert_cmpstr (json_object_get_string_member (object, "baz"), ==, "Hello, World!");
 
290
  g_assert_cmpfloat (json_object_get_double_member (object, "meh"), ==, 0.5);
274
291
 
275
292
  /* blah is read-only */
276
293
  g_assert (json_object_has_member (object, "blah"));