public void TestCloneEquals() { RuleBasedBreakIterator bi1 = (RuleBasedBreakIterator)BreakIterator.GetCharacterInstance(CultureInfo.CurrentCulture); RuleBasedBreakIterator biequal = (RuleBasedBreakIterator)BreakIterator.GetCharacterInstance(CultureInfo.CurrentCulture); RuleBasedBreakIterator bi3 = (RuleBasedBreakIterator)BreakIterator.GetCharacterInstance(CultureInfo.CurrentCulture); RuleBasedBreakIterator bi2 = (RuleBasedBreakIterator)BreakIterator.GetWordInstance(CultureInfo.CurrentCulture); string testString = "Testing word break iterators's clone() and equals()"; bi1.SetText(testString); bi2.SetText(testString); biequal.SetText(testString); bi3.SetText("hello"); Logln("Testing equals()"); Logln("Testing == and !="); if (!bi1.Equals(biequal) || bi1.Equals(bi2) || bi1.Equals(bi3)) { Errln("ERROR:1 RBBI's == and !- operator failed."); } if (bi2.Equals(biequal) || bi2.Equals(bi1) || biequal.Equals(bi3)) { Errln("ERROR:2 RBBI's == and != operator failed."); } Logln("Testing clone()"); RuleBasedBreakIterator bi1clone = (RuleBasedBreakIterator)bi1.Clone(); RuleBasedBreakIterator bi2clone = (RuleBasedBreakIterator)bi2.Clone(); if (!bi1clone.Equals(bi1) || !bi1clone.Equals(biequal) || bi1clone.Equals(bi3) || bi1clone.Equals(bi2)) { Errln("ERROR:1 RBBI's clone() method failed"); } if (bi2clone.Equals(bi1) || bi2clone.Equals(biequal) || bi2clone.Equals(bi3) || !bi2clone.Equals(bi2)) { Errln("ERROR:2 RBBI's clone() method failed"); } if (!bi1.Text.Equals(bi1clone.Text) || !bi2clone.Text.Equals(bi2.Text) || bi2clone.Equals(bi1clone)) { Errln("ERROR: RBBI's clone() method failed"); } }
public void TestEquals() { RuleBasedBreakIterator rbbi = new RuleBasedBreakIterator(".;"); RuleBasedBreakIterator rbbi1 = new RuleBasedBreakIterator(".;"); // TODO: Tests when "if (fRData != other.fRData && (fRData == null || other.fRData == null))" is true // Tests when "if (fText == null || other.fText == null)" is true rbbi.SetText((CharacterIterator)null); if (rbbi.Equals(rbbi1)) { Errln("RuleBasedBreakIterator.equals(Object) was not suppose to return " + "true when the other object has a null fText."); } // Tests when "if (fText == null && other.fText == null)" is true rbbi1.SetText((CharacterIterator)null); if (!rbbi.Equals(rbbi1)) { Errln("RuleBasedBreakIterator.equals(Object) was not suppose to return " + "false when both objects has a null fText."); } // Tests when an exception occurs if (rbbi.Equals(0)) { Errln("RuleBasedBreakIterator.equals(Object) was suppose to return " + "false when comparing to integer 0."); } if (rbbi.Equals(0.0)) { Errln("RuleBasedBreakIterator.equals(Object) was suppose to return " + "false when comparing to float 0.0."); } if (rbbi.Equals("0")) { Errln("RuleBasedBreakIterator.equals(Object) was suppose to return " + "false when comparing to string '0'."); } }