+static void TestBufStringManipulation(void)
+{
+ long len, i = 0;
+ StrBuf *dest = NewStrBuf ();
+ StrBuf *Buf = NewStrBufPlain(HKEY("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
+
+ StrBufSub(dest, Buf, -5, i);
+ len = StrLength(Buf);
+ for (i = 0; i < len + 10; i++)
+ {
+ StrBufSub(dest, Buf, 5, i);
+ if (i + 5 < len)
+ {
+ CU_ASSERT(StrLength(dest) == i);
+ }
+ else
+ {
+ CU_ASSERT(StrLength(dest) == len - 5);
+ }
+ }
+ FreeStrBuf(&dest);
+ dest = NewStrBuf ();
+ StrBufSub(dest, Buf, -5, 200);
+
+ StrBufCutLeft(Buf, 5);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
+ CU_ASSERT(StrLength(Buf) == 95);
+
+ StrBufCutRight(Buf, 5);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 90);
+
+ StrBufCutAt(Buf, 80, NULL);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 80);
+
+ StrBufCutAt(Buf, -1, ChrPtr(Buf) + 70);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"6789012345678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 70);
+
+
+ StrBufCutAt(Buf, 0, ChrPtr(Buf) + 60);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 60);
+
+ StrBufCutAt(Buf, 0, ChrPtr(Buf) + 70);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 60);
+
+ StrBufCutAt(Buf, 70, NULL);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
+ CU_ASSERT(StrLength(Buf) == 60);
+
+
+ StrBufCutLeft(Buf, 70);
+ CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"");
+ CU_ASSERT(StrLength(Buf) == 0);