]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
test on types after operations
authorasl <asl@opencascade.com>
Wed, 14 Oct 2015 11:27:14 +0000 (14:27 +0300)
committerasl <asl@opencascade.com>
Wed, 14 Oct 2015 11:27:14 +0000 (14:27 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index 2de0498dde73358be053a4b93afacbb6e31a7d6e..f384999d11989ae221cc289c50543da1c91bb8d3 100644 (file)
@@ -53,6 +53,17 @@ HYDROData_LandCoverMap::Iterator::Iterator( const HYDROData_LandCoverMap& theMap
   Init( theMap );
 }
 
+HYDROData_LandCoverMap::Iterator::Iterator( const Handle( HYDROData_LandCoverMap )& theMap )
+{
+  if( theMap.IsNull() )
+  {
+    myIterator = 0;
+    myIndex = -1;
+  }
+  else
+    Init( *theMap );
+}
+
 /**
   Initialize the iterator
   @param theMap the land cover map to iterate through
@@ -91,7 +102,10 @@ bool HYDROData_LandCoverMap::Iterator::More() const
 void HYDROData_LandCoverMap::Iterator::Next()
 {
   if( myIterator )
+  {
     myIterator->Next();
+    myIndex++;
+  }
 }
 
 /**
@@ -394,8 +408,10 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
   HYDROData_MapOfFaceToStricklerType::Iterator aNFIt( theMap );
   for( int i=0; aNFIt.More(); aNFIt.Next(), i++ )
   {
-    aCompoundBuilder.Add( aCompound, aNFIt.Key() );
-    aTypes->SetValue( i, HYDROData_Tool::toExtString( aNFIt.Value() ) );
+    TopoDS_Face aFace = aNFIt.Key();
+    QString aType = aNFIt.Value();
+    aCompoundBuilder.Add( aCompound, aFace );
+    aTypes->SetValue( i, HYDROData_Tool::toExtString( aType ) );
   }
 
   SetShape( aCompound );
index 0a53e7a1930c09c838146c2522d3f4a4f883ca47..ba5c5f685303fdcd5ba1921a634c2aa6bf1080ce 100644 (file)
@@ -49,6 +49,7 @@ public:
   {
   public:
     Iterator( const HYDROData_LandCoverMap& );
+    Iterator( const Handle( HYDROData_LandCoverMap )& );
     ~Iterator();
 
     void Init( const HYDROData_LandCoverMap& );
index e715c51d4d0409224677e93b282bf8e1fadd1a03..b2c3ac69534cdae00d138ae0a9ba00461bce8cf9 100644 (file)
@@ -20,6 +20,7 @@
 #include <HYDROData_Document.h>
 #include <HYDROData_LandCoverMap.h>
 #include <HYDROData_PolylineXY.h>
+#include <HYDROData_Tool.h>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Face.hxx>
@@ -85,7 +86,14 @@ void test_HYDROData_LandCoverMap::test_add_2_objects()
   TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
   TestViewer::AssertEqual( "LandCoverMap_Add_2_Objects" );
 
-  //TODO: check the types
+  HYDROData_LandCoverMap::Iterator anIt( aMap );
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.StricklerType() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
 
   aDoc->Close();
 }
@@ -113,7 +121,14 @@ void test_HYDROData_LandCoverMap::test_split_by_polyline()
   //TestViewer::show( aWire, QColor(), 0 );
   TestViewer::AssertEqual( "LandCoverMap_Split_1" );
 
-  //TODO: check the types
+  HYDROData_LandCoverMap::Iterator anIt( aMap );
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.StricklerType() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
 
   aDoc->Close();
 }