offset != -1 && (max == 0 || max > int(l.size()) + 1);
offset = v.find(pattern, offset + pattern.size(), byteAlign))
{
- if(offset - previousOffset > 1)
+ if(offset - previousOffset >= 1)
l.append(v.mid(previousOffset, offset - previousOffset));
else
l.append(ByteVector::null);
--- /dev/null
+#include <cppunit/extensions/HelperMacros.h>
+#include <tbytevector.h>
+#include <tbytevectorlist.h>
+
+using namespace std;
+using namespace TagLib;
+
+class TestByteVectorList : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(TestByteVectorList);
+ CPPUNIT_TEST(testSplitSingleChar);
+ CPPUNIT_TEST(testSplitSingleChar_2);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+ void testSplitSingleChar()
+ {
+ ByteVector v("a b");
+
+ ByteVectorList l = ByteVectorList::split(v, " ");
+ CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), l.size());
+ CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]);
+ CPPUNIT_ASSERT_EQUAL(ByteVector("b"), l[1]);
+ }
+
+ void testSplitSingleChar_2()
+ {
+ ByteVector v("a");
+
+ ByteVectorList l = ByteVectorList::split(v, " ");
+ CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), l.size());
+ CPPUNIT_ASSERT_EQUAL(ByteVector("a"), l[0]);
+ }
+
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TestByteVectorList);