Beispiel #1
0
TEST(TNEANet, GetSAttrDatN_str) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  TStr Val;
  TInt AttrId(0);
  TStr AttrName("TestInt");
  TInt NId(0);
  int status = Graph->GetSAttrDatN(NId, AttrName, Val);
  EXPECT_EQ(-1, status);
  status = Graph->GetSAttrDatN(NId, AttrId, Val);
  EXPECT_EQ(-1, status);
  Graph->AddSAttrN(AttrName, atStr, AttrId);
  TStr TestVal("5");
  Graph->AddSAttrDatN(NId, AttrId, TestVal);
  status = Graph->GetSAttrDatN(NId, AttrId, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  status = Graph->GetSAttrDatN(NId, AttrName, Val);
  EXPECT_EQ(0, status);
  EXPECT_STREQ(TestVal.CStr(), Val.CStr());
  TInt ErrorId(1);
  status = Graph->GetSAttrDatN(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #2
0
TEST(TNEANet, GetSAttrDatN_flt) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  TFlt Val;
  TInt AttrId(0);
  TStr AttrName("TestInt");
  TInt NId(0);
  int status = Graph->GetSAttrDatN(NId, AttrName, Val);
  EXPECT_EQ(-1, status);
  status = Graph->GetSAttrDatN(NId, AttrId, Val);
  EXPECT_EQ(-1, status);
  Graph->AddSAttrN(AttrName, atFlt, AttrId);
  TFlt TestVal(5.0);
  Graph->AddSAttrDatN(NId, AttrId, TestVal);
  status = Graph->GetSAttrDatN(NId, AttrId, Val);
  EXPECT_EQ(0, status);
  EXPECT_EQ(TestVal.Val, Val.Val);
  status = Graph->GetSAttrDatN(NId, AttrName, Val);
  EXPECT_EQ(0, status);
  EXPECT_EQ(TestVal.Val, Val.Val);
  TInt ErrorId(1);
  status = Graph->GetSAttrDatN(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #3
0
TEST(TNEANet, GetIdVSAttrN) {
  PNEANet Graph;
  Graph = TNEANet::New();
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrN(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrN(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrN(StrAttr, atStr, StrId);

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

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

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

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

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

  TAttrPrV AttrV;
  int status = Graph->GetSAttrVN(Id, atInt, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  status = Graph->GetSAttrVN(Id, atFlt, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  status = Graph->GetSAttrVN(Id, atStr, AttrV);
  EXPECT_EQ(0, status);
  EXPECT_EQ(1, AttrV.Len());
  //status = Graph->GetSAttrVN(Id, atAny, AttrV);
  //EXPECT_EQ(0, status);
  //EXPECT_EQ(3, AttrV.Len());
  //status = Graph->GetSAttrVN(Id, atUndef, AttrV);
  //EXPECT_EQ(0, status);
  //EXPECT_EQ(0, AttrV.Len());
  //TInt ErrorId(1);
  //status = Graph->GetSAttrVN(ErrorId, atUndef, AttrV);
  //EXPECT_EQ(-1, status);
}
Beispiel #5
0
TEST(TNEANet, AddSAttrDatN_str) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  TStr Val("5");
  TInt Id(0);
  int status = Graph->AddSAttrDatN(Id, 1, Val);
  EXPECT_EQ(-1, status);
  TInt AttrId;
  TStr AttrName("TestFlt");
  Graph->AddSAttrN(AttrName, atStr, AttrId);
  TInt ErrorVal(1);
  status = Graph->AddSAttrDatN(Id, AttrId, ErrorVal);
  EXPECT_EQ(-2, status);
  status = Graph->AddSAttrDatN(Id, AttrId, Val);
  EXPECT_EQ(0, status);
  status = Graph->AddSAttrDatN(Id, AttrName, Val);
  EXPECT_EQ(0, status);
  TStr NewName("TestStr2");
  status = Graph->AddSAttrDatN(Id, NewName, Val);
  EXPECT_EQ(0, status);
  TInt ErrorId(1);
  status = Graph->AddSAttrDatN(ErrorId, AttrId, Val);
  EXPECT_EQ(-1, status);
}
Beispiel #6
0
TEST(TNEANet, DelSAttrDatN) {
  PNEANet Graph;
  Graph = TNEANet::New();
  Graph->AddNode(0);
  TStr IntAttr("TestInt");
  TInt IntId;
  Graph->AddSAttrN(IntAttr, atInt, IntId);
  TStr FltAttr("TestFlt");
  TInt FltId;
  Graph->AddSAttrN(FltAttr, atFlt, FltId);
  TStr StrAttr("TestStr");
  TInt StrId;
  Graph->AddSAttrN(StrAttr, atStr, StrId);
  TInt Id(0);
  int status = Graph->DelSAttrDatN(Id, IntAttr);
  EXPECT_EQ(-1, status);
  status = Graph->DelSAttrDatN(Id, IntId);
  EXPECT_EQ(-1, status);

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

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

  TStr StrVal("5");
  Graph->AddSAttrDatN(Id, StrId, StrVal);
  status = Graph->DelSAttrDatN(Id, StrAttr);
  EXPECT_EQ(0, status);
  Graph->AddSAttrDatN(Id, StrId, StrVal);
  status = Graph->DelSAttrDatN(Id, StrId);
  EXPECT_EQ(0, status);
  status = Graph->DelSAttrDatN(Id, StrId);
  EXPECT_EQ(-1, status);
  status = Graph->DelSAttrDatN(ErrorId, StrId);
  EXPECT_EQ(-1, status);
}