ascii_toupper.cpp 816 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include<__vic/ascii_string.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. #include<cstring>
  6. #include<string>
  7. namespace tests {
  8. void tolower_tests()
  9. {
  10. char st[] = "aBcDe";
  11. std::string str(st);
  12. __vic::ascii::tolower(st);
  13. assert(std::strcmp(st, "abcde") == 0);
  14. __vic::ascii::tolower(str);
  15. assert(str == "abcde");
  16. }
  17. void toupper_tests()
  18. {
  19. char st[] = "aBcDe";
  20. std::string str(st);
  21. __vic::ascii::toupper(st);
  22. assert(std::strcmp(st, "ABCDE") == 0);
  23. __vic::ascii::toupper(str);
  24. assert(str == "ABCDE");
  25. }
  26. void run()
  27. {
  28. tolower_tests();
  29. toupper_tests();
  30. }
  31. } // namespace
  32. int main()
  33. {
  34. try
  35. {
  36. tests::run();
  37. return 0;
  38. }
  39. catch(const std::exception &ex)
  40. {
  41. std::cerr << ex.what() << '\n';
  42. }
  43. return 1;
  44. }