StringList.cpp 880 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2009-2022, 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. ANKI_TEST(Util, StringList)
  8. {
  9. HeapAllocator<U8> alloc(allocAligned, nullptr);
  10. // Test splitString
  11. {
  12. CString toSplit = "foo\n\nboo\n";
  13. StringListAuto list(alloc);
  14. list.splitString(toSplit, '\n');
  15. ANKI_TEST_EXPECT_EQ(list.getSize(), 2);
  16. auto it = list.getBegin();
  17. ANKI_TEST_EXPECT_EQ(*it, "foo");
  18. ++it;
  19. ANKI_TEST_EXPECT_EQ(*it, "boo");
  20. // Again
  21. list.destroy();
  22. list.splitString(toSplit, '\n', true);
  23. ANKI_TEST_EXPECT_EQ(list.getSize(), 3);
  24. it = list.getBegin();
  25. ANKI_TEST_EXPECT_EQ(*it, "foo");
  26. ++it;
  27. ANKI_TEST_EXPECT_EQ(it->isEmpty(), true);
  28. ++it;
  29. ANKI_TEST_EXPECT_EQ(*it, "boo");
  30. }
  31. }