|
@@ -10,35 +10,36 @@ import de.mcs.tools.sps.exceptions.SyntaxError;
|
|
|
|
|
|
class TestPORT {
|
|
|
|
|
|
+ private static final int BYTE_VALUE = 0x10;
|
|
|
private final String MNEMONIC = "PORT";
|
|
|
|
|
|
@Test
|
|
|
- void testNOP() throws SyntaxError {
|
|
|
- PORT port = new PORT(MNEMONIC + " 0x00");
|
|
|
- port.checkArgument();
|
|
|
- assertEquals(0x10, port.getByte());
|
|
|
+ void testMnemonic() throws SyntaxError {
|
|
|
+ PORT mno = new PORT(MNEMONIC + " 0x00");
|
|
|
+ mno.checkArgument();
|
|
|
+ assertEquals(BYTE_VALUE, mno.getByte());
|
|
|
|
|
|
- port = new PORT(MNEMONIC + " 0x01");
|
|
|
- port.checkArgument();
|
|
|
- assertEquals(0x11, port.getByte());
|
|
|
+ mno = new PORT(MNEMONIC + " 0x01");
|
|
|
+ mno.checkArgument();
|
|
|
+ assertEquals(BYTE_VALUE + 1, mno.getByte());
|
|
|
|
|
|
- port = new PORT(MNEMONIC + " 0x0f");
|
|
|
- port.checkArgument();
|
|
|
- assertEquals(0x1f, port.getByte());
|
|
|
+ mno = new PORT(MNEMONIC + " 0x0f");
|
|
|
+ mno.checkArgument();
|
|
|
+ assertEquals(BYTE_VALUE + 0x0f, mno.getByte());
|
|
|
|
|
|
Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
- PORT port1 = new PORT(MNEMONIC);
|
|
|
- port1.checkArgument();
|
|
|
+ PORT mno1 = new PORT(MNEMONIC);
|
|
|
+ mno1.checkArgument();
|
|
|
});
|
|
|
|
|
|
Assertions.assertThrows(IllegalArgument.class, () -> {
|
|
|
- PORT port1 = new PORT(MNEMONIC + " 0x10");
|
|
|
- port1.checkArgument();
|
|
|
+ PORT mno1 = new PORT(MNEMONIC + " 0x10");
|
|
|
+ mno1.checkArgument();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void testNOPFactory() throws SyntaxError {
|
|
|
+ void testMnemonicFactory() throws SyntaxError {
|
|
|
Mnemonic mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x00", 0);
|
|
|
assertEquals(PORT.class, mnemonic.getClass());
|
|
|
|
|
@@ -47,13 +48,13 @@ class TestPORT {
|
|
|
});
|
|
|
|
|
|
mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0x02", 0);
|
|
|
- assertEquals(0x12, mnemonic.getByte());
|
|
|
+ assertEquals(BYTE_VALUE + 0x02, mnemonic.getByte());
|
|
|
|
|
|
mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 12", 0);
|
|
|
- assertEquals(0x1C, mnemonic.getByte());
|
|
|
+ assertEquals(BYTE_VALUE + 12, mnemonic.getByte());
|
|
|
|
|
|
mnemonic = MnemonicFactory.getMnemonic(MNEMONIC + " 0b00001010", 0);
|
|
|
- assertEquals(0x1A, mnemonic.getByte());
|
|
|
+ assertEquals(BYTE_VALUE + 10, mnemonic.getByte());
|
|
|
|
|
|
}
|
|
|
}
|