<update!> assert_in_set() for WERROR
David Disseldorp
ddiss at samba.org
Sat Aug 26 19:46:07 UTC 2017
Hi Dimitris,
On Sat, 26 Aug 2017 16:06:25 +0300, Dimitris Gravanis via samba-technical wrote:
> On 26/08/2017 02:54 μμ, Dimitris Gravanis wrote:
> >
> > I want to check if a function returns one of the following WERROR
> > definitions:
> >
> > In werror_gen.h:
> >
> > * |WERR_NERR_SUCCESS W_ERROR=0x0|
> > * |WERR_NOT_ENOUGH_MEMORY W_ERROR=0x8|
> > * |WERR_DNS_ERROR_RCODE_NOTAUTH W_ERROR=0x2331|
> > * |WERR_DNS_ERROR_RCODE_FORMAT_ERROR W_ERROR=0x2329|
> >
>
> After some more reading cmocka assertion macros and trial-and-error, my
> code for this is:
...
> ||*WERROR test_werr* = (unsigned long)
> dns_cli_generate_tsig(test_client, mem_ctx,||
> || test_state, test_packet, in_test);||
> ||
> || assert_in_set(test_werr, werr_set, 4);
>
> |Which obviously fails, due to type casting. How could I extract x from
> the W_ERROR(x) format to make it work in assert_in_set()?
I'd recommend using cmocka's simple assert_true() / assert_false()
calls, alongside the regular WERROR test macros. E.g.
assert_true(W_ERROR_IS_OK(werr));
assert_true(W_ERROR_EQUAL(werr, WERR_NOT_ENOUGH_MEMORY));
etc.
Cheers, David
More information about the samba-technical
mailing list