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:
parent
6bce6cf649
commit
87a06cead1
|
@ -372,21 +372,3 @@ unittest {
|
||||||
readIter!(BitFlags!F)(&iter2).assertThrow!InvalidValueException();
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
Connection connectToBus(DBusBusType bus = DBusBusType.DBUS_BUS_SESSION) {
|
||||||
DBusConnection *conn = wrapErrors((err) { return dbus_bus_get(bus,err); });
|
DBusConnection *conn = wrapErrors((err) { return dbus_bus_get(bus,err); });
|
||||||
return Connection(conn);
|
return Connection(conn);
|
||||||
|
|
Loading…
Reference in a new issue