diff --git a/source/ddbus/router.d b/source/ddbus/router.d
index e999eca..e107963 100644
--- a/source/ddbus/router.d
+++ b/source/ddbus/router.d
@@ -194,6 +194,10 @@ void registerRouter(Connection conn, MessageRouter router) {
unittest{
import dunit.toolkit;
+
+ import std.typecons : BitFlags;
+ import std.variant : Algebraic;
+
auto router = new MessageRouter();
// set up test messages
MessagePattern patt = MessagePattern("/root","ca.thume.test","test");
@@ -209,6 +213,24 @@ unittest{
patt = MessagePattern("/troll","ca.thume.tester","wow");
router.setHandler!(void)(patt,{return;});
+ patt = MessagePattern("/root/fancy","ca.thume.tester","crazyTest");
+ enum F : ushort { a = 1, b = 8, c = 16 }
+ struct S { byte b; ulong ul; F f; }
+ router.setHandler!(int)(patt, (Algebraic!(ushort, BitFlags!F, S) v) {
+ if (v.type is typeid(ushort) || v.type is typeid(BitFlags!F)) {
+ return v.coerce!int;
+ } else if (v.type is typeid(S)) {
+ auto s = v.get!S;
+ final switch (s.f) {
+ case F.a: return s.b;
+ case F.b: return cast(int) s.ul;
+ case F.c: return cast(int) s.ul + s.b;
+ }
+ }
+
+ assert(false);
+ });
+
static assert(!__traits(compiles, {
patt = MessagePattern("/root/bar","ca.thume.tester","lolwut");
router.setHandler!(void, DBusAny)(patt,(DBusAny wrongUsage){return;});
@@ -216,10 +238,13 @@ unittest{
// TODO: these tests rely on nondeterministic hash map ordering
static string introspectResult = `
-`;
+`;
router.introspectXML("/root").assertEqual(introspectResult);
static string introspectResult2 = `
`;
router.introspectXML("/root/foo").assertEqual(introspectResult2);
+ static string introspectResult3 = `
+`;
+ router.introspectXML("/root/fancy").assertEqual(introspectResult3);
router.introspectXML("/").assertEndsWith(``);
}