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

« back to all changes in this revision

Viewing changes to src/lib/test-array.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2015-05-24 15:01:19 UTC
  • mto: (4.1.53 sid)
  • mto: This revision was merged to the branch mainline in revision 102.
  • Revision ID: package-import@ubuntu.com-20150524150119-hsh6cbr1fqseapga
Tags: upstream-2.2.18
ImportĀ upstreamĀ versionĀ 2.2.18

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
static void test_array_cmp(void)
127
127
{
128
128
        static const unsigned short deltas[] = {
129
 
                -32768, -16384, -512, -256, -128, -64, -2, -1,
 
129
                0x8000, 0xc000, 0xfe00, 0xff00, 0xff80, 0xffc0, 0xfffe, 0xffff,
130
130
                0, 1, 2, 64, 128, 256, 512, 16384, 32768
131
131
        };
132
132
 
151
151
 
152
152
        for (i = 0; i < 256; i++) {
153
153
                unsigned int j = rand() % NELEMS;
154
 
                unsigned short tmp = *array_idx(&arr2, j);
 
154
                const unsigned short *ptmp = array_idx(&arr2, j);
 
155
                unsigned short tmp = *ptmp;
155
156
                unsigned short repl = tmp + deltas[rand() % N_ELEMENTS(deltas)];
156
157
 
157
158
                array_idx_set(&arr2, j, &repl);
203
204
        test_assert(array_equal_fn(&arr1, &arr2, test_compare_string) == 1); /* therefore value same */
204
205
        for (i = 0; i < 2560; i++) {
205
206
                unsigned int j = rand() % NELEMS;
206
 
                const char *ostr = *array_idx(&arr2, j);
 
207
                const char *const *ostr_p = array_idx(&arr2, j);
 
208
                const char *ostr = *ostr_p;
207
209
                unsigned int olen = strlen(ostr);
208
210
                unsigned int rc = rand() % (olen + 1);
209
211
                char ochar = ostr[rc];