FileDocCategorySizeDatePackage
TestTextCharsAtom.javaAPI DocApache Poi 3.0.13275Mon Jan 01 18:56:12 GMT 2007org.apache.poi.hslf.record

TestTextCharsAtom

public class TestTextCharsAtom extends TestCase
Tests that TextCharsAtom works properly
author
Nick Burch (nick at torchbox dot com)

Fields Summary
private byte[]
data
private String
data_text
private byte[]
alt_data
private String
alt_text
Constructors Summary
Methods Summary
public voidtestChangeText()

		TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
		tca.setText(alt_text);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		tca.writeOut(baos);
		byte[] b = baos.toByteArray();

		// Compare the header and the text
		assertEquals(alt_data.length, b.length);
		for(int i=0; i<alt_data.length; i++) {
			assertEquals(alt_data[i],b[i]);
		}
	
public voidtestCreateNew()

		TextCharsAtom tca = new TextCharsAtom();
		assertEquals(0, tca.getText().length());
		
		tca.setText(data_text);
		assertEquals(data_text, tca.getText());
		
		// Check it's now like data
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		tca.writeOut(baos);
		byte[] b = baos.toByteArray();

		assertEquals(data.length, b.length);
		for(int i=0; i<data.length; i++) {
			assertEquals(data[i],b[i]);
		}
	
public voidtestRecordType()


         
		TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
		assertEquals(4000l, tca.getRecordType());
	
public voidtestTextA()

		TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
		assertEquals(data_text, tca.getText());
	
public voidtestTextB()

		TextCharsAtom tca = new TextCharsAtom(alt_data,0,alt_data.length);
		assertEquals(alt_text, tca.getText());
	
public voidtestWrite()

		TextCharsAtom tca = new TextCharsAtom(data,0,data.length);
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		tca.writeOut(baos);
		byte[] b = baos.toByteArray();

		assertEquals(data.length, b.length);
		for(int i=0; i<data.length; i++) {
			assertEquals(data[i],b[i]);
		}