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); }
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}"); }
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()); }