lib/util: add debug_set_forced_log_priority()
[Samba.git] / source4 / torture / ndr / charset.c
blob7062ce15c90f60a26902b15aafb0f6c02f0206a1
1 /*
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/>.
21 #include "includes.h"
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[] = {
28 NULL,
29 "",
30 "test"
32 int i;
34 struct ndr_push *ndr;
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),
48 expected_ndr_err,
49 "failed to push charset");
52 return true;
55 static bool test_ndr_push_charset_to_null(struct torture_context *tctx)
57 const char *strs[] = {
58 NULL,
59 "",
60 "test"
62 int i;
64 struct ndr_push *ndr;
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");
76 return true;
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);
89 return suite;