_PTR(GenericAttribute) ga;
CPPUNIT_ASSERT(so->FindAttribute(ga, "AttributeIOR"));
- //Check method ReferencedObject
+ //Try to find attribute with empty type
+ CPPUNIT_ASSERT(!so->FindAttribute(ga, ""));
+ //Check method ReferencedObject
studyBuilder->Addreference(so1, so);
_PTR(SObject) so2;
CPPUNIT_ASSERT(so1->ReferencedObject(so2));
study->Name("Test");
//Check method URL (get/set)
+ study->URL("");
+ CPPUNIT_ASSERT(study->URL() == "");
study->URL("some url");
CPPUNIT_ASSERT(study->URL() == "some url");
_PTR(SObject) so = study->CreateObjectID("0:2:1:3");
CPPUNIT_ASSERT(so);
+ //Try to create SObject with empty and invalid entries
+ CPPUNIT_ASSERT(!study->CreateObjectID(""));
+ CPPUNIT_ASSERT(!study->CreateObjectID("entry"));
+
//Check method NewChildIterator
_PTR(ChildIterator) childIterator = study->NewChildIterator(so);
CPPUNIT_ASSERT(childIterator);
CPPUNIT_ASSERT(name_attr_sco1);
name_attr_sco1->SetValue("sco1");
+ //Try to find component with empty type
+ CPPUNIT_ASSERT(!study->FindComponent(""));
+
//Check method GetComponentNames
vector<string> components = study->GetComponentNames(""); //The context doesn't matter
CPPUNIT_ASSERT(components.size() == 1 && components[0] == "sco1");
_PTR(SComponent) sco3 = study->FindComponentID(sco1->GetID());
CPPUNIT_ASSERT(sco3 && sco3->GetID() == sco1->GetID());
+ //Try to find component with empty id
+ CPPUNIT_ASSERT(!study->FindComponentID(""));
+
_PTR(SObject) so1 = studyBuilder->NewObject(sco1);
CPPUNIT_ASSERT(so1);
_PTR(AttributeName) name_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
_PTR(SObject) so3 = study->FindObject("so1");
CPPUNIT_ASSERT(so3 && so3->GetID() == so1->GetID());
+ //Try to find SObject with empty name
+ CPPUNIT_ASSERT(!study->FindObject(""));
+
//Check method FindObjectID
_PTR(SObject) so4 = study->FindObjectID(so1->GetID());
CPPUNIT_ASSERT(so4 && so4->GetID() == so1->GetID());
+ //Try to find SObject with empty ID
+ CPPUNIT_ASSERT(!study->FindObjectID(""));
+
//Check method FindObjectByName
vector< _PTR(SObject) > v = study->FindObjectByName("so1", sco1->ComponentDataType());
CPPUNIT_ASSERT(v.size()==1 && v[0]->GetID() == so1->GetID());
+ //Try to find SObject with empty name and empty component type
+ CPPUNIT_ASSERT((study->FindObjectByName("", "")).size() == 0);
+
//Check method FindObjectByPath
_PTR(SObject) path_so = study->FindObjectByPath("/"+sco1->GetName()+"/"+so1->GetName());
CPPUNIT_ASSERT(path_so && path_so->GetID() == so1->GetID());
_PTR(SObject) so5 = study->FindObjectIOR(ior);
CPPUNIT_ASSERT(so5 && so5->GetID() == so1->GetID());
+ //Try to find SObject with empty IOR
+ CPPUNIT_ASSERT(!study->FindObjectIOR(""));
+
//Check method GetObjectPath
string path = study->GetObjectPath(so2);
+ //Try to get path of NULL SObject
+ _PTR(SObject) emptySO;
+ path = study->GetObjectPath(emptySO);
+ CPPUNIT_ASSERT(path.empty());
+
//Check method SetContext
study->SetContext("/sco1");
CPPUNIT_ASSERT(study->GetContext() == "/sco1");
_PTR(SObject) so6 = study->FindObjectByPath("so1");
CPPUNIT_ASSERT(so6 && so6->GetID() == so1->GetID());
+
+ //Try to find SObject with empty path
+ _PTR(SObject) tmp = study->FindObjectByPath(""); //Must return the Context SObject
+ CPPUNIT_ASSERT(tmp && tmp->GetID() == sco1->GetID());
+
study->SetContext("/"); //Root
//Check method GetObjectNames
CPPUNIT_ASSERT(sp);
//Check Lock functionality
- //_PTR(AttributeName) name_attr_so1 = studyBuilder->FindOrCreateAttribute(so1, "AttributeName");
sp->SetLocked(true);
bool isLockRaised = false;
try {
//Check method GetUseCaseBuilder
_PTR(UseCaseBuilder) ub = study->GetUseCaseBuilder();
+ CPPUNIT_ASSERT(ub);
//Check method SetStudyLock
study->SetStudyLock("locker1");
_PTR(SComponent) sco2 = study->FindComponent("Test");
CPPUNIT_ASSERT(!sco2);
+ //Try to create and find the component with empty type
+ _PTR(SComponent) sco_empty = studyBuilder->NewComponent("");
+ CPPUNIT_ASSERT(!sco_empty);
_PTR(SComponent) sco3 = studyBuilder->NewComponent("NewComp");
CPPUNIT_ASSERT(sco3);
_PTR(AttributeName) an3 = studyBuilder->FindOrCreateAttribute(so3, "AttributeName");
CPPUNIT_ASSERT(an3);
+ cout << endl << "########## 1" << endl;
+
+ //Try to create attribute with invalid type
+ CPPUNIT_ASSERT(!studyBuilder->FindOrCreateAttribute(so3, "invalid type"));
+
+ cout << endl << "########## 2" << endl;
+
//Check method FindAttribute
_PTR(GenericAttribute) ga;
CPPUNIT_ASSERT(studyBuilder->FindAttribute(so3, ga, "AttributeName"));
+ cout << endl << "########## 3" << endl;
+
+ //Try to find attribute with invalid type
+ CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so3, ga, "invalid type"));
+
+ cout << endl << "########## 4" << endl;
+
//Check method RemoveObject
studyBuilder->RemoveObject(so3);
CPPUNIT_ASSERT(!studyBuilder->FindAttribute(so3, ga, "AttributeName"));
_PTR(SObject) refSO;
CPPUNIT_ASSERT(so2->ReferencedObject(refSO) && refSO->GetID() == so1->GetID());
+ //Try to set reference to NULL SObject
+ bool isRaised = false;
+ _PTR(SObject) empty_so;
+ try {
+ studyBuilder->Addreference(so2, empty_so);
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
//Check method RemoveReference
studyBuilder->RemoveReference(so2);
CPPUNIT_ASSERT(!so2->ReferencedObject(refSO));
studyBuilder->SetGUID(so1, value);
CPPUNIT_ASSERT(studyBuilder->IsGUID(so1, value));
+ //Try to set invalid GUID
+ isRaised = false;
+ try {
+ studyBuilder->SetGUID(so1, "invalid GUID");
+ }
+ catch(...) {
+ isRaised = true;
+ }
+ CPPUNIT_ASSERT(isRaised);
+
//Check method UndoLimit (set/get)
studyBuilder->UndoLimit(10);
CPPUNIT_ASSERT(studyBuilder->UndoLimit() == 10);
studyBuilder->SetName(so1, "new name");
CPPUNIT_ASSERT(so1->GetName() == "new name");
+ //Try to set empty Name
+ studyBuilder->SetName(so1, "");
+ CPPUNIT_ASSERT(so1->GetName() == "");
+
//Check method SetComment
studyBuilder->SetComment(so1, "new comment");
CPPUNIT_ASSERT(so1->GetComment() == "new comment");
+ //Check method empty Comment
+ studyBuilder->SetComment(so1, "");
+ CPPUNIT_ASSERT(so1->GetComment() == "");
+
+ //Try to set empty IOR
+ studyBuilder->SetIOR(so1, "");
+ CPPUNIT_ASSERT(so1->GetIOR() == "");
+
//Check method SetIOR
studyBuilder->SetIOR(so1, ior);
CPPUNIT_ASSERT(so1->GetIOR() == ior);
SALOMEDS::Driver_var drv2 = SALOMEDS::Driver::_narrow(obj2);
ior = _orb->object_to_string(drv2);
- bool isRaised = false;
+ isRaised = false;
try {
sb3->LoadWith(aComp, ior);
}
_PTR(Study) study2 = sm->NewStudy("Study2");
CPPUNIT_ASSERT(study2);
- //Check method FindStudyByName
+ //Check method GetStudyByName
_PTR(Study) study3 = sm->GetStudyByName("Study1");
CPPUNIT_ASSERT(study3->StudyId() == study1->StudyId());
CPPUNIT_ASSERT(study3->Name() == study1->Name());
+ //Check method GetStudyByName with empty name
+ CPPUNIT_ASSERT(!sm->GetStudyByName(""));
+
+ //Try to create Study with empty name
+ _PTR(Study) study_empty = sm->NewStudy("");
+ CPPUNIT_ASSERT(study_empty);
+ CPPUNIT_ASSERT(sm->GetStudyByName(""));
+ sm->Close(study_empty);
+
//Check method FindStudyByID
_PTR(Study) study4 = sm->GetStudyByID(study2->StudyId());
CPPUNIT_ASSERT(study4->StudyId() == study2->StudyId());
sm->Close(study2);
CPPUNIT_ASSERT(!sm->GetStudyByID(id));
+ //Check method GetStudyByID for invalid ID
+ CPPUNIT_ASSERT(!sm->GetStudyByID(-1));
+
//Check methods CanPaste, CanCopy, Copy, Paste
_PTR(StudyBuilder) sb1 = study1->NewBuilder();
_PTR(SComponent) sco1 = sb1->NewComponent("Test");
//Check method Open
_PTR(Study) study1_opened = sm->Open("srn_UnitTest_Save.hdf"); //Contains Test component
system("rm -f srn_UnitTest_Save.hdf");
+ url = study1->URL();
CPPUNIT_ASSERT(study1_opened);
CPPUNIT_ASSERT(url == "srn_UnitTest_Save.hdf");
_PTR(StudyBuilder) sb6 = study4_opened->NewBuilder();
_PTR(AttributeName) na6 = sb6->FindOrCreateAttribute(so6, "AttributeName");
CPPUNIT_ASSERT(na6 && na6->Value() == "Saved study ASCII"); //Compare the value of restored attribute with string that has to be saved.
-
}