MED fichier
Unittest_MEDlibrary_1.c
Aller à la documentation de ce fichier.
1 /* This file is part of MED.
2  *
3  * COPYRIGHT (C) 1999 - 2023 EDF R&D, CEA/DEN
4  * MED is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * MED is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with MED. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * Unitary tests for MED library module
20  */
21 
22 #include <med.h>
23 #define MESGERR 1
24 #include <med_utils.h>
25 
26 #include <string.h>
27 
28 int main (int argc, char **argv)
29 {
30  med_int major,minor,release;
31  med_int majorFromStr, minorFromStr, releaseFromStr;
32  char version[11];
33 
34  /* Get library version numbers */
35  if (MEDlibraryNumVersion(&major,&minor,&release) < 0) {
36  MESSAGE("Error : library version numbers");
37  return -1;
38  }
39 
40  /* Get library version numbers in a string */
41  if (MEDlibraryStrVersion(version) < 0) {
42  MESSAGE("Error : library version numbers (in a string)");
43  return -1;
44  }
45  sscanf(version,"MED-"IFORMAT"."IFORMAT"."IFORMAT,
46  &majorFromStr,&minorFromStr,&releaseFromStr);
47  if ((major != majorFromStr) ||
48  (minor != minorFromStr) ||
49  (release != releaseFromStr)) {
50  MESSAGE("ERROR : The MED num version is not the good one");
51  SSCRUTE(version);
52  return -1;
53  }
54 
55  /* Get Hdf library version numbers */
56  if (MEDlibraryHdfNumVersion(&major,&minor,&release) < 0) {
57  MESSAGE("Error : Hdf library version numbers");
58  return -1;
59  }
60 
61  /* Get Hdf library version numbers in a string */
62  if (MEDlibraryHdfStrVersion(version) < 0) {
63  MESSAGE("Error : Hdf library version numbers (in a string)");
64  return -1;
65  }
66  sscanf(version,"HDF5-"IFORMAT"."IFORMAT"."IFORMAT,
67  &majorFromStr,&minorFromStr,&releaseFromStr);
68  if ((major != majorFromStr) ||
69  (minor != minorFromStr) ||
70  (release != releaseFromStr)) {
71  MESSAGE("ERROR : The HDF num version is not the good one");
72  SSCRUTE(version);ISCRUTE(major);ISCRUTE(minor);ISCRUTE(release);
73  return -1;
74  }
75 
76  /* flush all data and clean memory */
77  if (MEDlibraryClose() < 0) {
78  MESSAGE("ERROR : Med library close");
79  return -1;
80  }
81 
82  return 0;
83 
84 }
MEDlibraryStrVersion
MEDC_EXPORT med_err MEDlibraryStrVersion(char *const medversion)
Renvoie le numéro de version de la librairie MED dans une chaîne de caractères.
Definition: MEDlibraryStrVersion.c:33
main
int main(int argc, char **argv)
Definition: Unittest_MEDlibrary_1.c:28
MESSAGE
#define MESSAGE(chaine)
Definition: med_utils.h:324
med_int
int med_int
Definition: med.h:344
ISCRUTE
#define ISCRUTE(entier)
Definition: med_utils.h:313
MEDlibraryHdfStrVersion
MEDC_EXPORT med_err MEDlibraryHdfStrVersion(char *const version)
Renvoie le numéro de version de la librairie HDF utilisée par la bibliothèque MED dans une chaîne de ...
Definition: MEDlibraryHdfStrVersion.c:32
IFORMAT
#define IFORMAT
Definition: med_utils.h:145
MEDlibraryClose
MEDC_EXPORT med_err MEDlibraryClose(void)
Cette routine force l'écriture des données sur disque, nettoie la mémoire et ferme tous les fichiers ...
Definition: MEDlibraryClose.c:31
MEDlibraryNumVersion
MEDC_EXPORT med_err MEDlibraryNumVersion(med_int *const major, med_int *const minor, med_int *const release)
Renvoie les 3 numéros de version de la librairie MED.
Definition: MEDlibraryNumVersion.c:33
SSCRUTE
#define SSCRUTE(chaine)
Definition: med_utils.h:323
med_utils.h
med.h
MEDlibraryHdfNumVersion
MEDC_EXPORT med_err MEDlibraryHdfNumVersion(med_int *const major, med_int *const minor, med_int *const release)
Renvoie les 3 numéros de version de la librairie HDF5 utilisée par MED.
Definition: MEDlibraryHdfNumVersion.c:33