1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestValueRangeRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x1F,(byte)0x01 }; 44 45 public TestValueRangeRecord(String name) 46 { 47 super(name); 48 } 49 50 public void testLoad() 51 throws Exception 52 { 53 54 ValueRangeRecord record = new ValueRangeRecord((short)0x101f, (short)data.length, data); 55 assertEquals( 0.0, record.getMinimumAxisValue(), 0.001); 56 assertEquals( 0.0, record.getMaximumAxisValue(), 0.001); 57 assertEquals( 0.0, record.getMajorIncrement(), 0.001); 58 assertEquals( 0.0, record.getMinorIncrement(), 0.001); 59 assertEquals( 0.0, record.getCategoryAxisCross(), 0.001); 60 assertEquals( 0x011f, record.getOptions()); 61 assertEquals( true, record.isAutomaticMinimum() ); 62 assertEquals( true, record.isAutomaticMaximum() ); 63 assertEquals( true, record.isAutomaticMajor() ); 64 assertEquals( true, record.isAutomaticMinor() ); 65 assertEquals( true, record.isAutomaticCategoryCrossing() ); 66 assertEquals( false, record.isLogarithmicScale() ); 67 assertEquals( false, record.isValuesInReverse() ); 68 assertEquals( false, record.isCrossCategoryAxisAtMaximum() ); 69 assertEquals( true, record.isReserved() ); 70 71 assertEquals( 42+4, record.getRecordSize() ); 72 73 record.validateSid((short)0x101f); 74 } 75 76 public void testStore() 77 { 78 ValueRangeRecord record = new ValueRangeRecord(); 79 record.setMinimumAxisValue( 0 ); 80 record.setMaximumAxisValue( 0 ); 81 record.setMajorIncrement( 0 ); 82 record.setMinorIncrement( 0 ); 83 record.setCategoryAxisCross( 0 ); 84 record.setAutomaticMinimum( true ); 85 record.setAutomaticMaximum( true ); 86 record.setAutomaticMajor( true ); 87 record.setAutomaticMinor( true ); 88 record.setAutomaticCategoryCrossing( true ); 89 record.setLogarithmicScale( false ); 90 record.setValuesInReverse( false ); 91 record.setCrossCategoryAxisAtMaximum( false ); 92 record.setReserved( true ); 93 94 byte [] recordBytes = record.serialize(); 95 assertEquals(recordBytes.length - 4, data.length); 96 for (int i = 0; i < data.length; i++) 97 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 98 } 99 } 100 | Popular Tags |