File: cpl_array-test.c

package info (click to toggle)
cpl 7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 21,240 kB
  • sloc: ansic: 126,133; sh: 4,181; makefile: 640
file content (585 lines) | stat: -rw-r--r-- 19,342 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/* $Id: cpl_array-test.c,v 1.75 2013-04-23 13:15:35 llundin Exp $
 *
 * This file is part of the ESO Common Pipeline Library
 * Copyright (C) 2001-2008 European Southern Observatory
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/*
 * $Author: llundin $
 * $Date: 2013-04-23 13:15:35 $
 * $Revision: 1.75 $
 * $Name: not supported by cvs2svn $
 */

/*-----------------------------------------------------------------------------
                                   Includes
 -----------------------------------------------------------------------------*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "cpl_array.h"
#include "cpl_math_const.h"

#include "cpl_test.h"

#include <complex.h>

/*----------------------------------------------------------------------------
                 Function prototypes
 ----------------------------------------------------------------------------*/

static void cpl_array_test_set_string(void);
static void cpl_array_test_power(void);
static void cpl_array_test_power_complex(void);
static void cpl_array_test_power_valid(cpl_array *, double, double, double)
    CPL_ATTR_NONNULL;
static void cpl_array_test_power_complex_one(cpl_array *, double,
                                         double complex,
                                         double complex) CPL_ATTR_NONNULL;
static void cpl_array_test_power_invalid(cpl_array *, double, double)
    CPL_ATTR_NONNULL;

static void cpl_array_test_new_complex(void);

/*-----------------------------------------------------------------------------
                                  Main
 -----------------------------------------------------------------------------*/

int main(void)
{

    FILE        * stream;


    cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);

    stream = cpl_msg_get_level() > CPL_MSG_INFO
        ? fopen("/dev/null", "a") : stdout;

    /* Testing begins here */

    cpl_test_nonnull( stream );

    cpl_array_dump_structure(NULL, stream);
    cpl_array_dump(NULL, 1, 1, stream);

    cpl_array_test_power();
    cpl_array_test_power_complex();

    cpl_array_test_set_string();

    cpl_array_test_new_complex();

    if (stream != stdout) cpl_test_zero( fclose(stream) );

    /* End of tests */
    return cpl_test_end(0);
}


/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test the cpl_array function
  @see cpl_array_power

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_power_complex(void)
{

    const cpl_type num_type[] = {CPL_TYPE_FLOAT_COMPLEX,
                                 CPL_TYPE_DOUBLE_COMPLEX};
    const size_t ntype = sizeof(num_type)/sizeof(num_type[0]);

    cpl_array *myarray;

    cpl_error_code code;

    code = cpl_array_power_complex(NULL, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);

    myarray = cpl_array_new(1, CPL_TYPE_STRING);

    code = cpl_array_power_complex(myarray, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_INVALID_TYPE);

    code = cpl_array_set_string(myarray, 0, "I am a string");

    code = cpl_array_power_complex(myarray, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_INVALID_TYPE);

    cpl_array_delete(myarray);

    for (size_t i = 0; i < ntype; i++) {
        const cpl_type mytype = num_type[i];

        cpl_msg_info(cpl_func, "Type: %s", cpl_type_get_name(mytype));

        myarray = cpl_array_new(1, mytype);
        cpl_test_nonnull(myarray);

        /* e^(i * pi) is -1, see man cpow() */
        cpl_array_test_power_complex_one(myarray, CPL_MATH_E,
                                         CPL_MATH_PI * I, -1.0);
        /* e^(i * pi/2) is i, see man cpow() */
        cpl_array_test_power_complex_one(myarray, CPL_MATH_E,
                                         CPL_MATH_PI_2 * I, I);
        cpl_array_delete(myarray);
    }

    return;
}


