2 * Unix SMB/CIFS implementation.
4 * Copyright (C) 2018 Andreas Schneider <asn@samba.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 static void test_ldb_dn_add_child_fmt(void **state
)
29 struct ldb_context
*ldb
= ldb_init(NULL
, NULL
);
31 struct ldb_dn
*dn
= ldb_dn_new(ldb
, ldb
, "dc=samba,dc=org");
33 assert_true(ldb_dn_add_child_fmt(dn
,
36 assert_string_equal("DC=X,dc=samba,dc=org",
37 ldb_dn_get_linearized(dn
));
39 assert_string_equal("DC=X,DC=SAMBA,DC=ORG",
40 ldb_dn_get_casefold(dn
));
44 static void test_ldb_dn_add_child_fmt2(void **state
)
46 struct ldb_context
*ldb
= ldb_init(NULL
, NULL
);
48 struct ldb_dn
*dn
= ldb_dn_new(ldb
, ldb
, "dc=samba,dc=org");
50 assert_true(ldb_dn_add_child_fmt(dn
,
53 assert_string_equal("DC=X,DC=Y,dc=samba,dc=org",
54 ldb_dn_get_linearized(dn
));
56 assert_string_equal("DC=X,DC=Y,DC=SAMBA,DC=ORG",
57 ldb_dn_get_casefold(dn
));
60 ldb_dn_get_comp_num(dn
));
64 static void test_ldb_dn_add_child_val(void **state
)
66 struct ldb_context
*ldb
= ldb_init(NULL
, NULL
);
68 struct ldb_dn
*dn
= ldb_dn_new(ldb
, ldb
, "dc=samba,dc=org");
69 struct ldb_val name
= {.data
= discard_const("X"),
73 assert_true(ldb_dn_add_child_val(dn
,
76 assert_string_equal("DC=X,dc=samba,dc=org",
77 ldb_dn_get_linearized(dn
));
79 assert_string_equal("DC=X,DC=SAMBA,DC=ORG",
80 ldb_dn_get_casefold(dn
));
84 static void test_ldb_dn_add_child_val2(void **state
)
86 struct ldb_context
*ldb
= ldb_init(NULL
, NULL
);
88 struct ldb_dn
*dn
= ldb_dn_new(ldb
, ldb
, "dc=samba,dc=org");
90 struct ldb_val name
= {.data
= discard_const("X,DC=Y"),
94 assert_true(ldb_dn_add_child_val(dn
,
97 assert_string_equal("DC=X\\,DC\\3DY,dc=samba,dc=org",
98 ldb_dn_get_linearized(dn
));
100 assert_string_equal("DC=X\\,DC\\3DY,DC=SAMBA,DC=ORG",
101 ldb_dn_get_casefold(dn
));
104 ldb_dn_get_comp_num(dn
));
109 const struct CMUnitTest tests
[] = {
110 cmocka_unit_test(test_ldb_dn_add_child_fmt
),
111 cmocka_unit_test(test_ldb_dn_add_child_fmt2
),
112 cmocka_unit_test(test_ldb_dn_add_child_val
),
113 cmocka_unit_test(test_ldb_dn_add_child_val2
),
116 return cmocka_run_group_tests(tests
, NULL
, NULL
);