Beispiel #1
0
TEST(TNEANet, DelSAttrDatE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrE(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrE(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrE(StrAttr, atStr, StrId);
  TInt Id(0);
  int status = Graph->DelSAttrDatE(Id, IntAttr);
  EXPECT_EQ(-1, status);
  status = Graph->DelSAttrDatE(Id, IntId);
  EXPECT_EQ(-1, status);

  TInt IntVal(5);
  Graph->AddSAttrDatE(Id, IntId, IntVal);
  status = Graph->DelSAttrDatE(Id, IntAttr);
  EXPECT_EQ(0, status);
  Graph->AddSAttrDatE(Id, IntId, IntVal);
  status = Graph->DelSAttrDatE(Id, IntId);
  EXPECT_EQ(0, status);
  status = Graph->DelSAttrDatE(Id, IntId);
  EXPECT_EQ(-1, status);
  TInt ErrorId(1);
  status = Graph->DelSAttrDatE(ErrorId, IntId);
  EXPECT_EQ(-1, status);

  TFlt FltVal(5.0);
  Graph->AddSAttrDatE(Id, FltId, FltVal);
  status = Graph->DelSAttrDatE(Id, FltAttr);
  EXPECT_EQ(0, status);
  Graph->AddSAttrDatE(Id, FltId, FltVal);
  status = Graph->DelSAttrDatE(Id, FltId);
  EXPECT_EQ(0, status);
  status = Graph->DelSAttrDatE(Id, FltId);
  EXPECT_EQ(-1, status);
  status = Graph->DelSAttrDatE(ErrorId, FltId);
  EXPECT_EQ(-1, status);

  TStr StrVal("5");
  Graph->AddSAttrDatE(Id, StrId, StrVal);
  status = Graph->DelSAttrDatE(Id, StrAttr);
  EXPECT_EQ(0, status);
  Graph->AddSAttrDatE(Id, StrId, StrVal);
  status = Graph->DelSAttrDatE(Id, StrId);
  EXPECT_EQ(0, status);
  status = Graph->DelSAttrDatE(Id, StrId);
  EXPECT_EQ(-1, status);
  status = Graph->DelSAttrDatE(ErrorId, StrId);
  EXPECT_EQ(-1, status);
}
Beispiel #2
0
TEST(TNEANet, AddSAttrDatE_flt) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TFlt Val(5.0);
  TInt Id(0);
  int status = Graph->AddSAttrDatE(Id, 1, Val);
  EXPECT_EQ(-1, status);
  TInt AttrId;
  TStr AttrName("TestFlt");
  Graph->AddSAttrE(AttrName, atFlt, AttrId);
  TInt ErrorVal(1);
  status = Graph->AddSAttrDatE(Id, AttrId, ErrorVal);
  EXPECT_EQ(-2, status);
  status = Graph->AddSAttrDatE(Id, AttrId, Val);
  EXPECT_EQ(0, status);
  status = Graph->AddSAttrDatE(Id, AttrName, Val);
  EXPECT_EQ(0, status);
  TStr NewName("TestFlt2");
  status = Graph->AddSAttrDatE(Id, NewName, Val);
  EXPECT_EQ(0, status);
  TInt ErrorId(1);
  status = Graph->AddSAttrDatE(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #3
0
TEST(TNEANet, AddSAttrE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TInt AttrId;
  int status = Graph->AddSAttrE("TestInt", atInt, AttrId);
  EXPECT_EQ(0, status);
  EXPECT_EQ(0, AttrId.Val);
  status = Graph->AddSAttrE("TestFlt", atFlt, AttrId);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrId.Val);
  status = Graph->AddSAttrE("TestStr", atStr, AttrId);
  EXPECT_EQ(0, status);
  EXPECT_EQ(2, AttrId.Val);
  //status = Graph->AddSAttrE("TestAny", atAny, AttrId);
  //EXPECT_EQ(-1, status);
}
Beispiel #4
0
TEST(TNEANet, GetSAttrDatE_str) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TStr Val;
  TInt AttrId(0);
  TStr AttrName("TestInt");
  TInt EId(0);
  int status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(-1, status);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(-1, status);
  Graph->AddSAttrE(AttrName, atStr, AttrId);
  TStr TestVal("5");
  Graph->AddSAttrDatE(EId, AttrId, TestVal);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  TInt ErrorId(1);
  status = Graph->GetSAttrDatE(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #5
0
TEST(TNEANet, GetSAttrDatE_flt) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TFlt Val;
  TInt AttrId(0);
  TStr AttrName("TestInt");
  TInt EId(0);
  int status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(-1, status);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(-1, status);
  Graph->AddSAttrE(AttrName, atFlt, AttrId);
  TFlt TestVal(5.0);
  Graph->AddSAttrDatE(EId, AttrId, TestVal);
  status = Graph->GetSAttrDatE(EId, AttrId, Val);
  EXPECT_EQ(0, status);
  EXPECT_EQ(TestVal.Val, Val.Val);
  status = Graph->GetSAttrDatE(EId, AttrName, Val);
  EXPECT_EQ(0, status);
  EXPECT_EQ(TestVal.Val, Val.Val);
  TInt ErrorId(1);
  status = Graph->GetSAttrDatE(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #6
0
TEST(TNEANet, GetIdVSAttrE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrE(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrE(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrE(StrAttr, atStr, StrId);

  TInt IntVal(0);
  TFlt FltVal(0);
  TStr StrVal("test");
  Graph->AddNode(0);
  for (int i = 0; i < 10; i++) {
    Graph->AddNode(i+1);
    Graph->AddEdge(i, i+1, i);
    TInt Id(i);
    Graph->AddSAttrDatE(Id, IntId, IntVal);
    if (i%2 == 0) {
      Graph->AddSAttrDatE(Id, FltId, FltVal);
    }
  }
  Graph->AddSAttrDatE(0, StrId, StrVal);

  TIntV IdV;
  Graph->GetIdVSAttrE(IntAttr, IdV);
  EXPECT_EQ(10, IdV.Len());
  Graph->GetIdVSAttrE(IntId, IdV);
  EXPECT_EQ(10, IdV.Len());

  Graph->GetIdVSAttrE(FltAttr, IdV);
  EXPECT_EQ(5, IdV.Len());
  Graph->GetIdVSAttrE(FltId, IdV);
  EXPECT_EQ(5, IdV.Len());

  Graph->GetIdVSAttrE(StrAttr, IdV);
  EXPECT_EQ(1, IdV.Len());
  Graph->GetIdVSAttrE(StrId, IdV);
  EXPECT_EQ(1, IdV.Len());
}
Beispiel #7
0
TEST(TNEANet, GetSAttrVE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  Graph->AddNode(1);
  Graph->AddEdge(0, 1, 0);
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrE(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrE(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrE(StrAttr, atStr, StrId);

  TInt Id(0);
  TInt IntVal(5);
  Graph->AddSAttrDatE(Id, IntId, IntVal);
  TFlt FltVal(5.0);
  Graph->AddSAttrDatE(Id, FltId, FltVal);
  TStr StrVal("5");
  Graph->AddSAttrDatE(Id, StrId, StrVal);

  TAttrPrV AttrV;
  int status = Graph->GetSAttrVE(Id, atInt, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  status = Graph->GetSAttrVE(Id, atFlt, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  status = Graph->GetSAttrVE(Id, atStr, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  //status = Graph->GetSAttrVE(Id, atAny, AttrV);
  //EXPECT_EQ(0, status);
  //EXPECT_EQ(3, AttrV.Len());
  //status = Graph->GetSAttrVE(Id, atUndef, AttrV);
  //EXPECT_EQ(0, status);
  //EXPECT_EQ(0, AttrV.Len());
  //TInt ErrorId(1);
  //status = Graph->GetSAttrVE(ErrorId, atUndef, AttrV);
  //EXPECT_EQ(-1, status);
}
Beispiel #8
0
TEST(TNEANet, GetSAttrIdE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TInt AttrId;
  Graph->AddSAttrE("TestInt", atInt, AttrId);
  Graph->AddSAttrE("TestFlt", atFlt, AttrId);
  Graph->AddSAttrE("TestStr", atStr, AttrId);
  TAttrType AttrType;
  int status = Graph->GetSAttrIdE(TStr("TestInt"), AttrId, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atInt, AttrType);
  EXPECT_EQ(0, AttrId.Val);
  status = Graph->GetSAttrIdE(TStr("TestFlt"), AttrId, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atFlt, AttrType);
  EXPECT_EQ(1, AttrId.Val);
  status = Graph->GetSAttrIdE(TStr("TestStr"), AttrId, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atStr, AttrType);
  EXPECT_EQ(2, AttrId.Val);
  status = Graph->GetSAttrIdE(TStr("TestError"), AttrId, AttrType);
  EXPECT_EQ(-1, status);
}
Beispiel #9
0
TEST(TNEANet, GetSAttrNameE) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TInt AttrId;
  Graph->AddSAttrE("TestInt", atInt, AttrId);
  Graph->AddSAttrE("TestFlt", atFlt, AttrId);
  Graph->AddSAttrE("TestStr", atStr, AttrId);
  TAttrType AttrType;
  TStr Name;
  int status = Graph->GetSAttrNameE(0, Name, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atInt, AttrType);
  EXPECT_STREQ("TestInt", Name.CStr());
  status = Graph->GetSAttrNameE(1, Name, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atFlt, AttrType);
  EXPECT_STREQ("TestFlt", Name.CStr());
  status = Graph->GetSAttrNameE(2, Name, AttrType);
  EXPECT_EQ(0, status);
  EXPECT_EQ(atStr, AttrType);
  EXPECT_STREQ("TestStr", Name.CStr());
  status = Graph->GetSAttrNameE(3, Name, AttrType);
  EXPECT_EQ(-1, status);
}