diff options
author | Nick Burch <nick@apache.org> | 2008-02-06 14:35:05 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2008-02-06 14:35:05 +0000 |
commit | 766dc98ce36338acc4ad9c21d931c0843994ee40 (patch) | |
tree | ebf5e63cf13fc77215009dd87be2e147ffab918e /src/testcases/org | |
parent | f37119acc5b2b3eee3288cc284cd8f3791152e11 (diff) | |
download | poi-766dc98ce36338acc4ad9c21d931c0843994ee40.tar.gz poi-766dc98ce36338acc4ad9c21d931c0843994ee40.zip |
Implement hashCode and equals for HSSFFont and HSSFCellStyle
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@619001 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index bdf5702c64..0daa80326e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -137,6 +137,35 @@ public class TestCellStyle assertEquals("FIRST ROW ", 0, s.getFirstRowNum()); } + + public void testHashEquals() { + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + HSSFCellStyle cs1 = wb.createCellStyle(); + HSSFCellStyle cs2 = wb.createCellStyle(); + HSSFRow row = s.createRow((short)0); + HSSFCell cell1 = row.createCell((short)1); + HSSFCell cell2 = row.createCell((short)2); + + cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy")); + cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); + + cell1.setCellStyle(cs1); + cell1.setCellValue(new Date()); + + cell2.setCellStyle(cs2); + cell2.setCellValue(new Date()); + + assertEquals(cs1.hashCode(), cs1.hashCode()); + assertEquals(cs2.hashCode(), cs2.hashCode()); + assertTrue(cs1.equals(cs1)); + assertTrue(cs2.equals(cs2)); + + // Change cs1, hash will alter + int hash1 = cs1.hashCode(); + cs1.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/dd/yy")); + assertFalse(hash1 == cs1.hashCode()); + } /** * TEST NAME: Test Write Sheet Style <P> |