1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestAxisOptionsRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01, 38 (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x00, 39 (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, 40 (byte)0x00,(byte)0xEF,(byte)0x00 41 }; 42 43 public TestAxisOptionsRecord(String name) 44 { 45 super(name); 46 } 47 48 public void testLoad() 49 throws Exception 50 { 51 AxisOptionsRecord record = new AxisOptionsRecord((short)0x1062, (short)data.length, data); 52 assertEquals( 0, record.getMinimumCategory()); 53 assertEquals( 0, record.getMaximumCategory()); 54 assertEquals( 1, record.getMajorUnitValue()); 55 assertEquals( 0, record.getMajorUnit()); 56 assertEquals( 1, record.getMinorUnitValue()); 57 assertEquals( 0, record.getMinorUnit()); 58 assertEquals( 0, record.getBaseUnit()); 59 assertEquals( 0, record.getCrossingPoint()); 60 assertEquals( 239, record.getOptions()); 61 assertEquals( true, record.isDefaultMinimum() ); 62 assertEquals( true, record.isDefaultMaximum() ); 63 assertEquals( true, record.isDefaultMajor() ); 64 assertEquals( true, record.isDefaultMinorUnit() ); 65 assertEquals( false, record.isIsDate() ); 66 assertEquals( true, record.isDefaultBase() ); 67 assertEquals( true, record.isDefaultCross() ); 68 assertEquals( true, record.isDefaultDateSettings() ); 69 70 71 assertEquals( 22, record.getRecordSize() ); 72 73 record.validateSid((short)0x1062); 74 } 75 76 public void testStore() 77 { 78 AxisOptionsRecord record = new AxisOptionsRecord(); 79 record.setMinimumCategory( (short)0 ); 80 record.setMaximumCategory( (short)0 ); 81 record.setMajorUnitValue( (short)1 ); 82 record.setMajorUnit( (short)0 ); 83 record.setMinorUnitValue( (short)1 ); 84 record.setMinorUnit( (short)0 ); 85 record.setBaseUnit( (short)0 ); 86 record.setCrossingPoint( (short)0 ); 87 record.setOptions( (short)239 ); 88 record.setDefaultMinimum( true ); 89 record.setDefaultMaximum( true ); 90 record.setDefaultMajor( true ); 91 record.setDefaultMinorUnit( true ); 92 record.setIsDate( false ); 93 record.setDefaultBase( true ); 94 record.setDefaultCross( true ); 95 record.setDefaultDateSettings( true ); 96 97 98 byte [] recordBytes = record.serialize(); 99 assertEquals(recordBytes.length - 4, data.length); 100 for (int i = 0; i < data.length; i++) 101 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 102 } 103 104 109 public static void main(String [] args) { 110 System.out.println("Testing org.apache.poi.hssf.record.AxisOptionsRecord"); 111 junit.textui.TestRunner.run(TestAxisOptionsRecord.class); 112 } 113 } 114 | Popular Tags |