1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MEDMEMTest.hxx"
23 #include <cppunit/TestAssert.h>
28 #include <MEDMEM_MedVersion.hxx>
29 #include "MEDMEM_Compatibility21_22.hxx"
32 using namespace MEDMEM;
33 using namespace MED_EN;
36 * Check methods (not in spec), defined in MEDMEM_MedVersion.hxx:
37 * (+) MED_EN::medFileVersion getMedFileVersion(const string & fileName) throw (MEDEXCEPTION);
38 * (+) int getMedAccessMode(MED_EN::med_mode_acces mode,
39 * MED_EN::medFileVersion medVersion) throw (MEDEXCEPTION);
42 void MEDMEMTest::testMedVersion()
44 string filename = getenv("MED_ROOT_DIR");
45 filename += "/share/salome/resources/med/pointe.med";
46 string notExistFileName = "anyfile";
47 medFileVersion myFileVersion;
48 medFileVersion myEmptyFileVersion;
50 // Test - getMedFileVersion
51 CPPUNIT_ASSERT_THROW(getMedFileVersion(notExistFileName),MEDEXCEPTION);
55 myFileVersion = getMedFileVersion(filename);
56 CPPUNIT_ASSERT(myFileVersion == V21);
58 catch(MEDEXCEPTION &e)
60 CPPUNIT_FAIL(e.what());
64 CPPUNIT_FAIL("Unknown exception");
67 //Test - getMedAccessMode
68 CPPUNIT_ASSERT_THROW(getMedAccessMode(RDWR,myEmptyFileVersion),MEDEXCEPTION);
72 CPPUNIT_ASSERT_EQUAL(med_2_1::MED_ECRI/*REMP*/,
73 (med_2_1::med_mode_acces)getMedAccessMode(RDWR,myFileVersion));
75 catch(MEDEXCEPTION &e)
77 CPPUNIT_FAIL(e.what());
81 CPPUNIT_FAIL("Unknown exception");