Ejemplo n.º 1
0
 public void testReplace()
 {
     StringTheory theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus.");
     StringTheory theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     int num = theory2.Replace("$", " ");
     Assert.True(num == 7, "Reported number of tilted slashes was wrong.");
     Assert.True(theory2.Equals(theory), "Chars didn't translate properly.");
     theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus.");
     theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     num = theory2.Replace('$', ' ');
     Assert.True(num == 7, "Reported number of tilted slashes was wrong.");
     Assert.True(theory2.Equals(theory), "Chars didn't translate properly.");
     theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus.");
     theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     num = theory2.Replace('$', " ");
     Assert.True(num == 7, "Reported number of tilted slashes was wrong.");
     Assert.True(theory2.Equals(theory), "Chars didn't translate properly.");
     theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus.");
     theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     num = theory2.Replace("$", ' ');
     Assert.True(num == 7, "Reported number of tilted slashes was wrong.");
     Assert.True(theory2.Equals(theory), "Chars didn't translate properly.");
     theory = new StringTheory("Lorem_$_ipsum._$_Ve_$_misdebus._$_U_$_misdebus._$_I_$_misdebus.");
     theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     num = theory2.Replace("$", "_$_");
     Assert.True(theory2.Equals(theory), "(x)Chars didn't translate properly.");
 }
Ejemplo n.º 2
0
 public void testFormat()
 {
     StringTheory theory = new StringTheory("341111111111111");
     if (!theory.Equals("3411-111111-11111"))
     {
         theory.Format("####-######-#####");
     }
     Assert.True(theory.Equals("3411-111111-11111"), "AMEX Format didn't work:" + theory);
     StringTheory theory2 = new StringTheory("18003334456");
     if (!theory2.Equals("1-800-333-4456"))
     {
         theory2.Format("#-###-###-####");
     }
     Assert.True(theory2.Equals("1-800-333-4456"), "Phone Format didn't work:" + theory2);
     theory2.Renew("18003334456");
     theory2.Format("");
     Assert.True(theory2.Equals("18003334456"), "Format failed when given a blank Format. It *should* pass thru." + theory2);
 }
Ejemplo n.º 3
0
 public void testPush()
 {
     StringTheory theory = new StringTheory();
     Assert.True(theory.Push('m') == 1, "push is misreporting length!");
     Assert.True(theory.Push('a') == 2, "push is misreporting length!");
     Assert.True(theory.Push('r') == 3, "push is misreporting length!");
     Assert.True(theory.Push('e') == 4, "push is misreporting length!");
     Assert.True(theory.Push('s') == 5, "push is misreporting length!");
     Assert.True(theory.Equals("mares"), "PUSH results didn't match expectations: " + theory);
 }
Ejemplo n.º 4
0
 public void testUnshift()
 {
     StringTheory theory = new StringTheory();
     Assert.True(theory.Unshift('s') == 1, "Unshift is misreporting length!");
     Assert.True(theory.Unshift('e') == 2, "Unshift is misreporting length!");
     Assert.True(theory.Unshift('r') == 3, "Unshift is misreporting length!");
     Assert.True(theory.Unshift('a') == 4, "Unshift is misreporting length!");
     Assert.True(theory.Unshift('m') == 5, "Unshift is misreporting length!");
     Assert.True(theory.Equals("mares"), "UNSHIFT results didn't match expectations: [" + theory + "]");
 }
Ejemplo n.º 5
0
 public void testEquals()
 {
     string str = "bozo";
     string str2 = "foo";
     StringTheory theory = new StringTheory("bozo");
     StringTheory theory2 = new StringTheory("bozo");
     StringTheory theory3 = new StringTheory("boxzxo");
     Assert.True(theory.Equals(str) && !theory.Equals(str2), "Failed while comparing with a string.");
     Assert.True(theory.Equals(theory2) && !theory.Equals(theory3), "Failed while comparing with another ST.");
 }
Ejemplo n.º 6
0
 public void testTransWithACharacter()
 {
     StringTheory theory = new StringTheory("Lorem ipsum. Ve misdebus. U misdebus. I misdebus.");
     StringTheory theory2 = new StringTheory("Lorem$ipsum.$Ve$misdebus.$U$misdebus.$I$misdebus.");
     int num = theory2.Replace('$', ' ');
     Assert.True(num == 7, "Reported number of tilted slashes was wrong.");
     Assert.True(theory2.Equals(theory), "Chars didn't translate properly.");
 }
Ejemplo n.º 7
0
 public void testTiltForward()
 {
     StringTheory theory = new StringTheory(@"http:\\www.google.com\folder\subfolder\file.html");
     StringTheory theory2 = new StringTheory("http://www.google.com/folder/subfolder/file.html");
     Assert.True(theory.TiltForward() == 5, "Reported number of tilted slashes was wrong.");
     Assert.True(theory.Equals(theory2), "Slashes aren't all tilted properly.");
 }
Ejemplo n.º 8
0
 public void testStripTabs()
 {
     StringTheory theory = new StringTheory("\tHi!\tThere!");
     StringTheory theory2 = new StringTheory("Hi!There!");
     Assert.True(theory.StripTabs() == 2, "Reported number of tabs was wrong.");
     Assert.True(theory.Equals(theory2), "Test string doesn't match the reference.");
 }
Ejemplo n.º 9
0
 public void testScrub()
 {
     StringTheory theory = new StringTheory("%555-33-0000*");
     theory.Filter("-.$%*");
     Assert.True(theory.Equals("555330000"), "Scrub(1) failed: " + theory);
     theory.Renew("%555-33-0000*");
     theory.Filter("-");
     Assert.True(theory.Equals("%555330000*"), "Scrub(2) failed: " + theory);
 }
Ejemplo n.º 10
0
 public void testReplaceRx()
 {
     StringTheory theory = new StringTheory("aabfooaabfooabfoob");
     theory.Rx.Replace("a*b", "-");
     Assert.True(theory.Equals("-foo-foo-foo-"), "rx_replace() didn't emit the expected result.");
 }