Files
mars-nwe/tests/nwnss/parse/test_nwnss_parse.c
Mario Fetka 0f82de2743
All checks were successful
Source release / source-package (push) Successful in 1m20s
0536 build: introduce libnwnss for imported NSS runtime
2026-06-14 22:34:04 +02:00

57 lines
1.3 KiB
C

#include <include/parse.h>
#include <library/omni.h>
#include <stdio.h>
#include <string.h>
#define CHECK(expr) \
do { \
if (!(expr)) { \
fprintf(stderr, "CHECK failed at %s:%d: %s\n", __FILE__, __LINE__, #expr); \
return 1; \
} \
} while (0)
int main(void)
{
char value[32] = {0};
NINT flag = -1;
NINT count = 0;
PCLSwitchDef_s switches[] = {
{
"name", NULL,
SWTYPE_VALUE | SWVAL_CHAR,
0, 0, NULL,
value,
.vtype.string = {sizeof(value), 0},
0, 0, StructMSGNot("name value"), NULL, NULL
},
{
"enabled", NULL,
SWTYPE_BOOLEAN | SWVAL_NINT,
0, 0, NULL,
&flag,
.vtype.numeric = {0, 1},
0, 0, StructMSGNot("enabled flag"), NULL, NULL
},
{
"count", NULL,
SWTYPE_VALUE | SWVAL_NINT,
0, 0, NULL,
&count,
.vtype.numeric = {0, 100},
0, 0, StructMSGNot("count value"), NULL, NULL
},
{PCMDLINE_ENDOFLIST}
};
CHECK(LB_ParseCmdline(switches, POPT_AT_RUNTIME,
"/name=demo /enabled /count=42", NULL) == zOK);
CHECK(strcmp(value, "demo") == 0);
CHECK(flag == TRUE);
CHECK(count == 42);
return 0;
}