/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test the cpl_array function
  @see cpl_array_power

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_power(void)
{

    const cpl_type num_type[] = {CPL_TYPE_INT,
                                 CPL_TYPE_LONG,
                                 CPL_TYPE_LONG_LONG,
                                 CPL_TYPE_SIZE,
                                 CPL_TYPE_FLOAT,
                                 CPL_TYPE_FLOAT_COMPLEX,
                                 CPL_TYPE_DOUBLE,
                                 CPL_TYPE_DOUBLE_COMPLEX};
    const size_t ntype = sizeof(num_type)/sizeof(num_type[0]);

    cpl_array *myarray;

    cpl_error_code code;

    code = cpl_array_power(NULL, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_NULL_INPUT);

    myarray = cpl_array_new(1, CPL_TYPE_STRING);

    code = cpl_array_power(myarray, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_INVALID_TYPE);

    code = cpl_array_set_string(myarray, 0, "I am a string");

    code = cpl_array_power(myarray, 1.0);
    cpl_test_eq_error(code, CPL_ERROR_INVALID_TYPE);

    cpl_array_delete(myarray);

    for (size_t i = 0; i < ntype; i++) {
        const cpl_type mytype = num_type[i];

        cpl_msg_info(cpl_func, "Type: %s", cpl_type_get_name(mytype));

        myarray = cpl_array_new(1, mytype);
        cpl_test_nonnull(myarray);

        /* 2^2 is 4, see man pow() */
        cpl_array_test_power_valid(myarray, 2.0, 2.0, 4.0);

        /* 0.5^2 is 0.25, see man pow() (rounded to zero for int types) */
        if (mytype == CPL_TYPE_FLOAT || mytype == CPL_TYPE_DOUBLE)
            cpl_array_test_power_valid(myarray, 0.5, 2.0, 0.25);
        else
            cpl_array_test_power_valid(myarray, 0.5, 2.0, 0.0);

        /* 8^(1/3) is 2, see man pow() */
        cpl_array_test_power_valid(myarray, 8.0, 1.0/3.0, 2.0);

        /* 16^(1/4) is 2, see man pow() */
        cpl_array_test_power_valid(myarray, 16.0, 0.25, 2.0);

        /* 0^0 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, 0.0, 0.0, 1.0);

        /* 0^1 is 0, see man pow() */
        cpl_array_test_power_valid(myarray, 0.0, 1.0, 0.0);

        /* 0^-1 is invalid, see man pow() */
        cpl_array_test_power_invalid(myarray, 0.0, -1.0);

        /* 0^-0.5 is invalid, see man pow() */
        cpl_array_test_power_invalid(myarray, 0.0, -0.5);

        /* -2^0 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, -2.0, 0.0, 1.0);

        /* 2^0 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, 2.0, 0.0, 1.0);

        /* -2^1 is -2, see man pow() */
        cpl_array_test_power_valid(myarray, -2.0, 1.0, -2.0);

        /* -2^2 is 4, see man pow() */
        cpl_array_test_power_valid(myarray, -2.0, 2.0, 4.0);

        /* -0.5^2 is 0.25, see man pow() (rounded to zero for int types) */
        if (mytype == CPL_TYPE_FLOAT || mytype == CPL_TYPE_DOUBLE)
            cpl_array_test_power_valid(myarray, -0.5, 2.0, 0.25);
        else
            cpl_array_test_power_valid(myarray, -0.5, 2.0, 0.0);

        /* 256^-(1/4) is 1/4, see man pow()
           - (rounded to 1 for int types) */
        if (mytype & (CPL_TYPE_FLOAT | CPL_TYPE_DOUBLE)) {
            cpl_array_test_power_valid(myarray, 256.0, -0.25, 0.25);
        } else {
            cpl_array_test_power_valid(myarray, 256.0, -0.25, 0.0);
        }

        /* -1^2 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, -1.0, 2.0, 1.0);

        /* -1^3 is -1, see man pow() */
        cpl_array_test_power_valid(myarray, -1.0, 3.0, -1.0);

        /* -1^-1 is -1, see man pow() */
        cpl_array_test_power_valid(myarray, -1.0, -1.0, -1.0);

        /* -1^0.5 is i or invalid (for non-complex), see man pow() */
        cpl_array_test_power_complex_one(myarray, -1.0, 0.5, 1.0 * I);

        /* -4^-0.5 is -0.5i or invalid (for non-complex), see man pow() */
        cpl_array_test_power_complex_one(myarray, -4.0, -0.5, -0.5 * I);

        /* -4^0.5 is 2i or invalid (for non-complex), see man pow() */
        cpl_array_test_power_complex_one(myarray, -4.0, 0.5, 2.0 * I);

        /* -4^0.25 is 1+i or invalid (for non-complex), see man pow() */
        cpl_array_test_power_complex_one(myarray, -4.0, 0.25, 1.0 + 1.0 * I);

        /* -4^-0.25 is 0.5-0.5i or invalid (for non-complex), see man pow() */
        cpl_array_test_power_complex_one(myarray, -4.0, -0.25, 0.5 - 0.5 * I);

        /* 1^-1 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, 1.0, -1.0, 1.0);

        /* 1^-2 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, 1.0, -2.0, 1.0);

        /* 1^-0.5 is 1, see man pow() */
        cpl_array_test_power_valid(myarray, 1.0, -0.5, 1.0);

        /* 2^-1 is 0.5, see man pow() */
        if (mytype == CPL_TYPE_FLOAT || mytype == CPL_TYPE_DOUBLE)
            cpl_array_test_power_valid(myarray, 2.0, -1.0, 0.5);
        else
            cpl_array_test_power_valid(myarray, 2.0, -1.0, 1.0);

        /* 4^-0.5 is 0.5, see man pow() */
        if (mytype == CPL_TYPE_FLOAT || mytype == CPL_TYPE_DOUBLE)
            cpl_array_test_power_valid(myarray, 4.0, -0.5, 0.5);
        else
            cpl_array_test_power_valid(myarray, 4.0, -0.5, 1.0);

        cpl_array_delete(myarray);
    }

    return;

}


