use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.
the class Mos6502CompilerTest method testIndirectYInstructions.
@Property
public void testIndirectYInstructions(@InRange(min = "0", max = "255") int byteValue) {
final String hexByte = Integer.toHexString(byteValue);
OpCode.streamOf(AddressingMode.INDIRECT_Y).forEach((opcode) -> {
final Mos6502Compiler compiler = new Mos6502Compiler(opcode.getOpCodeName() + " (" + VALUE_PREFIX + hexByte + "),Y");
Program program = compiler.compileProgram();
int[] bytes = program.getProgramAsByteArray();
assertArrayEquals(new int[] { opcode.getByteValue(), byteValue }, bytes);
});
}
use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.
the class Mos6502Properties method testValidStartup.
@Property(trials = 100)
public void testValidStartup(@InRange(min = "0", max = "255") int memHi, @InRange(min = "0", max = "255") int memLo) {
memory = new SimpleMemory();
memory.setByteAt(0xFFFC, memHi);
memory.setByteAt(0xFFFD, memLo);
processor = new Mos6502(memory);
processor.reset();
Registers registers = processor.getRegisters();
// PC Set to location pointed to by mem[FFFC:FFFD]
assertEquals(memHi, registers.getRegister(Registers.Register.PROGRAM_COUNTER_HI));
// ...
assertEquals(memLo, registers.getRegister(Registers.Register.PROGRAM_COUNTER_LOW));
// Status flags reset
assertEquals(0x34, registers.getRegister(Registers.Register.STATUS_FLAGS));
// Stack Pointer at top of stack
assertEquals(0xFF, registers.getRegister(Registers.Register.STACK_POINTER_HI));
// All cleared
assertEquals(0, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0, registers.getRegister(Registers.Register.Y_INDEX));
}
use of com.pholser.junit.quickcheck.Property in project emuRox by rossdrew.
the class Mos6502Properties method testValidImmediateADC.
@Property(trials = 100)
public void testValidImmediateADC(@InRange(min = "0", max = "255") int value) {
Program program = new Program().with(LDA_I, value);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step();
Registers registers = processor.getRegisters();
assertEquals(value, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(program.getLength(), registers.getPC());
}
use of com.pholser.junit.quickcheck.Property in project beam by apache.
the class AvroUtilsTest method avroToBeamRoundTrip.
@Property(trials = 1000)
@SuppressWarnings("unchecked")
public void avroToBeamRoundTrip(@From(RecordSchemaGenerator.class) org.apache.avro.Schema avroSchema) {
Schema schema = AvroUtils.toBeamSchema(avroSchema);
Iterable iterable = new RandomData(avroSchema, 10);
List<GenericRecord> records = Lists.newArrayList((Iterable<GenericRecord>) iterable);
for (GenericRecord record : records) {
Row row = AvroUtils.toBeamRowStrict(record, schema);
GenericRecord out = AvroUtils.toGenericRecord(row, avroSchema);
assertEquals(record, out);
}
}
use of com.pholser.junit.quickcheck.Property in project beam by apache.
the class AvroUtilsTest method supportsAnyAvroSchema.
@Property(trials = 1000)
@SuppressWarnings("unchecked")
public void supportsAnyAvroSchema(@From(RecordSchemaGenerator.class) org.apache.avro.Schema avroSchema) {
Schema schema = AvroUtils.toBeamSchema(avroSchema);
Iterable iterable = new RandomData(avroSchema, 10);
List<GenericRecord> records = Lists.newArrayList((Iterable<GenericRecord>) iterable);
for (GenericRecord record : records) {
AvroUtils.toBeamRowStrict(record, schema);
}
}
Aggregations