12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #include "simple/file/string_stack.h"
- #include <cassert>
- using namespace simple::file::string_stack;
- void FreeFunctions()
- {
- // TODO
- }
- void Manipulator()
- {
- std::string s;
- {
- manipulator m(s);
- m.push("abc");
- assert(s == "abc");
- m.push("123");
- assert(s == "abc/123");
- m.push("x", "y", "z");
- assert(s == "abc/123/x/y/z");
- assert(m.pop() == "z");
- assert(s == "abc/123/x/y/");
- assert(m.pop() == "y/");
- assert(s == "abc/123/x/");
- m.drop();
- assert(s == "abc/123/");
- }
- assert(s == "");
- {
- manipulator m(s);
- m.push("x", "y", "z");
- assert(s == "x/y/z");
- m.release();
- }
- assert(s == "x/y/z");
- {
- manipulator m(s);
- assert(m.pop() == "z");
- assert(s == "x/y/");
- assert(m.pop() == "y/");
- assert(s == "x/");
- assert(m.pop() == "x/");
- assert(s == "");
- assert(m.pop() == "");
- assert(s == "");
- assert(m.pop() == "");
- assert(s == "");
- assert(m.pop() == "");
- assert(s == "");
- assert(m.pop() == "");
- assert(s == "");
- }
- assert(s == "");
- {
- // TODO: delimiters
- }
- {
- std::string s2 = "";
- manipulator m(s);
- manipulator m2(s2);
- m.push("a", "b", "c");
- m2.push("x", "y", "z");
- assert(s == "a/b/c");
- assert(s2 == "x/y/z");
- m = std::move(m2);
- assert(s == "");
- assert(s2 == "x/y/z");
- }
- }
- int main()
- {
- FreeFunctions();
- Manipulator();
- return 0;
- }
|