1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00
samba-mirror/pidl/tests/ndr_represent.pl
Douglas Bagnall efef4366f1 pidl: use perl warnings
Warnings are good. If we turn on warnings with 'use warnings', we will
see bugs that have lain latent for years.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-12-10 02:53:34 +00:00

73 lines
1.4 KiB
Perl
Executable File

#!/usr/bin/perl
# NDR represent_as() / transmit_as() tests
# (C) 2006 Jelmer Vernooij. Published under the GNU GPL
use strict;
use warnings;
use Test::More tests => 2 * 8;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_samba4_ndr);
test_samba4_ndr('represent_as-simple',
'
void bla([in,represent_as(uint32)] uint8 x);
',
'
uint8_t expected[] = { 0x0D };
DATA_BLOB in_blob = { expected, 1 };
struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
struct bla r;
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
return 1;
if (r.in.x != 13)
return 2;
',
'
enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
*to = from;
return NDR_ERR_SUCCESS;
}
enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
{
*to = from;
return NDR_ERR_SUCCESS;
}
'
);
test_samba4_ndr('transmit_as-simple',
'
void bla([in,transmit_as(uint32)] uint8 x);
',
'
uint8_t expected[] = { 0x0D };
DATA_BLOB in_blob = { expected, 1 };
struct ndr_pull *ndr = ndr_pull_init_blob(&in_blob, NULL, NULL);
struct bla r;
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_pull_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
return 1;
if (r.in.x != 13)
return 2;
',
'
enum ndr_err_code ndr_uint8_to_uint32(uint8_t from, uint32_t *to)
{
*to = from;
return NDR_ERR_SUCCESS;
}
enum ndr_err_code ndr_uint32_to_uint8(uint32_t from, uint8_t *to)
{
*to = from;
return NDR_ERR_SUCCESS;
}
'
);