14 { 0, "( FALSE AND FALSE )" },
15 { 0, "( TRUE AND FALSE )" },
16 { 1, "( TRUE AND TRUE )" },
17 { 1, "( TRUE OR TRUE )" },
18 { 1, "( TRUE OR FALSE )" },
19 { 0, "( FALSE OR FALSE )" },
20 { 1, "! ( FALSE OR FALSE )" },
22 { 1, "\"foo\" TAILMATCH \"foo\"" },
23 { 1, "\"foobar\" TAILMATCH \"bar\"" },
24 { 0, "\"foobar\" TAILMATCH \"foo\"" },
26 { 1, "\"foo\" == \"foo\"" },
27 { 0, "\"foo\" == \"bar\"" },
28 { 0, "\"foo\" != \"foo\"" },
29 { 1, "\"foo\" != \"bar\"" },
30 { 1, "%{variable} == \"foo\"" },
31 { 0, "%{variable} == \"bar\"" },
32 { 1, "%{context.variable} == \"foo\"" },
33 { 0, "%{context.variable} == \"bar\"" },
34 { 1, "\"foo\" IN ( \"bar\", \"foo\")" },
35 { 0, "\"foo\" IN ( \"bar\", \"baz\")" },
36 { 0, "\"bar\" IN %{context}" },
37 { 1, "\"foo\" IN %{context}" },
38 { 1, "\"variable\" IN %{context}" },
40 { 1, "\"foo\" IN %{context} AND %{context.variable} == \"foo\"" }
44 main(int argc
, char **argv
)
47 hx509_context context
;
48 hx509_env env
= NULL
, env2
= NULL
;
56 ret
= hx509_context_init(&context
);
58 errx(1, "hx509_context_init failed with %d", ret
);
60 hx509_env_add(context
, &env
, "variable", "foo");
61 hx509_env_add(context
, &env2
, "variable", "foo");
62 hx509_env_add_binding(context
, &env
, "context", env2
);
64 for (i
= 0; i
< sizeof(foo
)/sizeof(foo
[0]); i
++) {
66 expr
= _hx509_expr_parse(foo
[i
].str
);
68 errx(1, "_hx509_expr_parse failed for %d: %s", i
, foo
[i
].str
);
70 val
= _hx509_expr_eval(context
, env
, expr
);
73 errx(1, "_hx509_expr_eval not true when it should: %d: %s",
77 errx(1, "_hx509_expr_eval true when it should not: %d: %s",
81 _hx509_expr_free(expr
);