Unittest_MEDlibrary_1.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  EDF R&D, CEA/DEN
00004  *  MED is free software: you can redistribute it and/or modify
00005  *  it under the terms of the GNU Lesser General Public License as published by
00006  *  the Free Software Foundation, either version 3 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  MED is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Lesser General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Lesser General Public License
00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 /*
00019  * Unitary tests for MED library module
00020  */
00021 
00022 #include <med.h>
00023 #define MESGERR 1
00024 #include <med_utils.h>
00025 
00026 #include <string.h>
00027 
00028 int main (int argc, char **argv)
00029 {
00030   med_int major,minor,release;
00031   med_int majorFromStr, minorFromStr, releaseFromStr;
00032   char version[11];
00033 
00034   /* Get library version numbers */
00035   if (MEDlibraryNumVersion(&major,&minor,&release) < 0) {
00036     MESSAGE("Error : library version numbers");
00037     return -1;
00038   }
00039 
00040   /* Get library version numbers in a string */
00041   if (MEDlibraryStrVersion(version) < 0) {
00042     MESSAGE("Error : library version numbers (in a string)");
00043     return -1;
00044   }
00045   sscanf(version,"MED-"IFORMAT"."IFORMAT"."IFORMAT,
00046          &majorFromStr,&minorFromStr,&releaseFromStr);
00047   if ((major != majorFromStr) ||
00048       (minor != minorFromStr) ||
00049       (release != releaseFromStr)) {
00050     MESSAGE("ERROR : The MED num version is not the good one");
00051     SSCRUTE(version);
00052     return -1;
00053   }
00054 
00055   /* Get Hdf library version numbers */
00056   if (MEDlibraryHdfNumVersion(&major,&minor,&release) < 0) {
00057     MESSAGE("Error : Hdf library version numbers");
00058     return -1;
00059   }
00060 
00061   /* Get Hdf library version numbers in a string */
00062   if (MEDlibraryHdfStrVersion(version) < 0) {
00063     MESSAGE("Error : Hdf library version numbers (in a string)");
00064     return -1;
00065   }
00066   sscanf(version,"HDF5-"IFORMAT"."IFORMAT"."IFORMAT,
00067          &majorFromStr,&minorFromStr,&releaseFromStr);
00068   if ((major != majorFromStr) ||
00069       (minor != minorFromStr) ||
00070       (release != releaseFromStr)) {
00071     MESSAGE("ERROR : The HDF num version is not the good one");
00072     SSCRUTE(version);ISCRUTE(major);ISCRUTE(minor);ISCRUTE(release);
00073     return -1;
00074   }
00075 
00076   /* flush all data and clean memory */
00077   if (MEDlibraryClose() < 0) {
00078     MESSAGE("ERROR : Med library close");
00079     return -1;
00080   }
00081 
00082   return 0;
00083 
00084 }

Généré le Thu Oct 8 14:26:17 2015 pour MED fichier par  doxygen 1.6.1