Salome HOME
initial ver.
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_ShapeFile.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <test_HYDROData_ShapeFile.h>
20 #include <HYDROData_ShapeFile.h>
21 #include <QStringList>
22 #include <vector>
23
24 const QString REF_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
25
26 void test_HYDROData_ShapeFile::test_openDbf()
27 {
28   QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
29   HYDROData_ShapeFile aSHPFile;
30   bool Stat = aSHPFile.DBF_OpenDBF(aDBFPath);
31   CPPUNIT_ASSERT_EQUAL( true, Stat );  
32   aSHPFile.DBF_CloseDBF();
33 }
34
35 void test_HYDROData_ShapeFile::test_NbFieldsDbf()
36 {
37   QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
38   HYDROData_ShapeFile aSHPFile;
39   aSHPFile.DBF_OpenDBF(aDBFPath);
40   int NbF = aSHPFile.DBF_GetNbFields();
41   CPPUNIT_ASSERT_EQUAL( 2, NbF );  
42   aSHPFile.DBF_CloseDBF();
43 }
44
45 void test_HYDROData_ShapeFile::test_FieldListDbf()
46 {
47   QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
48   HYDROData_ShapeFile aSHPFile;
49   aSHPFile.DBF_OpenDBF(aDBFPath);
50
51   QStringList FL = aSHPFile.DBF_GetFieldList();
52   CPPUNIT_ASSERT_EQUAL(true, "NAME" == FL[0]);
53   CPPUNIT_ASSERT_EQUAL(true, "TYPE" == FL[1]);
54   aSHPFile.DBF_CloseDBF();
55 }
56
57 void test_HYDROData_ShapeFile::test_FieldTypeListDbf()
58 {
59   QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
60   HYDROData_ShapeFile aSHPFile;
61   aSHPFile.DBF_OpenDBF(aDBFPath);
62
63   std::vector<HYDROData_ShapeFile::DBF_FieldType> FTVect;
64   aSHPFile.DBF_GetFieldTypeList(FTVect);
65   CPPUNIT_ASSERT_EQUAL(HYDROData_ShapeFile::DBF_FieldType_String, FTVect[0]);
66   CPPUNIT_ASSERT_EQUAL(HYDROData_ShapeFile::DBF_FieldType_String, FTVect[1]);
67   aSHPFile.DBF_CloseDBF();
68 }
69
70
71