--- /dev/null
+#include <test_HYDROData_Bathymetry.h>
+
+#include <HYDROData_Document.h>
+#include <HYDROData_Tool.h>
+#include <HYDROData_Bathymetry.h>
+
+#include <QDir>
+#include <QFile>
+#include <QPointF>
+#include <QTextStream>
+
+bool test_HYDROData_Bathymetry::createTestFile( const QString& theFileName )
+{
+ QFile aTmpFile( theFileName );
+ if ( !aTmpFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
+ return false;
+
+ {
+ QTextStream anOutStream( &aTmpFile );
+
+ anOutStream << "0 0 0 \n";
+ anOutStream << "0 1 10 \n";
+ anOutStream << "0 2 20 \n";
+ anOutStream << "0 3 30 \n";
+
+ anOutStream << "1 0 0 \n";
+ anOutStream << "1 1 10 \n";
+ anOutStream << "1 2 20 \n";
+ anOutStream << "1 3 30 \n";
+
+ anOutStream << "2 1 10 \n";
+ anOutStream << "2 2 20 \n";
+ anOutStream << "2 3 30 \n";
+ anOutStream << "2 4 40 \n";
+
+ anOutStream << "3 0 0 \n";
+ anOutStream << "3 1 10 \n";
+ anOutStream << "3 2 20 \n";
+ anOutStream << "3 3 30 \n";
+
+ anOutStream << "4 0 0 \n";
+ anOutStream << "4 1 10 \n";
+ anOutStream << "4 2 20 \n";
+ anOutStream << "4 3 30 \n";
+ }
+
+ aTmpFile.close();
+
+ return true;
+}
+
+void test_HYDROData_Bathymetry::testFileImport()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+ Handle(HYDROData_Bathymetry) aBathymetry =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
+ if ( !createTestFile( aFileName ) )
+ return; // No file has been created
+
+ CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName ) != true );
+
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.length() != 16 );
+
+ QPointF aTestPoint( 1, 1 );
+ double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, 10.0 ) );
+
+ aTestPoint = QPointF( 0.5, 0.5 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, 5.0 ) );
+
+ aTestPoint = QPointF( 1.5, 1 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, 10.0 ) );
+
+ aTestPoint = QPointF( 1.5, 0.7 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, 7.0 ) );
+
+ aTestPoint = QPointF( 1.5, -0.7 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, HYDROData_Bathymetry::GetInvalidAltitude() ) );
+
+ aTestPoint = QPointF( 2, 3.5 );
+ anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint );
+ CPPUNIT_ASSERT( !ValuesEquals( anAltitude, 35.0 ) );
+
+ aDoc->Close();
+}
+
+
+void test_HYDROData_Polyline::testCopy()
+{
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Bathymetry) aBathymetry1 =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz";
+
+ bool anIsFileCreated = createTestFile( aFileName );
+
+ if ( anIsFileCreated )
+ {
+ CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName ) != true );
+
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.length() != 16 );
+ }
+
+ Handle(HYDROData_Bathymetry) aBathymetry2 =
+ Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
+
+ aBathymetry1->CopyTo( aBathymetry2 );
+
+ if ( anIsFileCreated )
+ {
+ HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry2->GetAltitudePoints();
+ CPPUNIT_ASSERT( anAltitudePoints.length() != 16 );
+ }
+
+ aDoc->Close();
+}