@Test public void write() { int memorySize = ConfigHelper.getConfig().getInt("memory_size"); Memory memory = new Memory(memorySize); assertTrue(memory.write(0, new char[memorySize], 0, memorySize)); assertFalse(memory.write(0, new char[memorySize], 0, memorySize + 1)); assertFalse(memory.write(0, new char[memorySize], 0, -1)); assertFalse(memory.write(-1, new char[memorySize], 0, 10)); assertFalse(memory.write(memorySize, new char[15], 0, 1)); assertFalse(memory.write((memorySize) - 5, new char[11], 0, 6)); assertTrue(memory.write((memorySize) - 5, new char[11], 0, 5)); }
public boolean write(int offset, char[] src, int srcOffset, int count) { if (offset + count > this.words.length || srcOffset >= src.length || count < 0 || offset < 0) { return false; } System.arraycopy(src, srcOffset, this.words, offset, count); return true; }
Memory implements Target, MongoSerializable { public boolean write(int offset, char[] src, int srcOffset, int count) { if (offset + count > this.words.length || srcOffset >= src.length || count < 0 || offset < 0) { return false; } System.arraycopy(src, srcOffset, this.words, offset, count); return true; } }
Memory implements Target, MongoSerializable { public boolean write(int offset, char[] src, int srcOffset, int count) { if (offset + count > this.words.length || srcOffset >= src.length || count < 0 || offset < 0) { return false; } System.arraycopy(src, srcOffset, this.words, offset, count); return true; } Memory(int size);  Memory(Document document); }
Memory implements Target, MongoSerializable { public boolean write(int offset, char[] src, int srcOffset, int count) { if (offset + count > this.words.length || srcOffset >= src.length || count < 0 || offset < 0) { return false; } System.arraycopy(src, srcOffset, this.words, offset, count); return true; } Memory(int size);  Memory(Document document); @Override int get(int address); boolean write(int offset, char[] src, int srcOffset, int count); @Override void set(int address, int value); void corrupt(int blockSize); void clear(); byte[] getBytes(); @Override Document mongoSerialise(); void setBytes(byte[] bytes); char[] getWords(); }
Memory implements Target, MongoSerializable { public boolean write(int offset, char[] src, int srcOffset, int count) { if (offset + count > this.words.length || srcOffset >= src.length || count < 0 || offset < 0) { return false; } System.arraycopy(src, srcOffset, this.words, offset, count); return true; } Memory(int size);  Memory(Document document); @Override int get(int address); boolean write(int offset, char[] src, int srcOffset, int count); @Override void set(int address, int value); void corrupt(int blockSize); void clear(); byte[] getBytes(); @Override Document mongoSerialise(); void setBytes(byte[] bytes); char[] getWords();  }