test-verbs: dispatch via _dispatch_verb_with_args() directly
Drops the global-optind dependency from the test helper. Verb fixtures stay inline as static const Verb[] — the section-based VERB() macro would force unique verb names across the three test cases, which they deliberately share to exercise overlap. Co-developed-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include "strv.h"
|
||||
#include "tests.h"
|
||||
#include "verbs.h"
|
||||
@@ -11,8 +9,7 @@ static int noop_dispatcher(int argc, char *argv[], uintptr_t _data, void *userda
|
||||
}
|
||||
|
||||
#define test_dispatch_one(argv, verbs, expected) \
|
||||
optind = 0; \
|
||||
assert_se(dispatch_verb(strv_length(argv), argv, verbs, NULL) == expected);
|
||||
assert_se(_dispatch_verb_with_args(argv, verbs, verbs + ELEMENTSOF(verbs) - 1, NULL) == expected);
|
||||
|
||||
TEST(verbs) {
|
||||
static const Verb verbs[] = {
|
||||
|
||||
Reference in New Issue
Block a user