string_stack.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "simple/file/string_stack.h"
  2. #include <cassert>
  3. using namespace simple::file::string_stack;
  4. void FreeFunctions()
  5. {
  6. // TODO
  7. }
  8. void Manipulator()
  9. {
  10. std::string s;
  11. {
  12. manipulator m(s);
  13. m.push("abc");
  14. assert(s == "abc");
  15. m.push("123");
  16. assert(s == "abc/123");
  17. m.push("x", "y", "z");
  18. assert(s == "abc/123/x/y/z");
  19. assert(m.pop() == "z");
  20. assert(s == "abc/123/x/y/");
  21. assert(m.pop() == "y/");
  22. assert(s == "abc/123/x/");
  23. m.drop();
  24. assert(s == "abc/123/");
  25. }
  26. assert(s == "");
  27. {
  28. manipulator m(s);
  29. m.push("x", "y", "z");
  30. assert(s == "x/y/z");
  31. m.release();
  32. }
  33. assert(s == "x/y/z");
  34. {
  35. manipulator m(s);
  36. assert(m.pop() == "z");
  37. assert(s == "x/y/");
  38. assert(m.pop() == "y/");
  39. assert(s == "x/");
  40. assert(m.pop() == "x/");
  41. assert(s == "");
  42. assert(m.pop() == "");
  43. assert(s == "");
  44. assert(m.pop() == "");
  45. assert(s == "");
  46. assert(m.pop() == "");
  47. assert(s == "");
  48. assert(m.pop() == "");
  49. assert(s == "");
  50. }
  51. assert(s == "");
  52. {
  53. // TODO: delimiters
  54. }
  55. {
  56. std::string s2 = "";
  57. manipulator m(s);
  58. manipulator m2(s2);
  59. m.push("a", "b", "c");
  60. m2.push("x", "y", "z");
  61. assert(s == "a/b/c");
  62. assert(s2 == "x/y/z");
  63. m = std::move(m2);
  64. assert(s == "");
  65. assert(s2 == "x/y/z");
  66. }
  67. }
  68. int main()
  69. {
  70. FreeFunctions();
  71. Manipulator();
  72. return 0;
  73. }