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); }
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); }
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); }
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); }
TEST(TNEANet, GetSAttrDatE_int) { PNEANet Graph; Graph = TNEANet::New(); Graph->AddNode(0); Graph->AddNode(1); Graph->AddEdge(0, 1, 0); TInt 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, atInt, AttrId); TInt TestVal(5); 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); }
void XMLElement :: DumpOn( std::ostream & os, bool recurse ) const { os << "<" << Name(); for ( unsigned int i = 0; i < AttrCount(); i++ ) { os << " " << AttrName(i) << "=\""; os << AttrValue( AttrName(i) ) << "\""; } if ( ! recurse ) { os << "/>\n"; } else { os << ">\n"; for ( unsigned int i = 0; i < ChildCount(); i++ ) { const XMLElement * ce = ChildElement( i ) ; if ( ce ) { ce->DumpOn( os, recurse ); } const XMLText * ct = ChildText( i ); if ( ct ) { os << LTrim( ct->Text() ) << "\n"; } } os << "</" << Name() << ">\n"; } }
// --------------------------------------------------------- // TCodParser::AttrLineL() // --------------------------------------------------------- // TBool TCodParser::AttrLineL(CMediaObjectData *& aMediaObject) { SkipWhiteSpace(); // Skip lines which contain only WS and LF at the end. while ( IsEndOfLine() ) { NextLine(); SkipWhiteSpace(); } TBool ok( ETrue ); if ( iCurP < iEndP ) { // Still has something to read. switch( AttrName() ) { case ECodName: { if ( Colon() ) { ok = aMediaObject->SetNameL( AttrValue() ); EndOfLine(); } break; } case ECodVendor: { if ( Colon() ) { ok = iData->SetVendorL( AttrValue() ); EndOfLine(); } break; } case ECodDescription: { if ( Colon() ) { ok = aMediaObject->SetDescriptionL( AttrValue() ); EndOfLine(); } break; } case ECodSize: { if ( Colon() ) { // Parse as TUint - negative not allowed. TUint size; TLex lex( AttrValue() ); if ( !lex.Val( size ) ) { aMediaObject->SetSize( size ); } else { ok = EFalse; } EndOfLine(); } break; } case ECodInstallNotify: { if ( Colon() ) { ok = aMediaObject->SetInstallNotifyL( AttrValue() ); EndOfLine(); } break; } case ECodNextUrl: { if ( Colon() ) { ok = iData->SetNextUrlL( AttrValue() ); EndOfLine(); } break; } case ECodNextUrlAtError: { if ( Colon() ) { ok = iData->SetNextUrlAtErrorL( AttrValue() ); EndOfLine(); } break; } case ECodInfoUrl: { if ( Colon() ) { ok = aMediaObject->SetInfoUrlL( AttrValue() ); EndOfLine(); } break; } case ECodPrice: { if ( Colon() ) { ok = aMediaObject->SetPriceL( AttrValue() ); EndOfLine(); } break; } case ECodIcon: { if ( Colon() ) { ok = aMediaObject->SetIconL( AttrValue() ); EndOfLine(); } break; } case ECodType: { if ( Colon() ) { ok = aMediaObject->SetTypeL( AttrValue() ); EndOfLine(); } break; } case ECodUrl: { if ( Colon() ) { ok = aMediaObject->SetUrlL( AttrValue() ); EndOfLine(); } break; } case ECodUnknownAttr: { // Name unknown; check colon anyway (syntax check). ok = Colon(); // Rest of the line goes unchecked. break; } default: { // Unexpected value. CodPanic( ECodInternal ); } } if ( !ok ) { Error( KErrCodInvalidDescriptor ); } NextLine(); // Step past LF. return ETrue; // More lines to go. } else { // EOF reached; done. // Note: not expecting EOF in any other place than here (well-formed // COD has complete attrlines. If EOF is found some other place, it // is a syntax error. return EFalse; } }