From 3b783835df054c13da2ff88fc436d5d4c38a8cd2 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 12 Mar 2006 19:19:18 +0000 Subject: [PATCH] Tests for creating a new Comment2000 record git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@385356 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hslf/record/TestComment2000.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java index 37726af7e0..2c582104ca 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestComment2000.java @@ -126,23 +126,35 @@ public class TestComment2000 extends TestCase { public void testChange() throws Exception { Comment2000 ca = new Comment2000(data_a, 0, data_a.length); Comment2000 cb = new Comment2000(data_b, 0, data_b.length); + Comment2000 cn = new Comment2000(); ca.setAuthor("Hogwarts"); ca.setAuthorInitials("H"); ca.setText("Comments are fun things to add in, aren't they?"); + cn.setAuthor("Hogwarts"); + cn.setAuthorInitials("H"); + cn.setText("Comments are fun things to add in, aren't they?"); // Change the Comment2000Atom Comment2000Atom c2a = ca.getComment2000Atom(); + Comment2000Atom c2n = cn.getComment2000Atom(); c2a.setNumber(1); c2a.setXOffset(0x0a); c2a.setYOffset(0x0a); + c2n.setNumber(1); + c2n.setXOffset(0x0a); + c2n.setYOffset(0x0a); Date new_date = sdf.parse("2006-01-24 22:25:03.725"); c2a.setDate(new_date); + c2n.setDate(new_date); // Check now the same assertEquals(ca.getText(), cb.getText()); + assertEquals(cn.getText(), cb.getText()); assertEquals(ca.getAuthor(), cb.getAuthor()); + assertEquals(cn.getAuthor(), cb.getAuthor()); assertEquals(ca.getAuthorInitials(), cb.getAuthorInitials()); + assertEquals(cn.getAuthorInitials(), cb.getAuthorInitials()); // Check bytes weren't the same try { @@ -155,14 +167,21 @@ public class TestComment2000 extends TestCase { } // Check bytes are now the same - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ca.writeOut(baos); - byte[] b = baos.toByteArray(); + ByteArrayOutputStream baosa = new ByteArrayOutputStream(); + ByteArrayOutputStream baosn = new ByteArrayOutputStream(); + ca.writeOut(baosa); + cn.writeOut(baosn); + byte[] ba = baosa.toByteArray(); + byte[] bn = baosn.toByteArray(); // Should now be the same - assertEquals(data_b.length, b.length); + assertEquals(data_b.length, ba.length); + for(int i=0; i