示例#1
0
        public void Test_StringManipulator_IndexOfStringStartIndexInLaterSectionNotFound()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cru");
            m.Append("el world");

            Assert.AreEqual("hello cruel world".IndexOf("k", 7), m.IndexOf("k", 7));
        }
示例#2
0
        public void Test_StringManipulator_InsertString()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello");
            m.Append("  world");
            m.Insert("cruel", 6);
            Assert.AreEqual("hello cruel world", m.ToString());
        }
示例#3
0
        public void Test_StringManipulator_IndexOfStringStartIndex()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cru");
            m.Append("el world");

            Assert.AreEqual("hello cruel world".IndexOf("l", 3), m.IndexOf("l", 3));
        }
示例#4
0
        public void Test_StringManipulator_AddTwoStrings()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello");
            m.Append(" world");

            Assert.AreEqual("hello world", m.ToString());
        }
示例#5
0
        public void Test_StringManipulator_IndexOfSingleLetter()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cru");
            m.Append("el world");

            Assert.AreEqual("hello".IndexOf('l'), m.IndexOf("l"));
        }
示例#6
0
        public void Test_StringManipulator_IndexOfStringInSecondSections()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cru");
            m.Append("el world");

            Assert.AreEqual("hello cruel world".IndexOf("rld"), m.IndexOf("rld"));
        }
示例#7
0
        public void Test_StringManipulator_SubstringMultipleSection()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cru");
            m.Append("el world");

            Assert.AreEqual("cruel", m.Substring(6, 5));
        }
示例#8
0
        public void Test_StringManipulator_RemoveWholeFirstSection()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello ");
            m.Append("world");
            m.Remove("hello ");

            Assert.AreEqual("world", m.ToString());
        }
示例#9
0
        public void Test_StringManipulator_RemoveSingleStringAcrossTwoSections()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cr");
            m.Append("uel world");
            m.Remove("cruel");

            Assert.AreEqual("hello  world", m.ToString());
        }
示例#10
0
        public void Test_StringManipulator_RemoveWholeLastSectionAndReplace()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello ");
            m.Append("cruel ");
            m.Append("world");
            m.Replace("world", "suzy");

            Assert.AreEqual("hello cruel suzy", m.ToString());
        }
示例#11
0
        public void Test_StringManipulator_RemoveMidTextAndReplace()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello");
            m.Append(" cruel ");
            m.Append("world");
            m.Replace(" cruel ", " big ");

            Assert.AreEqual("hello big world", m.ToString());
        }
示例#12
0
        public void Test_StringManipulator_RemoveSingleStringAcrossThreeSections()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cr");
            m.Append("u");
            m.Append("el world");
            m.Remove("cruel");

            Assert.AreEqual("hello  world", m.ToString());
            Assert.AreEqual("hello  world".Length, m.Length, "The Lengths should be the same too");
        }
示例#13
0
        private static void TestStringManipulator()
        {
            Console.Write("String Manipulator: ");
            Stopwatch sw = new Stopwatch();

            sw.Start();

            var sb = new StringManipulator();

            for (int x = 0; x < 1000; x++)
            {
                sb.Append("Hello ");
            }

            for (int x = 0; x < 1000; x++)
            {
                sb.Insert("World", 50);
            }

            for (int x = 0; x < 1000; x++)
            {
                sb.Replace("Hello ", "Hey ");
            }
            sw.Stop();

            Console.WriteLine(sw.ElapsedMilliseconds);
        }
示例#14
0
        public void TestTimingSM()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            var sb = new StringManipulator();

            for (int x = 0; x < 1000; x++)
            {
                sb.Append("Hello ");
            }

            for (int x = 0; x < 1000; x++)
            {
                sb.Insert("World", 50);
            }

            for (int x = 0; x < 1000; x++)
            {
                sb.Replace("Hello ", "Hey ");
            }
            sw.Stop();

            Assert.IsFalse(true, $"{sw.ElapsedMilliseconds}");
        }
示例#15
0
        public void Test_StringManipulator_ReplaceMany()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cruel world");
            m.Replace("l", "L");

            Assert.AreEqual("heLLo crueL worLd", m.ToString());
        }
示例#16
0
        public void Test_StringManipulator_RemoveTwoStringsInsideSection()
        {
            StringManipulator m = new StringManipulator();

            m.Append("hello cruel world");
            m.Remove("l");

            Assert.AreEqual("heo crue word", m.ToString());
        }