verbs: use strv_find_closest()
This also makes the list of verbs is always shown on failure.
This commit is contained in:
@@ -54,6 +54,28 @@ TEST(verbs_no_default) {
|
||||
};
|
||||
|
||||
test_dispatch_one(STRV_MAKE(NULL), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("hel"), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("helpp"), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("hgrejgoraoiosafso"), verbs, -EINVAL);
|
||||
}
|
||||
|
||||
TEST(verbs_no_default_many) {
|
||||
static const Verb verbs[] = {
|
||||
{ "help", VERB_ANY, VERB_ANY, 0, noop_dispatcher },
|
||||
{ "list-images", VERB_ANY, 1, 0, noop_dispatcher },
|
||||
{ "list", VERB_ANY, 2, 0, noop_dispatcher },
|
||||
{ "status", 2, VERB_ANY, 0, noop_dispatcher },
|
||||
{ "show", VERB_ANY, VERB_ANY, 0, noop_dispatcher },
|
||||
{ "terminate", 2, VERB_ANY, 0, noop_dispatcher },
|
||||
{ "login", 2, 2, 0, noop_dispatcher },
|
||||
{ "copy-to", 3, 4, 0, noop_dispatcher },
|
||||
{}
|
||||
};
|
||||
|
||||
test_dispatch_one(STRV_MAKE(NULL), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("hel"), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("helpp"), verbs, -EINVAL);
|
||||
test_dispatch_one(STRV_MAKE("hgrejgoraoiosafso"), verbs, -EINVAL);
|
||||
}
|
||||
|
||||
DEFINE_TEST_MAIN(LOG_INFO);
|
||||
|
||||
Reference in New Issue
Block a user