2 Unix SMB/CIFS implementation.
3 test suite for charset ndr operations
5 Copyright (C) Guenther Deschner 2017
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "torture/ndr/ndr.h"
23 #include "torture/ndr/proto.h"
25 static bool test_ndr_push_charset(struct torture_context
*tctx
)
27 const char *strs
[] = {
36 ndr
= talloc_zero(tctx
, struct ndr_push
);
38 for (i
= 0; i
< ARRAY_SIZE(strs
); i
++) {
40 enum ndr_err_code expected_ndr_err
= NDR_ERR_SUCCESS
;
42 if (strs
[i
] == NULL
) {
43 expected_ndr_err
= NDR_ERR_INVALID_POINTER
;
46 torture_assert_ndr_err_equal(tctx
,
47 ndr_push_charset(ndr
, NDR_SCALARS
, strs
[i
], 256, 2, CH_UTF16LE
),
49 "failed to push charset");
55 static bool test_ndr_push_charset_to_null(struct torture_context
*tctx
)
57 const char *strs
[] = {
66 ndr
= talloc_zero(tctx
, struct ndr_push
);
69 for (i
= 0; i
< ARRAY_SIZE(strs
); i
++) {
71 torture_assert_ndr_success(tctx
,
72 ndr_push_charset_to_null(ndr
, NDR_SCALARS
, strs
[i
], 256, 2, CH_UTF16LE
),
73 "failed to push charset to null");
80 struct torture_suite
*ndr_charset_suite(TALLOC_CTX
*ctx
)
82 struct torture_suite
*suite
= torture_suite_create(ctx
, "charset");
84 suite
->description
= talloc_strdup(suite
, "NDR - charset focused push/pull tests");
86 torture_suite_add_simple_test(suite
, "push", test_ndr_push_charset
);
87 torture_suite_add_simple_test(suite
, "push_to_null", test_ndr_push_charset_to_null
);