From 87a06cead1b2f503d71c52a23a096a38969c98ab Mon Sep 17 00:00:00 2001 From: "Harry T. Vennik" Date: Sat, 22 Jul 2017 15:06:23 +0200 Subject: [PATCH] Improved tests Moved unittest for struct types from `ddbus.conv` to `ddbus.thin` and made one struct field private. Test now fails compile-time because of error "member a is not accessible". --- source/ddbus/conv.d | 18 ------------------ source/ddbus/thin.d | 13 +++++++++++++ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/source/ddbus/conv.d b/source/ddbus/conv.d index d4a74cd..43e491a 100644 --- a/source/ddbus/conv.d +++ b/source/ddbus/conv.d @@ -372,21 +372,3 @@ unittest { readIter!(BitFlags!F)(&iter2).assertThrow!InvalidValueException(); } -unittest { - import dunit.toolkit; - import ddbus.thin; - - struct S1 { int a; double b; string s; } - struct S2 { Variant!int c; string d; S1 e; uint f; } - - Message msg = Message("org.example.wow", "/wut", "org.test.iface", "meth3"); - - enum testStruct = S2(variant(5), "blah", S1(-7, 63.5, "test"), 16); - msg.build(testStruct); - - DBusMessageIter iter; - dbus_message_iter_init(msg.msg, &iter); - - readIter!S2(&iter).assertEqual(testStruct); -} - diff --git a/source/ddbus/thin.d b/source/ddbus/thin.d index de60eba..7710502 100644 --- a/source/ddbus/thin.d +++ b/source/ddbus/thin.d @@ -570,6 +570,19 @@ struct Connection { } } +unittest { + import dunit.toolkit; + + struct S1 { private int a; double b; string s; } + struct S2 { Variant!int c; string d; S1 e; uint f; } + + Message msg = Message("org.example.wow", "/wut", "org.test.iface", "meth3"); + + enum testStruct = S2(variant(5), "blah", S1(-7, 63.5, "test"), 16); + msg.build(testStruct); + msg.read!S2().assertEqual(testStruct); +} + Connection connectToBus(DBusBusType bus = DBusBusType.DBUS_BUS_SESSION) { DBusConnection *conn = wrapErrors((err) { return dbus_bus_get(bus,err); }); return Connection(conn);