source: trunk/test/test_nxunlimited.c @ 1822

Revision 1792, 2.6 KB checked in by Freddie Akeroyd, 6 months ago (diff)

Fix constness of various functions. Refs #286

Line 
1/*---------------------------------------------------------------------------
2  NeXus - Neutron & X-ray Common Data Format
3 
4  Test program for C API
5 
6  Copyright (C) 1997-2009 Freddie Akeroyd
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21             
22  For further information, see <http://www.nexusformat.org>
23
24  $Id: napi_test.c 1178 2009-01-21 12:28:55Z Freddie Akeroyd $
25
26----------------------------------------------------------------------------*/
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <time.h>
31#include "napi.h"
32#include "napiconfig.h"
33
34#define DATA_SIZE 200000
35
36int test_unlimited(int file_type, const char* filename)
37{
38    static double d[DATA_SIZE];
39    int dims[2] = { NX_UNLIMITED, DATA_SIZE };
40    int i, slab_start[2], slab_size[2];
41    NXhandle file_id = NULL;
42      remove(filename);
43      NXopen (filename, file_type, &file_id);
44       NXmakegroup(file_id,"entry1","NXentry");
45       NXopengroup(file_id,"entry1","NXentry");
46          NXmakedata (file_id, "data", NX_FLOAT64, 2, dims);
47          NXopendata (file_id, "data");
48          slab_start[1] = 0;
49          slab_size[0] = 1;
50          slab_size[1] = DATA_SIZE;
51          for(i=0; i<2; i++)
52          {
53              slab_start[0] = i;
54              NXputslab (file_id, d, slab_start, slab_size);
55          }
56          NXclosedata (file_id);
57       NXclosegroup(file_id);
58      NXclose (&file_id);
59    return 0;
60}
61
62int main(int argc, char* argv[])
63{
64    time_t tim;
65    printf("Testing HDF4\n");
66    time(&tim);
67    test_unlimited(NXACC_CREATE4, "test_unlimited.nx4");
68    printf("Took %u seconds\n", (unsigned)(time(NULL) - tim));
69    printf("Testing XML\n");
70    time(&tim);
71    test_unlimited(NXACC_CREATEXML, "test_unlimited.xml");
72    printf("Took %u seconds\n", (unsigned)(time(NULL) - tim));
73    printf("Testing HDF5\n");
74    time(&tim);
75    test_unlimited(NXACC_CREATE5, "test_unlimited.nx5");
76    printf("Took %u seconds\n", (unsigned)(time(NULL) - tim));
77    return 0;
78}
Note: See TracBrowser for help on using the repository browser.