Changeset 6073

Show
Ignore:
Timestamp:
02/24/08 20:45:56 (8 months ago)
Author:
erijo
Message:

Added test case to check that a descriptor can only be added once.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/newapi/licq/src/event/test/descriptorsettest.cpp

    r6072 r6073  
    1919 
    2020#include "event/descriptorset.h" 
     21#include "licq/exception/invalidargumentexception.h" 
    2122#include "test/recorder.h" 
    2223#include "util/pipe.h" 
     
    4950{ 
    5051  reset(); 
    51  
    5252  LicqDaemon::DescriptorSet set(Licq::EventLoop::Read); 
    5353 
     
    6161  maxFd = set.getFdSet(&fds); 
    6262  BOOST_CHECK_EQUAL(maxFd, pipe.getReadFd()); 
     63  BOOST_CHECK(FD_ISSET(pipe.getReadFd(), &fds)); 
    6364 
    6465  pipe.putc('A'); 
     
    7475{ 
    7576  reset(); 
    76  
    7777  LicqDaemon::DescriptorSet set(Licq::EventLoop::Read); 
    7878 
     
    8686    maxFd = set.getFdSet(&fds); 
    8787    BOOST_CHECK_EQUAL(maxFd, pipe.getReadFd()); 
     88    BOOST_CHECK(FD_ISSET(pipe.getReadFd(), &fds)); 
    8889 
    8990    set.removeBadDescriptors(); 
    9091    maxFd = set.getFdSet(&fds); 
    9192    BOOST_CHECK_EQUAL(maxFd, pipe.getReadFd()); 
     93    BOOST_CHECK(FD_ISSET(pipe.getReadFd(), &fds)); 
    9294  } 
    9395 
     
    9799} 
    98100 
     101BOOST_AUTO_TEST_CASE(duplicate) 
     102{ 
     103  reset(); 
     104  LicqDaemon::DescriptorSet set(Licq::EventLoop::Read); 
     105 
     106  // A descriptor should only be added once 
     107  set.addDescriptor(0, this); 
     108  BOOST_CHECK_THROW(set.addDescriptor(0, this), Licq::InvalidArgumentException); 
     109  set.removeDescriptor(0); 
     110} 
     111 
    99112BOOST_AUTO_TEST_SUITE_END()