/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test the cpl_array_power for a single valid value, x^y
  @param    self   The array (of a numerical type) to work with
  @param    x      Base
  @param    y      Power
  @param    result Expected result
  @see cpl_array_power

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_power_valid(cpl_array *self, double x, double y,
                                       double result)
{

    const cpl_type mytype = cpl_array_get_type(self);
    int            isvalid;
    cpl_error_code code;

    code = cpl_array_set(self, 0, x);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    code = cpl_array_power(self, y);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    isvalid = cpl_array_is_valid(self, 0);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_eq(isvalid, 1);

    if ((mytype & CPL_TYPE_COMPLEX) == 0) {
        int isnull;
        const double value = cpl_array_get(self, 0, &isnull);

        cpl_test_error(CPL_ERROR_NONE);
        cpl_test_zero(isnull);
        cpl_test_abs(value, result, 0.0);
    }

}

/*----------------------------------------------------------------------------*/
static void cpl_array_test_power_complex_one(cpl_array *self, double x,
                                             double complex y,
                                             double complex result)
{

    const cpl_type mytype = cpl_array_get_type(self);
    int            isvalid;
    cpl_array*     acopy;
    cpl_error_code code;

    code = cpl_array_set(self, 0, x);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    acopy = cpl_array_duplicate(self);

    code = cpl_array_power(self, (double)y);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    isvalid = cpl_array_is_valid(self, 0);
    cpl_test_error(CPL_ERROR_NONE);

    code = cpl_array_power_complex(acopy, y);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    isvalid = cpl_array_is_valid(acopy, 0);
    cpl_test_error(CPL_ERROR_NONE);

    if ((mytype & CPL_TYPE_COMPLEX) == 0) {
        int isnull;
        /* cpl_array_get() returns zero, when the value is invalid,
           we would need to use cpl_array_get_data_float_const() to
           verify that the function did not actually modify the value */
        const double value = cpl_array_get(self, 0, &isnull);

        cpl_test_zero(isvalid);

        cpl_test_error(CPL_ERROR_NONE);
        cpl_test_eq(isnull, 1);
        cpl_test_abs(value, 0.0, 0.0);
        if (mytype == CPL_TYPE_FLOAT) {
            const float * fptr = cpl_array_get_data_float_const(self);
            cpl_test_abs(fptr[0], x, 0.0);
        }

        cpl_test_array_abs(self, acopy, 0.0);
    } else {
        int isnull, isnull2;
        const double complex value  = cpl_array_get_complex(self, 0, &isnull);
        const double complex value2 = cpl_array_get_complex(acopy, 0, &isnull2);

        cpl_test_eq(isvalid, 1);

        cpl_test_error(CPL_ERROR_NONE);
        cpl_test_zero(isnull);
        cpl_test_zero(isnull2);
        if (!(y != (double)y))
            cpl_test_abs_complex(value, result, mytype & CPL_TYPE_FLOAT
                                 ? FLT_EPSILON : DBL_EPSILON);
        cpl_test_abs_complex(value2, result, mytype & CPL_TYPE_FLOAT
                             ? 2.0 * FLT_EPSILON : DBL_EPSILON);
    }
    cpl_array_delete(acopy);
}

/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test the cpl_array_power for a single invalid value
  @param    self   The array (of a numerical type) to work with
  @param    x      Base
  @param    y      Power
  @see cpl_array_power

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_power_invalid(cpl_array *self, double x, double y)
{
    const cpl_type mytype = cpl_array_get_type(self);
    int            isvalid;
    cpl_error_code code;

    code = cpl_array_set(self, 0, x);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    code = cpl_array_power(self, y);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    isvalid = cpl_array_is_valid(self, 0);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_zero(isvalid);

    code = cpl_array_power_complex(self, y);
    cpl_test_eq_error(code, CPL_ERROR_NONE);

    isvalid = cpl_array_is_valid(self, 0);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_zero(isvalid);

    if ((mytype & CPL_TYPE_COMPLEX) == 0) {
        int isnull;
        /* cpl_array_get() returns zero, when the value is invalid,
           we would need to use cpl_array_get_data_float_const() to
           verify that the function did not actually modify the value */
        const double value = cpl_array_get(self, 0, &isnull);

        cpl_test_error(CPL_ERROR_NONE);
        cpl_test_eq(isnull, 1);
        cpl_test_abs(value, 0.0, 0.0);
        if (mytype == CPL_TYPE_FLOAT) {
            const float * fptr = cpl_array_get_data_float_const(self);
            cpl_test_abs(fptr[0], x, 0.0);
        }
    }
}

