+static void test_unit_name_template(void) {
+#define expect(name, expected) \
+ { \
+ _cleanup_free_ char *f = NULL; \
+ f = unit_name_template(name); \
+ assert_se(f); \
+ printf("got: %s, expected: %s\n", f, expected); \
+ assert_se(streq(f, expected)); \
+ }
+ expect("foo@bar.service", "foo@.service")
+ expect("foo.mount", "foo.mount")
+#undef expect
+}
+
+static void test_unit_name_is_template(void) {
+ assert_se(unit_name_is_template("foo@.service"));
+ assert_se(unit_name_is_template("bar@.path"));
+
+ assert_se(!unit_name_is_template("bar@i.mount"));
+ assert_se(!unit_name_is_template("bar@foobbbb.service"));
+ assert_se(!unit_name_is_template("barfoo.service"));
+}
+