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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <test_HYDROData_ShapeFile.h>
20 #include <HYDROData_ShapeFile.h>
21 #include <QStringList>
24 const QString REF_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
26 void test_HYDROData_ShapeFile::test_openDbf()
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();
35 void test_HYDROData_ShapeFile::test_NbFieldsDbf()
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();
45 void test_HYDROData_ShapeFile::test_FieldListDbf()
47 QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
48 HYDROData_ShapeFile aSHPFile;
49 aSHPFile.DBF_OpenDBF(aDBFPath);
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();
57 void test_HYDROData_ShapeFile::test_FieldTypeListDbf()
59 QString aDBFPath = REF_PATH + "/cyprus_natural.dbf";
60 HYDROData_ShapeFile aSHPFile;
61 aSHPFile.DBF_OpenDBF(aDBFPath);
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();