コード例 #1
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);
        }
コード例 #2
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}");
        }
コード例 #3
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());
        }