~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib/test-bsearch-insert-pos.c

  • Committer: Package Import Robot
  • Author(s): Jaldhar H. Vyas
  • Date: 2013-09-09 00:57:32 UTC
  • mfrom: (1.13.11)
  • mto: (4.8.5 experimental) (1.16.1)
  • mto: This revision was merged to the branch mainline in revision 97.
  • Revision ID: package-import@ubuntu.com-20130909005732-dn1eell8srqbhh0e
Tags: upstream-2.2.5
ImportĀ upstreamĀ versionĀ 2.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2007-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "test-lib.h"
4
4
#include "bsearch-insert-pos.h"
5
5
 
6
 
static int cmp_uint(const void *p1, const void *p2)
 
6
static int cmp_uint(const unsigned int *i1, const unsigned int *i2)
7
7
{
8
 
        const unsigned int *i1 = p1, *i2 = p2;
9
 
 
10
 
        return *i1 - *i2;
 
8
        return (int)*i1 - (int)*i2;
11
9
}
12
10
 
13
11
void test_bsearch_insert_pos(void)
14
12
{
15
13
        static const unsigned int input[] = {
16
 
                1, 5, 9, 15, 16, -1U,
17
 
                1, 5, 9, 15, 16, 17, -1U,
18
 
                -1U
 
14
                1, 5, 9, 15, 16, UINT_MAX,
 
15
                1, 5, 9, 15, 16, 17, UINT_MAX,
 
16
                UINT_MAX
19
17
        };
20
18
        static const unsigned int max_key = 18;
21
19
        const unsigned int *cur;
23
21
        bool success;
24
22
 
25
23
        cur = input;
26
 
        for (i = 0; cur[0] != -1U; i++) {
27
 
                for (len = 0; cur[len] != -1U; len++) ;
 
24
        for (i = 0; cur[0] != UINT_MAX; i++) {
 
25
                for (len = 0; cur[len] != UINT_MAX; len++) ;
28
26
                for (key = 0; key < max_key; key++) {
29
27
                        if (bsearch_insert_pos(&key, cur, len, sizeof(*cur),
30
28
                                               cmp_uint, &idx))