Salome HOME
simple test for DBF info of polylines
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_Entity.cxx
index 9bdeb4c5380d230aaf0954d8021cddc5d53d97ed..ca377c32f91a62bdba62ec72241d3759bf0f851f 100644 (file)
@@ -64,3 +64,39 @@ void test_HYDROData_Entity::testCopy()
 
   aDoc->Close();
 }
+
+void test_HYDROData_Entity::testPythonNameChoice()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_Entity) anObj = aDoc->CreateObject(KIND_IMAGE); // any object
+  
+  anObj->SetName("test");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test" ) );
+
+  anObj->SetName("test_1");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
+
+  anObj->SetName("test 1");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "test_1" ) );
+
+  anObj->SetName("  test abc    hello     ");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__test_abc____hello_____" ) );
+
+  anObj->SetName("123");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "Image_123" ) );
+
+  anObj->SetName("  123");
+  CPPUNIT_ASSERT_EQUAL( anObj->GetObjPyName().toStdString(), std::string( "__123" ) );
+
+  aDoc->Close();
+}
+
+void test_HYDROData_Entity::testTypes()
+{
+  for( int i=0; i<KIND_LAST; i++ )
+  {
+    CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).isEmpty() );
+    CPPUNIT_ASSERT_EQUAL( false, HYDROData_Entity::Type( (ObjectKind)i ).contains(' ') );
+  }
+}