@Test public void readCharUTF8ReadsAllSingleCodeUnitCharsCorrectly() { byte[] bytes = new byte[0b0111_1111]; for (int i = 0; i < bytes.length; i++) { bytes[i] = (byte) i; } rawReader = (process, offset, bytesToRead) -> toBuffer(Arrays.copyOfRange(bytes, offset, offset + bytesToRead)); for (int i = 0; i < bytes.length; i++) { char expected = new String(bytes, i, 1, StandardCharsets.UTF_8).charAt(0); char result = reader.readCharUTF8(process, i); assertEquals(expected, result); } }
@Override public char readCharUTF8(NativeProcess process, int offset) { return (char) rawMemoryReader.read(process, offset, TypeSize.CHAR_UTF8.getSize()).get(); }
MemoryReaderImpl implements MemoryReader { @Override public char readCharUTF8(NativeProcess process, int offset) { return (char) rawMemoryReader.read(process, offset, TypeSize.CHAR_UTF8.getSize()).get(); } }
MemoryReaderImpl implements MemoryReader { @Override public char readCharUTF8(NativeProcess process, int offset) { return (char) rawMemoryReader.read(process, offset, TypeSize.CHAR_UTF8.getSize()).get(); } MemoryReaderImpl(RawMemoryReader rawMemoryReader); }
MemoryReaderImpl implements MemoryReader { @Override public char readCharUTF8(NativeProcess process, int offset) { return (char) rawMemoryReader.read(process, offset, TypeSize.CHAR_UTF8.getSize()).get(); } MemoryReaderImpl(RawMemoryReader rawMemoryReader); @Override boolean readBoolean(NativeProcess process, int offset); @Override byte readByte(NativeProcess process, int offset); @Override char readCharUTF8(NativeProcess process, int offset); @Override char readCharUTF16LE(NativeProcess process, int offset); @Override short readShort(NativeProcess process, int offset); @Override int readInt(NativeProcess process, int offset); @Override float readFloat(NativeProcess process, int offset); @Override long readLong(NativeProcess process, int offset); @Override double readDouble(NativeProcess process, int offset); @Override String readStringUTF8(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override String readStringUTF16LE(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override byte[] read(NativeProcess process, int offset, int bytesToRead); }
MemoryReaderImpl implements MemoryReader { @Override public char readCharUTF8(NativeProcess process, int offset) { return (char) rawMemoryReader.read(process, offset, TypeSize.CHAR_UTF8.getSize()).get(); } MemoryReaderImpl(RawMemoryReader rawMemoryReader); @Override boolean readBoolean(NativeProcess process, int offset); @Override byte readByte(NativeProcess process, int offset); @Override char readCharUTF8(NativeProcess process, int offset); @Override char readCharUTF16LE(NativeProcess process, int offset); @Override short readShort(NativeProcess process, int offset); @Override int readInt(NativeProcess process, int offset); @Override float readFloat(NativeProcess process, int offset); @Override long readLong(NativeProcess process, int offset); @Override double readDouble(NativeProcess process, int offset); @Override String readStringUTF8(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override String readStringUTF16LE(NativeProcess process, int offset, int maxCodeUnitsToRead); @Override byte[] read(NativeProcess process, int offset, int bytesToRead);  }