File: irplib_framelist-test.c

package info (click to toggle)
cpl-plugin-vimos 4.1.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 28,228 kB
  • sloc: ansic: 169,271; cpp: 16,177; sh: 4,344; python: 3,678; makefile: 1,138; perl: 10
file content (117 lines) | stat: -rw-r--r-- 3,940 bytes parent folder | download | duplicates (37)
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
/*                                                                            *
 *   This file is part of the ESO IRPLIB package                              *
 *   Copyright (C) 2004,2005 European Southern Observatory                    *
 *                                                                            *
 *   This library 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, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA     *
 *                                                                            */
 
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

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

#include <irplib_framelist.h>


/*----------------------------------------------------------------------------*/
/**
 * @defgroup irplib_framelist_test Testing of the IRPLIB framelist object
 */
/*----------------------------------------------------------------------------*/


/*----------------------------------------------------------------------------*/
/**
   @brief   Unit tests of framelist module
**/
/*----------------------------------------------------------------------------*/

int main(void)
{

    irplib_framelist * flist;
    irplib_framelist * nulllist;
    cpl_frame        * frm;
    cpl_frameset     * fset;
    cpl_frameset     * nullset;
    int i;

    /* Initialize CPL for unit testing */
    cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);

    /* Some NULL tests */

    irplib_framelist_delete(NULL);
    cpl_test_error(CPL_ERROR_NONE);

    nulllist = irplib_framelist_cast(NULL);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_null(nulllist);

    nullset = irplib_frameset_cast(NULL);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_null(nullset);

    irplib_framelist_empty(NULL);
    cpl_test_error(CPL_ERROR_NONE);

    i = irplib_framelist_get_size(NULL);
    cpl_test_error(CPL_ERROR_NULL_INPUT);
    cpl_test_leq(i, -1);


    /* Some tests on an empty list */
    flist = irplib_framelist_new();

    cpl_test_zero(irplib_framelist_get_size(flist));

    irplib_framelist_empty(flist);

    cpl_test_zero(irplib_framelist_get_size(flist));

    fset = irplib_frameset_cast(flist);

    irplib_framelist_delete(flist);

    flist = irplib_framelist_cast(fset);

    cpl_test_zero(irplib_framelist_get_size(flist));

    irplib_framelist_delete(flist);

    frm = cpl_frame_new();
    cpl_frame_set_filename(frm, "test.fits");
    cpl_frame_set_tag(frm, "TEST");
    cpl_frameset_insert(fset, frm);

    flist = irplib_framelist_cast(fset);

    cpl_test_eq(irplib_framelist_get_size(flist), 1);

    irplib_framelist_delete(flist);

    cpl_frameset_insert(fset, cpl_frame_duplicate(frm));
    flist = irplib_framelist_cast(fset);

    cpl_test_eq(irplib_framelist_get_size(flist), 2);

    cpl_frameset_delete(fset);
    irplib_framelist_delete(flist);

    return cpl_test_end(0);
}