StringList.cpp 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <Tests/Framework/Framework.h>
  6. #include "anki/util/StringList.h"
  7. namespace anki
  8. {
  9. ANKI_TEST(Util, StringList)
  10. {
  11. HeapAllocator<U8> alloc(allocAligned, nullptr);
  12. // Test splitString
  13. {
  14. CString toSplit = "foo\n\nboo\n";
  15. StringListAuto list(alloc);
  16. list.splitString(toSplit, '\n');
  17. ANKI_TEST_EXPECT_EQ(list.getSize(), 2);
  18. auto it = list.getBegin();
  19. ANKI_TEST_EXPECT_EQ(*it, "foo");
  20. ++it;
  21. ANKI_TEST_EXPECT_EQ(*it, "boo");
  22. // Again
  23. list.destroy();
  24. list.splitString(toSplit, '\n', true);
  25. ANKI_TEST_EXPECT_EQ(list.getSize(), 3);
  26. it = list.getBegin();
  27. ANKI_TEST_EXPECT_EQ(*it, "foo");
  28. ++it;
  29. ANKI_TEST_EXPECT_EQ(it->isEmpty(), true);
  30. ++it;
  31. ANKI_TEST_EXPECT_EQ(*it, "boo");
  32. }
  33. }
  34. } // end namespace anki