void TestDistrList::testDuplicate() { kDebug() ; // This is a special test for the case where we have a contact and a distr list with the same name KABC::AddressBook *ab = KABC::StdAddressBook::self(); KABC::Addressee addr; addr.setName( "foo" ); addr.insertEmail( "*****@*****.**", true ); ab->insertAddressee( addr ); #if 0 // we need a findByFormattedName KABC::Addressee::List addrList = ab->findByName( "foo" ); assert( addrList.count() == 2 ); bool a = DistributionList::isDistributionList( addrList.first() ); bool b = DistributionList::isDistributionList( addrList.last() ); // one is a distr list, but not both assert( a || b ); // assert( ! ( a && b ) ); #endif DistributionList dl = DistributionList::findByName( ab, "foo" ); assert( !dl.isEmpty() ); assert( DistributionList::isDistributionList( dl ) ); assert( dl.formattedName() == "foo" ); }
void TestDistrList::testNewList() { kDebug() ; DistributionList dl; dl.setName( "foo" ); assert( !dl.isEmpty() ); check( "name set", dl.formattedName(), "foo" ); assert( DistributionList::isDistributionList( dl ) ); KABC::AddressBook *ab = KABC::StdAddressBook::self(); ab->insertAddressee( dl ); #if 0 // can't do that until we have KABC::AddressBook::findByFormattedName, or we use setName() KABC::Addressee::List addrList = ab->findByName( "foo" ); assert( addrList.count() == 1 ); KABC::Addressee addr = addrList.first(); assert( !addr.isEmpty() ); check( "correct name", addr.name(), "foo" ); assert( DistributionList::isDistributionList( addr ) ); #else KABC::Addressee addr = dl; #endif DistributionList dl2 = DistributionList::findByName( ab, "foo" ); assert( !dl2.isEmpty() ); check( "correct name", dl2.formattedName(), "foo" ); assert( DistributionList::isDistributionList( dl2 ) ); // Test the ctor that takes an addressee DistributionList dl3( addr ); assert( !dl3.isEmpty() ); assert( DistributionList::isDistributionList( dl3 ) ); check( "correct name", dl3.formattedName(), "foo" ); }