ctdb-daemon: Use ctdb_parse_node_address() in ctdbd
[samba4-gss.git] / lib / ldb / tests / test_ldb_qsort.c
blobbaaad7afe927bdae29606573a988c7b3968e8fb8
1 /*
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/>.
20 #include <stdarg.h>
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <setjmp.h>
24 #include <cmocka.h>
26 #include <ldb.h>
28 static int cmp_integer(int *a, int *b, void *opaque)
30 if (a == NULL || b == NULL) {
31 return 0;
34 if (*a > *b) {
35 return 1;
38 if (*a < *b) {
39 return -1;
42 return 0;
45 static void test_ldb_qsort(void **state)
47 int a[6] = { 6, 3, 2, 7, 9, 4 };
49 ldb_qsort(a, 6, sizeof(int), NULL, (ldb_qsort_cmp_fn_t)cmp_integer);
51 assert_int_equal(a[0], 2);
52 assert_int_equal(a[1], 3);
53 assert_int_equal(a[2], 4);
54 assert_int_equal(a[3], 6);
55 assert_int_equal(a[4], 7);
56 assert_int_equal(a[5], 9);
59 int main(void) {
60 const struct CMUnitTest tests[] = {
61 cmocka_unit_test(test_ldb_qsort),
64 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
65 return cmocka_run_group_tests(tests, NULL, NULL);