X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_Profile.cxx;h=ee40097ffef461b39c7e7436083941421065fce5;hb=1ad3406d04aa81800693d6811c7c36e87e0c95c1;hp=cc3d3da00660a056f8124fbba4350e34903a937b;hpb=6527cd5d3063b2724b60b3f87ed1105244b74cb3;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_Profile.cxx b/src/HYDRO_tests/test_HYDROData_Profile.cxx index cc3d3da0..ee40097f 100644 --- a/src/HYDRO_tests/test_HYDROData_Profile.cxx +++ b/src/HYDRO_tests/test_HYDROData_Profile.cxx @@ -31,8 +31,10 @@ #include #include #include +#include const double EPS = 1E-2; +extern QString REF_DATA_PATH; bool test_HYDROData_Profile::createTestFile( const QString& theFileName, const bool theIsParametric ) @@ -87,7 +89,7 @@ void test_HYDROData_Profile::testFileImport() TCollection_AsciiString aFileName( aParamFileName.toStdString().c_str() ); NCollection_Sequence aBadProfilesList; - CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName, aBadProfilesList ) ); + CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName, aBadProfilesList, true ) ); int aProfileCount = 0; HYDROData_Iterator aDocIter( aDoc, KIND_PROFILE ); @@ -110,7 +112,9 @@ void test_HYDROData_Profile::testFileImport() Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aFileName = TCollection_AsciiString( aGeorefFileName.toStdString().c_str() ); - CPPUNIT_ASSERT( aGeorefProfile->ImportFromFile( aFileName ) ); + bool notEmpty = false; + CPPUNIT_ASSERT( aGeorefProfile->ImportFromFile( aFileName, true, ¬Empty ) ); + CPPUNIT_ASSERT( notEmpty ); // Check validity of imported profile CPPUNIT_ASSERT( aGeorefProfile->IsValid() ); @@ -145,8 +149,10 @@ void test_HYDROData_Profile::testCopy() if ( anIsFileCreated ) { + bool notEmpty = false; TCollection_AsciiString anAsciiFileName( aFileName.toStdString().c_str() ); - CPPUNIT_ASSERT( aProfile1->ImportFromFile( anAsciiFileName ) ); + CPPUNIT_ASSERT( aProfile1->ImportFromFile( anAsciiFileName, true, ¬Empty ) ); + CPPUNIT_ASSERT( notEmpty ); CPPUNIT_ASSERT( aProfile1->IsValid() ); CPPUNIT_ASSERT( aProfile1->NbPoints() == 5 ); @@ -165,3 +171,59 @@ void test_HYDROData_Profile::testCopy() aDoc->Close(); } + +void operator << ( std::ostream& s, const gp_XYZ& p ) +{ + s << "(" << p.X() << "; " << p.Y() << "; " << p.Z() << ") "; +} + +bool operator == ( const gp_XYZ& p1, const gp_XYZ& p2 ) +{ + return fabs(p1.X()-p2.X()) aBadProfilesList; + CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName, aBadProfilesList, false ) ); + CPPUNIT_ASSERT( HYDROData_Profile::ImportFromFile( aDoc, aFileName, aBadProfilesList, true ) ); + + HYDROData_Iterator it( aDoc, KIND_PROFILE ); + CPPUNIT_ASSERT( it.More() ); + Handle(HYDROData_Profile) p1 = Handle(HYDROData_Profile)::DownCast( it.Current() ); it.Next(); + CPPUNIT_ASSERT( it.More() ); + Handle(HYDROData_Profile) p2 = Handle(HYDROData_Profile)::DownCast( it.Current() ); it.Next(); + CPPUNIT_ASSERT( !it.More() ); + + CPPUNIT_ASSERT_EQUAL( QString( "Profile_1" ), p1->GetName() ); + CPPUNIT_ASSERT_EQUAL( QString( "Profile_2" ), p2->GetName() ); + + HYDROData_Profile::ProfilePoints pp1 = p1->GetProfilePoints(); + int low1 = pp1.Lower(), up1 = pp1.Upper(); + CPPUNIT_ASSERT_EQUAL( 1, low1 ); + CPPUNIT_ASSERT_EQUAL( 6, up1 ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 1.0, 2.0, 5.0 ), pp1.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 2.04019, 4.0838, 4.0 ), pp1.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 2.9601, 5.9202, 3.0 ), pp1.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 4.08026, 8.16052, 3.0 ), pp1.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 4.9202, 9.84041, 4.0 ), pp1.Value( 5 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 6.0, 12.0, 5.0 ), pp1.Value( 6 ) ); + + HYDROData_Profile::ProfilePoints pp2 = p2->GetProfilePoints(); + int low2 = pp2.Lower(), up2 = pp2.Upper(); + CPPUNIT_ASSERT_EQUAL( 1, low2 ); + CPPUNIT_ASSERT_EQUAL( 6, up2 ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 1.0, 2.0, 5.0 ), pp2.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 2.04019, 4.0838, 4.0 ), pp2.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 2.9601, 5.9202, 3.0 ), pp2.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 4.08, 8.16, 3.0 ), pp2.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 4.92, 9.84, 4.0 ), pp2.Value( 5 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XYZ( 6.0, 12.0, 5.0 ), pp2.Value( 6 ) ); + + aDoc->Close(); +}