/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test the cpl_array_set_string() for out-of-bounds input
  @param    self   The array (of a numerical type) to work with
  @param    x      Base
  @param    y      Power
  @see cpl_array_power

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_set_string(void)
{
    cpl_array    * self = cpl_array_new(1, CPL_TYPE_STRING);
    cpl_error_code code;

    cpl_test_nonnull(self);

    code = cpl_array_set_string(self, 2, "test");
    cpl_test_eq_error(code, CPL_ERROR_ACCESS_OUT_OF_RANGE);

    code = cpl_array_fill_window_string(self, 1, 2, "test");
    cpl_test_eq_error(code, CPL_ERROR_ACCESS_OUT_OF_RANGE);

    cpl_array_delete(self);

}


/*----------------------------------------------------------------------------*/
/**
  @internal
  @brief    Test cpl_array_new_complex_from_arrays()
  @see cpl_array_new_complex_from_arrays()

 */
/*----------------------------------------------------------------------------*/
static void cpl_array_test_new_complex(void)
{

    double darray[] = {1.0, 2.0};
    float  farray[] = {1.0, 2.0};
    cpl_array *null;
    cpl_array *aint    = cpl_array_new(1, CPL_TYPE_INT);
    cpl_array *adouble = cpl_array_new(1, CPL_TYPE_DOUBLE);
    cpl_array *afloat  = cpl_array_new(2, CPL_TYPE_FLOAT);
    cpl_array *acomp;

    cpl_test_nonnull(aint);
    cpl_test_nonnull(adouble);
    cpl_test_nonnull(afloat);

    null = cpl_array_new_complex_from_arrays(NULL, NULL);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_null(null);

    null = cpl_array_new_complex_from_arrays(NULL, adouble);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_null(null);

    null = cpl_array_new_complex_from_arrays(adouble, NULL);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_null(null);

    null = cpl_array_new_complex_from_arrays(aint, aint);
    cpl_test_error(CPL_ERROR_INVALID_TYPE);
    cpl_test_null(null);

    null = cpl_array_new_complex_from_arrays(adouble, aint);
    cpl_test_error(CPL_ERROR_INVALID_TYPE);
    cpl_test_null(null);

    null = cpl_array_new_complex_from_arrays(adouble, afloat);
    cpl_test_error(CPL_ERROR_INCOMPATIBLE_INPUT);
    cpl_test_null(null);

    acomp = cpl_array_new_complex_from_arrays(adouble, adouble);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_nonnull(acomp);
    cpl_test_eq(cpl_array_get_size(acomp), cpl_array_get_size(adouble));
    cpl_test_eq(cpl_array_get_type(acomp),
                cpl_array_get_type(adouble) | CPL_TYPE_COMPLEX);
    cpl_test_eq(cpl_array_count_invalid(acomp),
                cpl_array_count_invalid(adouble));
    cpl_array_delete(acomp);

    acomp = cpl_array_new_complex_from_arrays(afloat, afloat);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_nonnull(acomp);
    cpl_test_eq(cpl_array_get_size(acomp), cpl_array_get_size(afloat));
    cpl_test_eq(cpl_array_get_type(acomp),
                cpl_array_get_type(afloat) | CPL_TYPE_COMPLEX);
    cpl_test_eq(cpl_array_count_invalid(acomp),
                cpl_array_count_invalid(afloat));
    cpl_array_delete(acomp);

    cpl_array_delete(adouble);
    cpl_array_delete(afloat);
    cpl_array_delete(aint);

    adouble = cpl_array_wrap_double(darray, 2);
    afloat  = cpl_array_wrap_float(farray, 2);

    acomp = cpl_array_new_complex_from_arrays(adouble, adouble);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_nonnull(acomp);
    cpl_test_eq(cpl_array_get_size(acomp), cpl_array_get_size(adouble));
    cpl_test_eq(cpl_array_get_type(acomp),
                cpl_array_get_type(adouble) | CPL_TYPE_COMPLEX);
    cpl_test_zero(cpl_array_count_invalid(acomp));
    cpl_array_delete(acomp);

    acomp = cpl_array_new_complex_from_arrays(afloat, afloat);
    cpl_test_error(CPL_ERROR_NONE);
    cpl_test_nonnull(acomp);
    cpl_test_eq(cpl_array_get_size(acomp), cpl_array_get_size(afloat));
    cpl_test_eq(cpl_array_get_type(acomp),
                cpl_array_get_type(afloat) | CPL_TYPE_COMPLEX);
    cpl_test_zero(cpl_array_count_invalid(acomp));
    cpl_array_delete(acomp);

    cpl_test_eq_ptr(cpl_array_unwrap(adouble), darray);
    cpl_test_eq_ptr(cpl_array_unwrap(afloat), farray);
}