set_of_chars.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include<__vic/set_of_chars.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. __vic::set_of_chars set;
  8. for(int c = 0; c < 256; c++)
  9. assert(!set.contains((unsigned char) c));
  10. set.add('a');
  11. assert(set.contains('a'));
  12. assert(!set.contains('b'));
  13. set.add('b');
  14. assert(set.contains('a') && set.contains('b'));
  15. set.remove('a');
  16. assert(!set.contains('a') && set.contains('b'));
  17. set.assign("123");
  18. assert(set.contains('1'));
  19. assert(set.contains('2'));
  20. assert(set.contains('3'));
  21. assert(!set.contains('a'));
  22. assert(!set.contains('b'));
  23. assert(!set.contains('0'));
  24. assert(!set.contains('4'));
  25. #if __cpp_initializer_lists
  26. set.assign({'1', '2', '3'});
  27. assert(set.contains('1'));
  28. assert(set.contains('2'));
  29. assert(set.contains('3'));
  30. assert(!set.contains('a'));
  31. assert(!set.contains('b'));
  32. assert(!set.contains('0'));
  33. assert(!set.contains('4'));
  34. #endif
  35. }
  36. int main()
  37. {
  38. try
  39. {
  40. run_tests();
  41. return 0;
  42. }
  43. catch(const std::exception &ex)
  44. {
  45. std::cerr << ex.what() << '\n';
  46. }
  47. return 1;
  48. }