StringList.cpp 923 B

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