]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug correction
authorageay <ageay>
Fri, 12 Aug 2011 07:45:46 +0000 (07:45 +0000)
committerageay <ageay>
Fri, 12 Aug 2011 07:45:46 +0000 (07:45 +0000)
src/MEDLoader/MEDLoaderBase.cxx
src/MEDLoader/Test/MEDLoaderTest.cxx
src/MEDLoader/Test/MEDLoaderTest.hxx

index 20cd511f8a21c2c24a5e0e8b683b56028dfe0ca7..3ff67c2e378e035fd37f53d1faf969b60b21d4b2 100644 (file)
@@ -86,6 +86,11 @@ void MEDLoaderBase::splitIntoNameAndUnit(const std::string& s, std::string& name
 void MEDLoaderBase::strip(std::string& s)
 {
   std::string::size_type f1=s.find_first_not_of(' ');
+  if(f1==std::string::npos)
+    {
+      s="";
+      return ;
+    }
   std::string::size_type f2=s.find_last_not_of(' ');
   s=s.substr(f1,f2-f1+1);
 }
index 00bf51d14011476f313123e8c0b4885b01ccc929..ae93d5d1cf06aac24dfe525c0b529a8ac9d7fcdf 100644 (file)
@@ -495,6 +495,30 @@ void MEDLoaderTest::testLittleStrings1()
   CPPUNIT_ASSERT(s=="azertty");
 }
 
+void MEDLoaderTest::testSplitIntoNameAndUnit1()
+{
+  std::string s(" []");
+  std::string c,u;
+  MEDLoaderBase::splitIntoNameAndUnit(s,c,u);
+  CPPUNIT_ASSERT(c.empty());
+  CPPUNIT_ASSERT(u.empty());
+  s="   lmmm  kki jjj      ";
+  MEDLoaderBase::strip(s);
+  CPPUNIT_ASSERT(s=="lmmm  kki jjj");
+  s=" ";
+  MEDLoaderBase::strip(s);
+  CPPUNIT_ASSERT(s.empty());
+  s="";
+  MEDLoaderBase::strip(s);
+  CPPUNIT_ASSERT(s.empty());
+  s="      ";
+  MEDLoaderBase::strip(s);
+  CPPUNIT_ASSERT(s.empty());
+  s="     pp";
+  MEDLoaderBase::strip(s);
+  CPPUNIT_ASSERT(s=="pp");
+}
+
 void MEDLoaderTest::testMesh3DSurfShuffleRW()
 {
   const char fileName[]="file15.med";
index d91ebaaeab5f0f2229a2739192d5809cf37e3ece..4605e9e362c88c4554d8132efa388cc4e1690e77 100644 (file)
@@ -45,6 +45,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( testFieldGaussRW1 );
     CPPUNIT_TEST( testFieldGaussNERW1 );
     CPPUNIT_TEST( testLittleStrings1 );
+    CPPUNIT_TEST( testSplitIntoNameAndUnit1 );
     CPPUNIT_TEST( testMesh3DSurfShuffleRW );
     CPPUNIT_TEST( testFieldShuffleRW1 );
     CPPUNIT_TEST( testMultiFieldShuffleRW1 );
@@ -68,6 +69,7 @@ namespace ParaMEDMEM
     void testFieldGaussRW1();
     void testFieldGaussNERW1();
     void testLittleStrings1();
+    void testSplitIntoNameAndUnit1();
     void testMesh3DSurfShuffleRW();
     void testFieldShuffleRW1();
     void testMultiFieldShuffleRW1();