mardi 1 mars 2016

Java: Reference to sub array of bytes

Unit Tests: Setup a byte array with poison barriers. If in the frame of the test any boarder is touched, the unit test shall fail, such as in the following fragment:

byte[]    memory = new byte[Size + 2];

/* Poison barriers. Failure in case of touch! */
memory[0]      = 0x5A; 
memory[Size-1] = 0xA5; 

...
    array = sub-array of memory[] from '1 to Size-2'
    test functions on array
...
/* Check if boarders have been touched. */
hwut_verify(memory[0]      == 0x5A);
hwut_verify(memory[Size-1] == 0xA5);

How could I get the sub-array that is actually located inside the original byte array?

Aucun commentaire:

Enregistrer un commentaire