int main( int /*argc*/, char** /*argv*/ ) { int fail = 0; std::string name; Tag *t; DelayedDelivery *d; JID j( "abc@def/ghi" ); Tag *x = new Tag( "delay", "reason" ); x->addAttribute( "stamp", "invalidstamp" ); x->addAttribute( "from", j.full() ); x->addAttribute( "xmlns", XMLNS_DELAY ); // ------- name = "parsing 0 tag"; d = new DelayedDelivery( 0 ); if( d->tag() != 0 ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; d = 0; // ------- name = "filled object/getters"; d = new DelayedDelivery( j, "invalidstamp", "reason" ); if( d->reason() != "reason" || d->stamp() != "invalidstamp" || d->from() != j ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; d = 0; t = 0; // ------- name = "filled object/tag()"; d = new DelayedDelivery( j, "invalidstamp", "reason" ); t = d->tag(); if( !t || t->name() != "delay" || !t->hasAttribute( "xmlns", XMLNS_DELAY ) || !t->hasAttribute( "from", j.full() ) || !t->hasAttribute( "stamp", "invalidstamp" ) || t->cdata() != "reason" ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; d = 0; t = 0; // ------- name = "from Tag/getters"; d = new DelayedDelivery( x ); if( d->reason() != "reason" || d->stamp() != "invalidstamp" || d->from() != j ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; d = 0; t = 0; // ------- name = "from Tag/tag()"; d = new DelayedDelivery( x ); t = d->tag(); if( !t || t->name() != "delay" || !t->hasAttribute( "xmlns", XMLNS_DELAY ) || !t->hasAttribute( "from", j.full() ) || !t->hasAttribute( "stamp", "invalidstamp" ) || t->cdata() != "reason" ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; d = 0; t = 0; delete x; x = 0; if( fail == 0 ) { printf( "DelayedDelivery: all tests passed\n" ); return 0; } else { printf( "DelayedDelivery: %d test(s) failed\n", fail ); return 1; } }
int main( int /*argc*/, char** /*argv*/ ) { int fail = 0; std::string name; StanzaExtension *se; Tag *t; // ------- name = "OOB test"; OOB *o = new OOB( "url", "desc", false ); t = o->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtOOB ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete o; delete t; delete se; t = 0; // ------- { name = "XDelayedDelivery test"; JID from( "*****@*****.**" ); XDelayedDelivery *x = new XDelayedDelivery( from, "stamp", "reason" ); t = x->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtXDelay ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete x; delete t; delete se; t = 0; } // ------- { name = "DelayedDelivery test"; JID from( "*****@*****.**" ); DelayedDelivery *d = new DelayedDelivery( from, "stamp", "reason" ); t = d->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtDelay ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; delete se; t = 0; } // ------- { name = "VCardUpdate test"; VCardUpdate *d = new VCardUpdate( "hash" ); t = d->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtVCardUpdate ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; delete se; t = 0; } // ------- { name = "GPGSigned test"; GPGSigned *d = new GPGSigned( "signature" ); t = d->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtGPGSigned ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; delete se; t = 0; } // ------- { name = "GPGEncrypted test"; GPGEncrypted *d = new GPGEncrypted( "encrypted" ); t = d->tag(); se = StanzaExtensionFactory::create( t ); if( se->type() != ExtGPGEncrypted ) { ++fail; printf( "test '%s' failed\n", name.c_str() ); } delete d; delete t; delete se; t = 0; } if( fail == 0 ) { printf( "StanzaExtensionFactory: all tests passed\n" ); return 0; } else { printf( "StanzaExtensionFactory: %d test(s) failed\n", fail ); return 1; } }