summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/test-bus-signature.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-09 02:37:10 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-09 02:40:07 +0200
commit29ddb38fea134c6132e4f2dd608e9da3871eaebe (patch)
treea3683f3d8064f37efe6d7bb9b454d8a8c81f38d5 /src/libsystemd-bus/test-bus-signature.c
parent8d1a28020409ee4afea6ef8c1c4d3522a209284e (diff)
libsystemd-bus: add lightweight object vtable implementation for exposing objects on the bus
This adds a lightweight scheme how to define interfaces in static fixed arrays which then can be easily registered on a bus connection. This makes it much easier to write bus services. This automatically handles implementation of the Properties, ObjectManager, and Introspection bus interfaces.
Diffstat (limited to 'src/libsystemd-bus/test-bus-signature.c')
-rw-r--r--src/libsystemd-bus/test-bus-signature.c67
1 files changed, 44 insertions, 23 deletions
diff --git a/src/libsystemd-bus/test-bus-signature.c b/src/libsystemd-bus/test-bus-signature.c
index cab0daa77e..c4304697f0 100644
--- a/src/libsystemd-bus/test-bus-signature.c
+++ b/src/libsystemd-bus/test-bus-signature.c
@@ -28,29 +28,30 @@
int main(int argc, char *argv[]) {
- assert_se(signature_is_single("y"));
- assert_se(signature_is_single("u"));
- assert_se(signature_is_single("v"));
- assert_se(signature_is_single("as"));
- assert_se(signature_is_single("(ss)"));
- assert_se(signature_is_single("()"));
- assert_se(signature_is_single("(()()()()())"));
- assert_se(signature_is_single("(((())))"));
- assert_se(signature_is_single("((((s))))"));
- assert_se(signature_is_single("{ss}"));
- assert_se(signature_is_single("a{ss}"));
- assert_se(!signature_is_single("uu"));
- assert_se(!signature_is_single(""));
- assert_se(!signature_is_single("("));
- assert_se(!signature_is_single(")"));
- assert_se(!signature_is_single("())"));
- assert_se(!signature_is_single("((())"));
- assert_se(!signature_is_single("{)"));
- assert_se(!signature_is_single("{}"));
- assert_se(!signature_is_single("{sss}"));
- assert_se(!signature_is_single("{s}"));
- assert_se(!signature_is_single("{ass}"));
- assert_se(!signature_is_single("a}"));
+ assert_se(signature_is_single("y", false));
+ assert_se(signature_is_single("u", false));
+ assert_se(signature_is_single("v", false));
+ assert_se(signature_is_single("as", false));
+ assert_se(signature_is_single("(ss)", false));
+ assert_se(signature_is_single("()", false));
+ assert_se(signature_is_single("(()()()()())", false));
+ assert_se(signature_is_single("(((())))", false));
+ assert_se(signature_is_single("((((s))))", false));
+ assert_se(signature_is_single("{ss}", true));
+ assert_se(signature_is_single("a{ss}", false));
+ assert_se(!signature_is_single("uu", false));
+ assert_se(!signature_is_single("", false));
+ assert_se(!signature_is_single("(", false));
+ assert_se(!signature_is_single(")", false));
+ assert_se(!signature_is_single("())", false));
+ assert_se(!signature_is_single("((())", false));
+ assert_se(!signature_is_single("{)", false));
+ assert_se(!signature_is_single("{}", true));
+ assert_se(!signature_is_single("{sss}", true));
+ assert_se(!signature_is_single("{s}", true));
+ assert_se(!signature_is_single("{ss}", false));
+ assert_se(!signature_is_single("{ass}", true));
+ assert_se(!signature_is_single("a}", true));
assert_se(signature_is_pair("yy"));
assert_se(signature_is_pair("ss"));
@@ -112,5 +113,25 @@ int main(int argc, char *argv[]) {
assert_se(!namespace_simple_pattern("", "foo"));
assert_se(!namespace_simple_pattern("foo", ""));
+ assert_se(streq(object_path_startswith("/foo/bar", "/foo"), "bar"));
+ assert_se(streq(object_path_startswith("/foo", "/foo"), ""));
+ assert_se(streq(object_path_startswith("/foo", "/"), "foo"));
+ assert_se(streq(object_path_startswith("/", "/"), ""));
+ assert_se(!object_path_startswith("/foo", "/bar"));
+ assert_se(!object_path_startswith("/", "/bar"));
+ assert_se(!object_path_startswith("/foo", ""));
+
+ assert_se(object_path_is_valid("/foo/bar"));
+ assert_se(object_path_is_valid("/foo"));
+ assert_se(object_path_is_valid("/"));
+ assert_se(object_path_is_valid("/foo5"));
+ assert_se(object_path_is_valid("/foo_5"));
+ assert_se(!object_path_is_valid(""));
+ assert_se(!object_path_is_valid("/foo/"));
+ assert_se(!object_path_is_valid("//"));
+ assert_se(!object_path_is_valid("//foo"));
+ assert_se(!object_path_is_valid("/foo//bar"));
+ assert_se(!object_path_is_valid("/foo/aaaäöä"));
+
return 0;
}