Salome HOME
implementation of the strickler types (integer codes) for points
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_Bathymetry.cxx
index 28a22cfe4d62f2eec8a5e115673576a9219bbeb7..1c0fc6edaef330264ede9456b75f64278ca925f3 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <gp_XY.hxx>
 #include <gp_XYZ.hxx>
-#include <random.h>
 
 #include <QDir>
 #include <QFile>
@@ -46,7 +45,7 @@ void generateOne( QTextStream& theStream,
   {
     double anX = theFirstX * (1-t) + theLastX * t;
     double anY = theFirstY * (1-t) + theLastY * t;
-    double aZ = aStepZ * aStepZ + sin( (float)rand() );
+    double aZ = aStepZ * aStepZ + sin( 10*t );
     theStream << anX << " " << anY << " " << aZ << " \n";
 
     aStepZ += 0.2;
@@ -62,7 +61,6 @@ bool test_HYDROData_Bathymetry::createTestFile( const QString& theFileName )
   {
     QTextStream anOutStream( &aTmpFile );
 
-    test_srand( 4587 );
     generateOne( anOutStream, 0, 5, 0, -5 );
     generateOne( anOutStream, 10, 5, 10, -5 );
     generateOne( anOutStream, 20, 5, 20, -5 );
@@ -109,7 +107,6 @@ bool test_HYDROData_Bathymetry::createTestFile( const QString& theFileName )
     generateOne( anOutStream, 1040.079834, -441.303467, 1017.623413, -459.9102175 );
     generateOne( anOutStream, 1055.478516, -456.060547, 1034.946899, -475.9505 );
     generateOne( anOutStream, 1074.085327, -474.025665, 1058.044922, -493.274017 );
-    test_srand( 0 );
   }
 
   aTmpFile.close();
@@ -128,34 +125,34 @@ void test_HYDROData_Bathymetry::testFileImport()
   if ( !createTestFile( aFileName ) )
     return; // No file has been created
 
-  CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName.toStdString().c_str() ) );
+  CPPUNIT_ASSERT( aBathymetry->ImportFromFiles( QStringList(aFileName)) );
 
   HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
-  CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
+  CPPUNIT_ASSERT_EQUAL( 2300, (int)anAltitudePoints.size() );
 
   gp_XY aTestPoint( 1, 1 );
-  double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.9186, anAltitude, EPS );
+  double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.2432, anAltitude, EPS );
 
   aTestPoint = gp_XY( 0.5, 0.5 );
-  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.3452, anAltitude, EPS );
+  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.591602, anAltitude, EPS );
 
   aTestPoint = gp_XY( 1.5, 1 );
-  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.9157, anAltitude, EPS );
+  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.2432, anAltitude, EPS );
 
   aTestPoint = gp_XY( 1.5, 0.7 );
-  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.8782, anAltitude, EPS );
+  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.591602, anAltitude, EPS );
 
   aTestPoint = gp_XY( 1.5, -0.7 );
-  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.9678, anAltitude, EPS );
+  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( -0.271267, anAltitude, EPS );
 
   aTestPoint = gp_XY( 2, 3.5 );
-  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
-  CPPUNIT_ASSERT_DOUBLES_EQUAL( 12.4364, anAltitude, EPS );
+  anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
+  CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.9454, anAltitude, EPS );
 
   aDoc->Close();
 }
@@ -174,10 +171,10 @@ void test_HYDROData_Bathymetry::testCopy()
   
   if ( anIsFileCreated )
   {
-    CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName.toStdString().c_str() ) );
+    CPPUNIT_ASSERT( aBathymetry1->ImportFromFiles( QStringList(aFileName ) ) );
 
     HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
-    CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
+    CPPUNIT_ASSERT_EQUAL( 2300, (int)anAltitudePoints.size() );
   }
 
   Handle(HYDROData_Bathymetry) aBathymetry2 = 
@@ -188,7 +185,7 @@ void test_HYDROData_Bathymetry::testCopy()
   if ( anIsFileCreated )
   {
     HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry2->GetAltitudePoints();
-    CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
+    CPPUNIT_ASSERT_EQUAL( 2300, (int)anAltitudePoints.size() );
   }
 
   aDoc->Close();