test_tb_tempbuffer.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // ================================================================================
  2. // == This file is a part of Turbo Badger. (C) 2011-2014, Emil Segerås ==
  3. // == See tb_core.h for more information. ==
  4. // ================================================================================
  5. #include "tb_test.h"
  6. #include "tb_tempbuffer.h"
  7. #ifdef TB_UNIT_TESTING
  8. using namespace tb;
  9. TB_TEST_GROUP(tb_tempbuffer)
  10. {
  11. TB_TEST(append_path_1)
  12. {
  13. TBTempBuffer buf;
  14. buf.AppendPath("foo.txt");
  15. TB_VERIFY_STR(buf.GetData(), "./");
  16. }
  17. TB_TEST(append_path_2)
  18. {
  19. TBTempBuffer buf;
  20. buf.AppendPath("Path/subpath/foo.txt");
  21. TB_VERIFY_STR(buf.GetData(), "Path/subpath/");
  22. }
  23. TB_TEST(append_path_3)
  24. {
  25. TBTempBuffer buf;
  26. buf.AppendPath("C:\\test\\foo.txt");
  27. TB_VERIFY_STR(buf.GetData(), "C:\\test\\");
  28. }
  29. TB_TEST(append_string)
  30. {
  31. TBTempBuffer buf;
  32. buf.AppendString("xxxxxxxxxx");
  33. TB_VERIFY(buf.GetAppendPos() == 10);
  34. TB_VERIFY_STR(buf.GetData(), "xxxxxxxxxx");
  35. buf.SetAppendPos(0);
  36. buf.AppendString("Foo");
  37. buf.AppendString("Bar");
  38. TB_VERIFY_STR(buf.GetData(), "FooBar");
  39. }
  40. }
  41. #endif // TB_UNIT_TESTING