test_udp.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 
  2. #include "hello_test.h"
  3. #define UDP_ASYNC_COUNT 100
  4. TEST_F(HelloTest, udpSyncGlobalCommunicator)
  5. {
  6. shared_ptr<Communicator> c = getCommunicator();
  7. transGlobalCommunicator([&](Communicator *comm){
  8. checkSync(comm, "UdpObjAdapter");
  9. }, c.get());
  10. }
  11. TEST_F(HelloTest, udpASyncGlobalCommunicator)
  12. {
  13. shared_ptr<Communicator> c = getCommunicator();
  14. int count = _count;
  15. _count = UDP_ASYNC_COUNT;
  16. //异步udp, 发送太快了会丢包
  17. transGlobalCommunicator([&](Communicator *comm){
  18. checkASync(comm, "UdpObjAdapter");
  19. }, c.get());
  20. _count = count;
  21. }
  22. TEST_F(HelloTest, udpASyncGlobalCommunicatorInCoroutine)
  23. {
  24. shared_ptr<Communicator> c = getCommunicator();
  25. int count = _count;
  26. _count = UDP_ASYNC_COUNT;
  27. transInCoroutineGlobalCommunicator([&](Communicator *comm){
  28. checkASync(comm, "UdpObjAdapter");
  29. }, c.get());
  30. _count = count;
  31. }
  32. TEST_F(HelloTest, udpIpV6SyncGlobalCommunicator)
  33. {
  34. shared_ptr<Communicator> c = getCommunicator();
  35. transGlobalCommunicator([&](Communicator *comm){
  36. checkSync(comm, "UdpIpv6Adapter");
  37. }, c.get());
  38. }
  39. TEST_F(HelloTest, udpIpV6ASyncGlobalCommunicatorInCoroutine)
  40. {
  41. shared_ptr<Communicator> c = getCommunicator();
  42. int count = _count;
  43. _count = UDP_ASYNC_COUNT;
  44. transInCoroutineGlobalCommunicator([&](Communicator *comm){
  45. checkASync(comm, "UdpIpv6Adapter");
  46. }, c.get());
  47. _count = count;
  48. }