From 766dc98ce36338acc4ad9c21d931c0843994ee40 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 6 Feb 2008 14:35:05 +0000 Subject: 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 --- .../apache/poi/hssf/usermodel/TestCellStyle.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/testcases/org') 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

-- cgit v1.2.3