public void testAsBase() { StringTheory theory = new StringTheory("11111111"); Assert.True(theory.AsBase(2) == 0xff, "Base 2 strings don't match"); Assert.True(theory.AsBase(8) == 0x249249, "Base 8 strings don't match"); Assert.True(theory.AsBase(0x10) == 0x11111111, "Base 16 strings don't match"); theory.PasteOver("111111"); Assert.True(theory.AsBase(0x1f) == 0, "Base 31 strings should yield zero." + theory.AsBase(0x1f)); }
public void testpasteOver() { string str = "MaresEatOats"; StringTheory theory = new StringTheory("MaresChowDownOnOats"); theory.PasteOver(5, 10, "Eat"); Assert.True(str.Equals(theory.ToString()), "overwritten (1) str doesn't match the comparison string!"); str = "MaresEatOats"; theory = new StringTheory("lorem ipsum"); theory.PasteOver("MaresEatOats"); Assert.True(str.Equals(theory.ToString()), "overwritten (2) str doesn't match the comparison string!"); }
public void testLeftJustify() { string str = "abcdef \t \t "; StringTheory theory = new StringTheory(" abcdef \t \t "); theory.LeftJustify(); Assert.True(str.Equals(theory.ToString()), "leftJustify str doesn't match the comparison string!"); theory.PasteOver(" "); theory.LeftJustify(); Assert.True(theory.Length == 6, "leftJustify str length isnt' right"); }
public void testCutThruLast() { string str = " Oats"; StringTheory theory = new StringTheory("Mares Eat Oats Mares Eat Oats"); string str2 = theory.CutThruLast("Eat"); Assert.True(str.Equals(theory.ToString()), "The resulting string is wrong."); Assert.True(str2.Equals("Mares Eat Oats Mares Eat"), "The emitted string is wrong."); theory.PasteOver("Mares Eat Oats"); string str3 = theory.CopyAfter("XYZ"); Assert.True("Mares Eat Oats".Equals(theory.ToString()), "[bogus] The resulting string is wrong."); Assert.True(str3.Length < 1, "[bogus] The Cut string is wrong."); }
public void testSplitToStrings() { StringTheory theory = new StringTheory("mares*eat*oats"); string[] strArray = theory.SplitToStrings('*'); Assert.AreEqual(3, strArray.Length, "1) Wrong number of strings returned"); Assert.AreEqual("mares", strArray[0], "1) Returned list item[0] doesn't match."); Assert.AreEqual("eat", strArray[1], "1) Returned list item[1] doesn't match."); Assert.AreEqual("oats", strArray[2], "1) Returned list item[2] doesn't match."); theory.PasteOver("maresFOOBAReatFOOBARoats"); strArray = theory.SplitToStrings("FOOBAR"); Assert.AreEqual(3, strArray.Length, "2) Wrong number of strings returned"); Assert.AreEqual("mares", strArray[0], "2) Returned list item[0] doesn't match."); Assert.AreEqual("eat", strArray[1], "2) Returned list item[1] doesn't match."); Assert.AreEqual("oats", strArray[2], "2) Returned list item[2] doesn't match."); }
public void testSplit() { StringTheory theory = new StringTheory("mares*eat*oats"); ArrayList list = theory.Split('*'); Assert.AreEqual(3, list.Count, "1) Wrong number of strings returned"); Assert.AreEqual("mares", list[0].ToString(), "1) Returned list item[0] doesn't match."); Assert.AreEqual("eat", list[1].ToString(), "1) Returned list item[1] doesn't match."); Assert.AreEqual("oats", list[2].ToString(), "1) Returned list item[2] doesn't match."); theory.PasteOver("maresFOOBAReatFOOBARoats"); list = theory.Split("FOOBAR"); Assert.AreEqual(3, list.Count, "2) Wrong number of strings returned"); Assert.AreEqual("mares", list[0].ToString(), "2) Returned list item[0] doesn't match."); Assert.AreEqual("eat", list[1].ToString(), "2) Returned list item[1] doesn't match."); Assert.AreEqual("oats", list[2].ToString(), "2) Returned list item[2] doesn't match."); }