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".
This commit is contained in:
Harry T. Vennik 2017-07-22 15:06:23 +02:00
parent 6bce6cf649
commit 87a06cead1
2 changed files with 13 additions and 18 deletions

View file

@ -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);
}

View file

@ -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);