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_Entity.h>
21 #include <HYDROData_Document.h>
22 #include <HYDROData_Entity.h>
26 void test_HYDROData_Entity::testName()
28 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
30 Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
31 static const QString aName("test_name");
32 anObj->SetName(aName);
33 CPPUNIT_ASSERT_EQUAL(aName.toStdString(), anObj->GetName().toStdString());
38 void test_HYDROData_Entity::testRemove()
40 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
42 Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
43 CPPUNIT_ASSERT(!anObj->IsRemoved());
45 CPPUNIT_ASSERT(anObj->IsRemoved());
50 void test_HYDROData_Entity::testCopy()
52 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
54 Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
55 static const QString aName("test_name");
56 anObj->SetName(aName);
58 Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy
59 CPPUNIT_ASSERT(aCopy->GetName().isEmpty());
60 anObj->CopyTo(aCopy, false);
62 // check the copied object has same name as original
63 CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString());
68 void test_HYDROData_Entity::testPythonNameChoice()
70 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
72 Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
74 anObj->SetName("test");
75 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test" ) );
77 anObj->SetName("test_1");
78 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
80 anObj->SetName("test 1");
81 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
83 anObj->SetName(" test abc hello ");
84 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__test_abc____hello_____" ) );
86 anObj->SetName("123");
87 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "Image_123" ) );
89 anObj->SetName(" 123");
90 CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__123" ) );
95 void test_HYDROData_Entity::testTypes()
97 for( int i=0; i<KIND_LAST; i++ )
99 CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).isEmpty() );
100 CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).contains(' ') );