posix_sigset.cpp 831 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include<__vic/posix/sigset.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. using __vic::posix::sigset;
  8. sigset set = sigset::empty();
  9. assert(!set.is_member(SIGTERM));
  10. set += SIGTERM;
  11. assert(set.is_member(SIGTERM));
  12. set -= SIGTERM;
  13. assert(!set.is_member(SIGTERM));
  14. assert(!set.is_member(SIGINT));
  15. set << SIGINT >> SIGINT;
  16. assert(!set.is_member(SIGINT));
  17. int sigs[] = { SIGINT, SIGTERM };
  18. sigset set2(sigs);
  19. assert(set2.is_member(SIGINT));
  20. assert(set2.is_member(SIGTERM));
  21. set2 = sigs;
  22. assert(set2.is_member(SIGINT));
  23. assert(set2.is_member(SIGTERM));
  24. }
  25. int main()
  26. {
  27. try
  28. {
  29. run_tests();
  30. return 0;
  31. }
  32. catch(const std::exception &ex)
  33. {
  34. std::cerr << ex.what() << '\n';
  35. }
  36. return 1;
  37. }