Mercurial > code
comparison C++/tests/Socket/main.cpp @ 370:2c6a4f468499
Socket: add epoll method
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 29 Apr 2015 17:17:35 +0200 |
parents | f3c762579073 |
children | 92457ea8f7e2 |
comparison
equal
deleted
inserted
replaced
369:f3c762579073 | 370:2c6a4f468499 |
---|---|
176 public: | 176 public: |
177 int m_callcount{0}; | 177 int m_callcount{0}; |
178 bool m_added{false}; | 178 bool m_added{false}; |
179 int m_flags{0}; | 179 int m_flags{0}; |
180 | 180 |
181 inline void set(Socket sc, int flags, bool add) noexcept | 181 inline void set(const SocketTable &, Socket sc, int flags, bool add) noexcept |
182 { | 182 { |
183 m_callcount ++; | 183 m_callcount ++; |
184 m_added = add; | 184 m_added = add; |
185 m_flags |= flags; | 185 m_flags |= flags; |
186 } | 186 } |
187 | 187 |
188 inline void unset(Socket, int, bool) noexcept {} | 188 inline void unset(const SocketTable &, Socket, int, bool) noexcept {} |
189 SocketStatus wait(const SocketTable &table, int ms) {} | 189 std::vector<SocketStatus> wait(const SocketTable &table, int ms) {} |
190 std::vector<SocketStatus> waitMultiple(const SocketTable &table, int ms) {} | |
191 }; | 190 }; |
192 | 191 |
193 class TestBackendSetFail { | 192 class TestBackendSetFail { |
194 public: | 193 public: |
195 inline void set(Socket, int, bool) | 194 inline void set(const SocketTable &, Socket, int, bool) |
196 { | 195 { |
197 throw "fail"; | 196 throw "fail"; |
198 } | 197 } |
199 | 198 |
200 inline void unset(Socket, int, bool) noexcept {} | 199 inline void unset(const SocketTable &, Socket, int, bool) noexcept {} |
201 SocketStatus wait(const SocketTable &table, int ms) {} | 200 std::vector<SocketStatus> wait(const SocketTable &table, int ms) {} |
202 std::vector<SocketStatus> waitMultiple(const SocketTable &table, int ms) {} | |
203 }; | 201 }; |
204 | 202 |
205 TEST(ListenerSet, initialAdd) | 203 TEST(ListenerSet, initialAdd) |
206 { | 204 { |
207 SocketListenerBase<TestBackendSet> listener; | 205 SocketListenerBase<TestBackendSet> listener; |
277 bool m_isset{false}; | 275 bool m_isset{false}; |
278 bool m_isunset{false}; | 276 bool m_isunset{false}; |
279 int m_flags{0}; | 277 int m_flags{0}; |
280 bool m_removal{false}; | 278 bool m_removal{false}; |
281 | 279 |
282 inline void set(Socket, int flags, bool) noexcept | 280 inline void set(const SocketTable &, Socket, int flags, bool) noexcept |
283 { | 281 { |
284 m_isset = true; | 282 m_isset = true; |
285 m_flags |= flags; | 283 m_flags |= flags; |
286 } | 284 } |
287 | 285 |
288 inline void unset(Socket, int flags, bool remove) noexcept | 286 inline void unset(const SocketTable &, Socket, int flags, bool remove) noexcept |
289 { | 287 { |
290 m_isunset = true; | 288 m_isunset = true; |
291 m_flags &= ~(flags); | 289 m_flags &= ~(flags); |
292 m_removal = remove; | 290 m_removal = remove; |
293 } | 291 } |
294 | 292 |
295 SocketStatus wait(const SocketTable &table, int ms) {} | 293 std::vector<SocketStatus> wait(const SocketTable &table, int ms) {} |
296 std::vector<SocketStatus> waitMultiple(const SocketTable &table, int ms) {} | |
297 }; | 294 }; |
298 | 295 |
299 class TestBackendUnsetFail { | 296 class TestBackendUnsetFail { |
300 public: | 297 public: |
301 inline void set(Socket, int, bool) noexcept {} | 298 inline void set(const SocketTable &, Socket, int, bool) noexcept {} |
302 | 299 |
303 inline void unset(Socket, int, bool) | 300 inline void unset(const SocketTable &, Socket, int, bool) |
304 { | 301 { |
305 throw "fail"; | 302 throw "fail"; |
306 } | 303 } |
307 | 304 |
308 SocketStatus wait(const SocketTable &table, int ms) {} | 305 std::vector<SocketStatus> wait(const SocketTable &table, int ms) {} |
309 std::vector<SocketStatus> waitMultiple(const SocketTable &table, int ms) {} | |
310 }; | 306 }; |
311 | 307 |
312 TEST(ListenerUnsetRemove, unset) | 308 TEST(ListenerUnsetRemove, unset) |
313 { | 309 { |
314 SocketListenerBase<TestBackendUnset> listener; | 310 SocketListenerBase<TestBackendUnset> listener; |