void KNewStuff2Test::entryTest() { kDebug() << "-- test kns2 entry class"; QDomDocument doc; QFile f(QString("%1/testdata/entry.xml").arg(KNSSRCDIR)); if (!f.open(QIODevice::ReadOnly)) { kDebug() << "Error loading entry file."; quitTest(); } if (!doc.setContent(&f)) { kDebug() << "Error parsing entry file."; f.close(); quitTest(); } f.close(); KNS::EntryHandler eh(doc.documentElement()); KNS::Entry e = eh.entry(); kDebug() << "-- xml->entry test result: " << eh.isValid(); KNS::EntryHandler eh2(e); QDomElement exml = eh2.entryXML(); kDebug() << "-- entry->xml test result: " << eh.isValid(); if (!eh.isValid()) { quitTest(); } else { QTextStream out(stdout); out << exml; } }
void purge_with_multiple_matches(char const * test_name) { ACE_Notification_Queue queue; Event_Handler eh1(1); Event_Handler eh2(2); int result = queue.push_new_notification( ACE_Notification_Buffer(&eh1, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK)); result = queue.push_new_notification( ACE_Notification_Buffer(&eh1, ACE_Event_Handler::WRITE_MASK)); result = queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::READ_MASK)); result = queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::WRITE_MASK)); result = queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::WRITE_MASK)); result = queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::WRITE_MASK)); result = queue.purge_pending_notifications(&eh2, ACE_Event_Handler::WRITE_MASK); TEST_EQUAL(result, 3, "purge of eh2/WRITE should return 3"); result = queue.purge_pending_notifications(&eh1, ACE_Event_Handler::WRITE_MASK); TEST_EQUAL(result, 1, "purge of eh1/WRITE should return 1"); }
void pop_returns_element_pushed(char const * test_name) { ACE_Notification_Queue queue; Event_Handler eh1(1); Event_Handler eh2(2); Event_Handler eh3(2); int result = queue.push_new_notification( ACE_Notification_Buffer(&eh1, ACE_Event_Handler::READ_MASK)); TEST_ASSERT(result == 1, "push[1] should return 1"); result = queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::WRITE_MASK)); TEST_ASSERT(result == 0, "push[2] should return 0"); result = queue.push_new_notification( ACE_Notification_Buffer(&eh3, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK)); TEST_ASSERT(result == 0, "push[3] should return 0"); ACE_Notification_Buffer current; bool more_messages_queued; ACE_Notification_Buffer next; result = queue.pop_next_notification(current, more_messages_queued, next); TEST_ASSERT(result == 1, "pop[0] should return 1"); TEST_ASSERT(more_messages_queued, "pop[0] should have more messages"); TEST_EQUAL(current.eh_, &eh1, "Wrong handler extracted"); TEST_EQUAL(current.mask_, ACE_Event_Handler::READ_MASK, "Wrong mask extracted"); result = queue.pop_next_notification(current, more_messages_queued, next); TEST_ASSERT(result == 1, "pop[1] should return 1"); TEST_ASSERT(more_messages_queued, "pop[1] should have more messages"); TEST_EQUAL(current.eh_, &eh2, "Wrong handler extracted"); TEST_EQUAL(current.mask_, ACE_Event_Handler::WRITE_MASK, "Wrong mask extracted"); result = queue.pop_next_notification(current, more_messages_queued, next); TEST_ASSERT(result == 1, "pop[2] should return 1"); TEST_ASSERT(!more_messages_queued, "pop[2] should not have more messages"); TEST_EQUAL(current.eh_, &eh3, "Wrong handler extracted"); TEST_EQUAL(current.mask_, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK, "Wrong mask extracted"); more_messages_queued = true; result = queue.pop_next_notification(current, more_messages_queued, next); TEST_ASSERT(result == 0, "pop[3] should return 0"); TEST_ASSERT(!more_messages_queued, "pop[3] should not have more messages"); }
void purge_with_no_matches(char const * test_name) { ACE_Notification_Queue queue; Event_Handler eh1(1); Event_Handler eh2(2); int result = queue.push_new_notification( ACE_Notification_Buffer(&eh1, ACE_Event_Handler::READ_MASK)); result = queue.purge_pending_notifications(&eh2, ACE_Event_Handler::READ_MASK); TEST_ASSERT(result == 0, "purge of eh2 should return 0"); result = queue.purge_pending_notifications(&eh1, ACE_Event_Handler::WRITE_MASK); TEST_ASSERT(result == 0, "purge of eh1/WRITE should return 0"); }
void reset_non_empty_queue(char const * /* test_name */) { ACE_Notification_Queue queue; Event_Handler eh1(1); Event_Handler eh2(2); queue.push_new_notification( ACE_Notification_Buffer(0, ACE_Event_Handler::READ_MASK)); queue.push_new_notification( ACE_Notification_Buffer(&eh1, ACE_Event_Handler::READ_MASK)); queue.push_new_notification( ACE_Notification_Buffer(&eh2, ACE_Event_Handler::WRITE_MASK)); queue.push_new_notification( ACE_Notification_Buffer(0, ACE_Event_Handler::WRITE_MASK)); queue.reset(); }