libtasks Documentation  1.6
test_socket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ADTECH GmbH
3  * Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4  *
5  * Author: Andreas Pohl
6  */
7 
8 #include <cppunit/TestCase.h>
9 #include <cppunit/TestFixture.h>
10 #include <cppunit/extensions/HelperMacros.h>
11 
12 #include <queue>
13 #include <vector>
14 
15 class echo_handler : public tasks::net_io_task {
16  public:
18  bool handle_event(tasks::worker* worker, int revents);
19 
20  private:
21  std::queue<std::vector<char> > m_write_queue;
22  ssize_t m_write_offset = 0;
23 };
24 
25 class test_socket : public CppUnit::TestFixture {
31 
32  public:
33  void setUp() {}
34  void tearDown() {}
35 
36  protected:
37  void tcp();
38  void udp();
39  void unix();
40 };
CPPUNIT_TEST_SUITE(test_socket)
void setUp()
Definition: test_socket.h:33
The net_io_task implements the base for socket based network tasks.
Definition: net_io_task.h:21
CPPUNIT_TEST_SUITE_END()
bool handle_event(tasks::worker *worker, int revents)
Definition: echoserver.cpp:28
The socket class.
Definition: socket.h:35
echo_handler(tasks::net::socket &socket)
Definition: test_socket.h:17
CPPUNIT_TEST(tcp)
net_io_task(int events)
Definition: net_io_task.h:23
net::socket & socket()
Provide access to the underlying socket object.
Definition: net_io_task.h:35
std::queue< std::vector< char > > m_write_queue
Definition: echoserver.h:46
ssize_t m_write_offset
Definition: echoserver.h:47
void tearDown()
Definition: test_socket.h:34