From 69d34b8c8738dabdf6cf814d0b4796af48f0d18d Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 14 Oct 2015 14:27:14 +0300 Subject: [PATCH] test on types after operations --- src/HYDROData/HYDROData_LandCoverMap.cxx | 20 +++++++++++++++++-- src/HYDROData/HYDROData_LandCoverMap.h | 1 + .../test_HYDROData_LandCoverMap.cxx | 19 ++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index 2de0498d..f384999d 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -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 ); diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index 0a53e7a1..ba5c5f68 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -49,6 +49,7 @@ public: { public: Iterator( const HYDROData_LandCoverMap& ); + Iterator( const Handle( HYDROData_LandCoverMap )& ); ~Iterator(); void Init( const HYDROData_LandCoverMap& ); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index e715c51d..b2c3ac69 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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(); } -- 2.39.2