當前位置: 首頁>>代碼示例>>Java>>正文


Java NorFlashSectorState類代碼示例

本文整理匯總了Java中com.sun.squawk.flash.NorFlashSectorState的典型用法代碼示例。如果您正苦於以下問題:Java NorFlashSectorState類的具體用法?Java NorFlashSectorState怎麽用?Java NorFlashSectorState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NorFlashSectorState類屬於com.sun.squawk.flash包,在下文中一共展示了NorFlashSectorState類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testErase

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void testErase() throws IOException, RecordStoreException {
    byte[] erasedMarker = NorFlashSectorState.ERASED_HEADER;
    final long sequence = 10;

    sector.incrementFreedBlockCount();
    sector.incrementAllocatedBlockCount();
    sector.erase(sequence);
    assertTrue(sector.hasErasedHeader());
    assertEquals(NorFlashSectorState.ERASED_HEADER_SIZE, sector.getWriteHeadPosition());
    assertEquals(0, sector.getFreedBlockCount());
    assertEquals(0, sector.getAllocatedBlockCount());
    byte[] bytes = new byte[testSize];
    sector.readBytes(0, bytes, 0, testSize);
    DataInputStream input = new DataInputStream(new ByteArrayInputStream(bytes));
    assertEquals(NorFlashMemoryHeap.ERASED_VALUE_XOR, input.readByte());
    assertEquals(NorFlashMemoryHeap.ERASED_VALUE_XOR, input.readByte());
    for (int i=0; i < erasedMarker.length; i++) {
        assertEquals(erasedMarker[i], input.readByte());
    }
    assertEquals(input.readLong(), sequence);
    assertEquals(NorFlashMemoryHeap.ERASED_VALUE_XOR, input.readByte());
    assertEquals(NorFlashMemoryHeap.ERASED_VALUE_XOR, input.readByte());
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:24,代碼來源:NorFlashSectorStateTest.java

示例2: testInitState4

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void testInitState4() throws IOException {
    final long sequence = 10;
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    DataOutputStream dataOut = new DataOutputStream(bytesOut);
    dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
    dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
    dataOut.write(NorFlashSectorState.ERASED_HEADER);
    dataOut.writeLong(sequence);
    dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
    dataOut.write(NorFlashMemoryHeap.ERASED_VALUE_XOR);
    castSector = new NorFlashSectorState(new SimulatedNorFlashSector(Address.zero(), bytesOut.toByteArray(), 0));
    sector = castSector;
    assertTrue(sector.hasErasedHeader());
    assertEquals(bytesOut.size(), sector.getWriteHeadPosition());
    assertEquals(sequence, castSector.sequence);
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:17,代碼來源:NorFlashSectorStateTest.java

示例3: setUp

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void setUp() throws Exception {
    this.testSize = 32;
    assertTrue((testSize / 2) > 0);
    startAddress = Address.zero();
    castSector = new NorFlashSectorState(new SimulatedNorFlashSector(startAddress, testSize, 0, false));
    sector = castSector;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:8,代碼來源:NorFlashSectorStateTest.java

示例4: testInitState2

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void testInitState2() {
    try {
        ;
        castSector = new NorFlashSectorState(new SimulatedNorFlashSector(Address.zero(), new byte[] {0}, 0));
        sector = castSector;
        fail();
    } catch (IllegalArgumentException e) {
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:10,代碼來源:NorFlashSectorStateTest.java

示例5: testInitState3

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void testInitState3() {
    final byte[] bytes = new byte[NorFlashSectorState.ERASED_HEADER_SIZE];
    castSector = new NorFlashSectorState(new SimulatedNorFlashSector(Address.zero(), bytes, 0));
    sector = castSector;
    assertFalse(sector.hasErasedHeader());
    assertSame(0, sector.getWriteHeadPosition());
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:8,代碼來源:NorFlashSectorStateTest.java

示例6: testResetHead

import com.sun.squawk.flash.NorFlashSectorState; //導入依賴的package包/類
public void testResetHead() {
    castSector.hasErasedHeader = false;
    sector.resetHead();
    assertSame(0, sector.getWriteHeadPosition());
    castSector.hasErasedHeader = true;
    sector.resetHead();
    assertEquals(NorFlashSectorState.ERASED_HEADER_SIZE, sector.getWriteHeadPosition());
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:9,代碼來源:NorFlashSectorStateTest.java


注:本文中的com.sun.squawk.flash.NorFlashSectorState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。