Salome HOME
Merge branch 'BR_1330' into BR_DEMO
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_ShapeFile.cxx
index c90791f60e2bfa9cac788a9981975ce86c6b1b79..b4007ceaab6b03cbaab3386bb72d37b7f12274aa 100644 (file)
@@ -21,7 +21,7 @@
 #include <QStringList>
 #include <vector>
 
-const QString REF_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
+const QString REF_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO";
 
 bool test_HYDROData_ShapeFile::compare_two_files(const QString& File1, const QString& File2)
 {
@@ -150,7 +150,7 @@ void test_HYDROData_ShapeFile::test_GetAttrListIndex()
     aSHPFile.DBF_GetAttributeList(2, theAttrV ); 
     CPPUNIT_ASSERT_EQUAL( 3269, (int)theAttrV.size() ); 
     CPPUNIT_ASSERT_EQUAL( true, std::string("6621.1654324936000000000000000000") == theAttrV[2].myRawValue);
-    CPPUNIT_ASSERT_EQUAL( true, QString("6621.1654324935998375") == theAttrV[2].myStrVal);
+    CPPUNIT_ASSERT_EQUAL( 6621.1654324935998375, theAttrV[2].myDoubleVal);
     CPPUNIT_ASSERT_EQUAL( false, theAttrV[2].myIsNull);
     CPPUNIT_ASSERT_EQUAL( HYDROData_ShapeFile::DBF_FieldType_Double, theAttrV[2].myFieldType);
 
@@ -161,27 +161,83 @@ void test_HYDROData_ShapeFile::test_GetAttrListIndex()
 
 void test_HYDROData_ShapeFile::test_DbfWrite()
 {
-  HYDROData_ShapeFile aSHPFile; 
-  QString tempFN = REF_PATH + "/temp_dbf1.dbf";
-  QString refFN = REF_PATH + "/ref_dbf1.dbf";
-  std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
-  HYDROData_ShapeFile::DBF_AttrValue theAttr1;
-  theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
-  theAttr1.myIsNull = false;
-  theAttr1.myRawValue = "test_value1";
-  theAttr1.myStrVal = "test_value1";
-  theAttrV.push_back(theAttr1);
-  HYDROData_ShapeFile::DBF_AttrValue theAttr2;
-  theAttr2.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
-  theAttr2.myIsNull = false;
-  theAttr2.myRawValue = "test_value2";
-  theAttr2.myStrVal = "test_value2";
-  theAttrV.push_back(theAttr2);
-  //
-  aSHPFile.DBF_WriteFieldAndValues(tempFN, "test_field_name", HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, false);
-
-  CPPUNIT_ASSERT(compare_two_files(tempFN, refFN));
-  CPPUNIT_ASSERT_EQUAL( 0, remove (tempFN.toStdString().c_str()));
+  {
+    HYDROData_ShapeFile aSHPFile; 
+    QString tempFN = REF_PATH + "/temp_dbf1.dbf";
+    QString refFN = REF_PATH + "/ref_dbf1.dbf";
+    std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+    HYDROData_ShapeFile::DBF_AttrValue theAttr1;
+    theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+    theAttr1.myIsNull = false;
+    theAttr1.myRawValue = "test_value1";
+    theAttr1.myStrVal = "test_value1";
+    theAttrV.push_back(theAttr1);
+    HYDROData_ShapeFile::DBF_AttrValue theAttr2;
+    theAttr2.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+    theAttr2.myIsNull = false;
+    theAttr2.myRawValue = "test_value2";
+    theAttr2.myStrVal = "test_value2";
+    theAttrV.push_back(theAttr2);
+    //
+    CPPUNIT_ASSERT(aSHPFile.DBF_WriteFieldAndValues(tempFN, "test_field_name", HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, true));
+
+    CPPUNIT_ASSERT(compare_two_files(tempFN, refFN));
+    CPPUNIT_ASSERT_EQUAL( 0, remove (tempFN.toStdString().c_str()));
+  }
+
+  {
+    HYDROData_ShapeFile aSHPFile; 
+    QString tempFN = REF_PATH + "/temp_dbf2.dbf";
+    QString refFN = REF_PATH + "/ref_dbf2.dbf";
+    std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+    HYDROData_ShapeFile::DBF_AttrValue theAttr1;
+    theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+    theAttr1.myIsNull = false;
+    theAttr1.myRawValue = "test_value1";
+    theAttr1.myStrVal = "test_value1";
+    theAttrV.push_back(theAttr1);
+
+    HYDROData_ShapeFile::DBF_AttrValue theAttr2;
+    theAttr2.myIsNull = false;
+    theAttr2.myRawValue = "test_value_K";
+    theAttr2.myStrVal = "test_value_K";
+    theAttr2.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+    for (int ii = 0; ii < 100; ii++)
+      theAttrV.push_back(theAttr2);
+
+    HYDROData_ShapeFile::DBF_AttrValue theAttr3;
+    theAttr3.myIsNull = true;
+    theAttr3.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+    for (int ii = 0; ii < 100; ii++)
+      theAttrV.push_back(theAttr3);
+    //
+    CPPUNIT_ASSERT(aSHPFile.DBF_WriteFieldAndValues(tempFN, "test_field_name", HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, true));
+
+    CPPUNIT_ASSERT(compare_two_files(tempFN, refFN));
+    CPPUNIT_ASSERT_EQUAL( 0, remove (tempFN.toStdString().c_str()));
+  }
+
+  {
+    HYDROData_ShapeFile aSHPFile; 
+    QString tempFN = REF_PATH + "/temp_dbf3.dbf";
+    QString refFN = REF_PATH + "/ref_dbf3.dbf";
+    std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+    HYDROData_ShapeFile::DBF_AttrValue theAttr1;
+    theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_Integer;
+    theAttr1.myIsNull = false;
+
+    for (int ii = 0; ii < 100; ii++)
+    {
+      theAttr1.myIntVal = ii;
+      theAttrV.push_back(theAttr1);
+    }
+
+    //
+    CPPUNIT_ASSERT(aSHPFile.DBF_WriteFieldAndValues(tempFN, "test_field_name", HYDROData_ShapeFile::DBF_FieldType_Integer, theAttrV, false));
+
+    CPPUNIT_ASSERT(compare_two_files(tempFN, refFN));
+    CPPUNIT_ASSERT_EQUAL( 0, remove (tempFN.toStdString().c_str()));
+  }
 
 }