[libgweather/wip/hadess/fix-serialising-deserialising: 2/2] tests: Add test for serialise -> deserialise
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/hadess/fix-serialising-deserialising: 2/2] tests: Add test for serialise -> deserialise
- Date: Wed, 20 Mar 2019 14:30:26 +0000 (UTC)
commit b604b748ddc0adb270b8484b38988e64fcce020d
Author: Bastien Nocera <hadess hadess net>
Date: Wed Mar 20 15:25:00 2019 +0100
tests: Add test for serialise -> deserialise
libgweather/test_libgweather.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c
index ecea68d..20be43d 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/test_libgweather.c
@@ -158,7 +158,8 @@ static void
test_no_code_serialize (void)
{
GVariant *variant;
- GWeatherLocation *world, *loc;
+ GWeatherLocation *world, *loc, *new_loc;
+ GString *str;
world = gweather_location_get_world ();
g_assert_nonnull (world);
@@ -166,10 +167,20 @@ test_no_code_serialize (void)
loc = gweather_location_find_nearest_city (world, 56.833333, 53.183333);
g_assert (loc);
g_assert_cmpstr (gweather_location_get_name (loc), ==, "Izhevsk");
+ g_assert_null (gweather_location_get_code (loc));
variant = gweather_location_serialize (loc);
g_assert_nonnull (variant);
+ str = g_variant_print_string (variant, NULL, TRUE);
+ g_message ("variant: %s", str->str);
+ g_string_free (str, TRUE);
+
+ new_loc = gweather_location_deserialize (world, variant);
g_variant_unref (variant);
+ g_assert_nonnull (new_loc);
+ g_assert_cmpstr (gweather_location_get_name (loc), ==, gweather_location_get_name (new_loc));
+ g_assert_true (gweather_location_equal (loc, new_loc));
+ gweather_location_unref (new_loc);
_gweather_location_reset_world ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]