/** * @tests java.text.DecimalFormatSymbols#clone() Test of method * java.text.DecimalFormatSymbols#clone(). Case 1: Compare of internal variables of cloned * objects. Case 2: Compare of clones. Case 3: Change the content of the clone. */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "clone", args = {}) public void test_clone() { try { // case 1: Compare of internal variables of cloned objects DecimalFormatSymbols fs = new DecimalFormatSymbols(Locale.US); DecimalFormatSymbols fsc = (DecimalFormatSymbols) fs.clone(); assertEquals(fs.getCurrency(), fsc.getCurrency()); // case 2: Compare of clones fs = new DecimalFormatSymbols(); DecimalFormatSymbols fsc2 = (DecimalFormatSymbols) (fs.clone()); // make sure the objects are equal assertTrue("Object's clone isn't equal!", fs.equals(fsc2)); // case 3: // change the content of the clone and make sure it's not equal // anymore // verifies that it's data is now distinct from the original fs.setNaN("not-a-number"); assertTrue("Object's changed clone should not be equal!", !fs.equals(fsc2)); } catch (Exception e) { fail("Unexpected exception " + e.toString()); } }
/** @tests java.text.DecimalFormatSymbols#equals(java.lang.Object) */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "equals", args = {java.lang.Object.class}) public void test_equalsLjava_lang_Object() { assertTrue("Equal objects returned false", dfs.equals(dfs.clone())); dfs.setDigit('B'); assertTrue("Un-Equal objects returned true", !dfs.equals(new DecimalFormatSymbols())); }