string_test.cpp 614 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright 2010-2016 Branimir Karadzic. All rights reserved.
  3. * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. */
  5. #include "test.h"
  6. #include <bx/string.h>
  7. #include <bx/crtimpl.h>
  8. #include <bx/handlealloc.h>
  9. bx::AllocatorI* g_allocator;
  10. TEST_CASE("StringView", "")
  11. {
  12. bx::StringView sv("test");
  13. REQUIRE(4 == sv.getLength() );
  14. bx::CrtAllocator crt;
  15. g_allocator = &crt;
  16. typedef bx::StringT<&g_allocator> String;
  17. String st(sv);
  18. REQUIRE(4 == st.getLength() );
  19. st.clear();
  20. REQUIRE(0 == st.getLength() );
  21. REQUIRE(4 == sv.getLength() );
  22. sv.clear();
  23. REQUIRE(0 == sv.getLength() );
  24. }