string_buffer.cpp 635 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include<__vic/string_buffer.h>
  2. #include<iostream>
  3. #include<exception>
  4. #include<cassert>
  5. void run_tests()
  6. {
  7. const size_t intial_capacity = 64;
  8. __vic::string_buffer s(intial_capacity);
  9. assert(s.empty());
  10. assert(s.capacity() >= intial_capacity);
  11. s << 1;
  12. assert(s == "1");
  13. s << ' ' << 2.0 << " " << true;
  14. std::string std_str = s;
  15. s = std_str;
  16. const char *c_str = s;
  17. s.clear() << static_cast<const void *>(c_str);
  18. }
  19. int main()
  20. {
  21. try
  22. {
  23. run_tests();
  24. return 0;
  25. }
  26. catch(const std::exception &ex)
  27. {
  28. std::cerr << ex.what() << '\n';
  29. }
  30. return 1;
  31. }