Example #1
0
        public void String8_ShiftBack()
        {
            String8Block block = new String8Block();

            // Goal: Split on semi-colon, collapse semi-colon and spaces in-place
            String8 shiftable  = "One; Two;Three; Four".TestConvert();
            int     totalShift = 0;

            String8Set parts = shiftable.Split(UTF8.Semicolon, new PartialArray <int>(5, false));

            for (int i = 0; i < parts.Count; ++i)
            {
                String8 part = parts[i];

                totalShift++;
                if (part.StartsWith(UTF8.Space))
                {
                    part = part.Substring(1);
                    totalShift++;
                }

                String8 beforeShift = block.GetCopy(part);
                String8 shifted     = part.ShiftBack(totalShift);
                Assert.AreEqual(beforeShift, shifted);
            }

            String8 result = shiftable.Substring(0, shiftable.Length - totalShift);

            Assert.AreNotEqual("OneTwoThreeFour", result.ToString());
        }