X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FTest%2FSauvLoaderTest.cxx;h=4fda6a2464aea2596ca99041441f55218a6df43c;hb=8c3dcf5940836637ac7bcb000049e833c5581eb7;hp=113633c734c9066b19a09792eea67f82e9b13703;hpb=de8da643a7f441fb2154818cde04b7b24ca76bb4;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Test/SauvLoaderTest.cxx b/src/MEDLoader/Test/SauvLoaderTest.cxx index 113633c73..4fda6a246 100644 --- a/src/MEDLoader/Test/SauvLoaderTest.cxx +++ b/src/MEDLoader/Test/SauvLoaderTest.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,9 +24,10 @@ #include "MEDFileData.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingMemArray.hxx" +#include "TestInterpKernelUtils.hxx" // getResourceFile() #ifdef WIN32 -# include +#include #else # include #endif @@ -39,12 +40,12 @@ using namespace ParaMEDMEM; void SauvLoaderTest::testSauv2Med() { // read a file containing all types of readable piles - std::string file = getResourceFile("allPillesTest.sauv"); + std::string file = INTERP_TEST::getResourceFile("allPillesTest.sauv", 3); MEDCouplingAutoRefCountObjectPtr sr=SauvReader::New(file.c_str()); MEDCouplingAutoRefCountObjectPtr d2=sr->loadInMEDFileDS(); // write MED d2->write("allPillesTest.med",0); - // check + // check CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfMeshes()); CPPUNIT_ASSERT_EQUAL(8+97,d2->getNumberOfFields()); MEDFileMesh * m = d2->getMeshes()->getMeshAtPos(0); @@ -113,10 +114,10 @@ void SauvLoaderTest::testMed2SauvOnAMeshWithVoidFamily() MEDCouplingAutoRefCountObjectPtr sr=SauvReader::New(sauvFile); MEDCouplingAutoRefCountObjectPtr d2=sr->loadInMEDFileDS(); MEDFileUMesh* m2 = static_cast( d2->getMeshes()->getMeshAtPos(0) ); - MEDCouplingAutoRefCountObjectPtr grp1 = m2->getGroup(0, "Group1"); - CPPUNIT_ASSERT_EQUAL(1,(int)grp1->getNumberOfCells()); - MEDCouplingAutoRefCountObjectPtr grp2 = m2->getGroup(0, "Group2"); - CPPUNIT_ASSERT_EQUAL(1,(int)grp2->getNumberOfCells()); + MEDCouplingAutoRefCountObjectPtr group1 = m2->getGroup(0, "Group1"); + CPPUNIT_ASSERT_EQUAL(1,(int)group1->getNumberOfCells()); + MEDCouplingAutoRefCountObjectPtr group2 = m2->getGroup(0, "Group2"); + CPPUNIT_ASSERT_EQUAL(1,(int)group2->getNumberOfCells()); MEDCouplingAutoRefCountObjectPtr grptot = m2->getGroup(0, "Grouptot"); CPPUNIT_ASSERT_EQUAL(2,(int)grptot->getNumberOfCells()); } @@ -124,7 +125,7 @@ void SauvLoaderTest::testMed2SauvOnAMeshWithVoidFamily() void SauvLoaderTest::testSauv2MedOnA3SubsField() { // read SAUV - std::string sauvFile = getResourceFile("portico_3subs.sauv"); + std::string sauvFile = INTERP_TEST::getResourceFile("portico_3subs.sauv", 3); MEDCouplingAutoRefCountObjectPtr sr=SauvReader::New(sauvFile.c_str()); MEDCouplingAutoRefCountObjectPtr d2=sr->loadInMEDFileDS(); // check mesh @@ -168,7 +169,7 @@ void SauvLoaderTest::testSauv2MedOnA3SubsField() void SauvLoaderTest::testMed2Sauv() { // read pointe.med - std::string file = getResourceFile("pointe.med"); + std::string file = INTERP_TEST::getResourceFile("pointe.med", 3); MEDCouplingAutoRefCountObjectPtr pointeMed=MEDFileData::New(file.c_str()); // add 3 faces to pointeMed @@ -249,14 +250,14 @@ void SauvLoaderTest::testMed2Sauv() CPPUNIT_ASSERT( std::find(groups.begin(),groups.end(),"groupe5") != groups.end() ); CPPUNIT_ASSERT( std::find(groups.begin(),groups.end(),"maa1") != groups.end() ); CPPUNIT_ASSERT_EQUAL(16,m->getSizeAtLevel(0)); - MEDCouplingAutoRefCountObjectPtr um0 = m->getGenMeshAtLevel(0); + MEDCouplingAutoRefCountObjectPtr um0 = m->getMeshAtLevel(0); CPPUNIT_ASSERT_EQUAL(12, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_TETRA4 )); CPPUNIT_ASSERT_EQUAL(2, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_PYRA5 )); CPPUNIT_ASSERT_EQUAL(2, um0->getNumberOfCellsWithType( INTERP_KERNEL::NORM_HEXA8 )); - MEDCouplingAutoRefCountObjectPtr um1 = m->getGenMeshAtLevel(-1); + MEDCouplingAutoRefCountObjectPtr um1 = m->getMeshAtLevel(-1); CPPUNIT_ASSERT_EQUAL(2, um1->getNumberOfCellsWithType( INTERP_KERNEL::NORM_TRI3 )); MEDCouplingAutoRefCountObjectPtr pointeUM0 = - static_cast( pointeMedMesh->getGenMeshAtLevel(0)); + static_cast( pointeMedMesh->getMeshAtLevel(0)); DataArrayDouble *coo = m->getCoords(); DataArrayDouble *pointeCoo = pointeMedMesh->getCoords(); CPPUNIT_ASSERT(coo->isEqualWithoutConsideringStr(*pointeCoo,1e-12)); @@ -306,7 +307,7 @@ void SauvLoaderTest::testMed2Sauv() } // "Field on 2 faces" MEDCouplingAutoRefCountObjectPtr fieldOnFaces = - dynamic_cast(d2->getFields()->getFieldWithName(f1->getName())); + dynamic_cast(d2->getFields()->getFieldWithName(f1->getName().c_str())); io1 = fieldOnFaces->getIterations(); MEDCouplingAutoRefCountObjectPtr fof = fieldOnFaces->getFieldOnMeshAtLevel(f1->getTypeOfField(),io1[0].first,io1[0].second,um1); @@ -327,28 +328,3 @@ void SauvLoaderTest::tearDown() remove(fileToRemove[i]); } } - -std::string SauvLoaderTest::getResourceFile( const std::string& filename ) -{ - std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make check' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; - } - resourceFile += filename; -#ifdef WIN32 - std::string fixedpath = resourceFile; - for ( int i=0; i < fixedpath.length(); ++i ) - if (fixedpath[i] == '/') - fixedpath[i] = '\\'; - return fixedpath; -#endif - return resourceFile; -}