|
@@ -0,0 +1,158 @@
|
|
|
+package de.mcs.tools.sps.mnemonic;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+
|
|
|
+import org.junit.jupiter.api.Assertions;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+
|
|
|
+import de.mcs.tools.sps.exceptions.SyntaxError;
|
|
|
+
|
|
|
+class TestSingleMnemonics {
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testSWAP() throws SyntaxError {
|
|
|
+ SWAP mno = new SWAP("SWAP");
|
|
|
+ assertEquals(0x50, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ SWAP mno1 = new SWAP("SWAP akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ SWAP mno1 = new SWAP("SWAP 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ SWAP mno1 = new SWAP("SWAP :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testBSET() throws SyntaxError {
|
|
|
+ BSET mno = new BSET("BSET");
|
|
|
+ assertEquals(0x51, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ BSET mno1 = new BSET("BSET akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ BSET mno1 = new BSET("BSET 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ BSET mno1 = new BSET("BSET :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testCSET() throws SyntaxError {
|
|
|
+ CSET mno = new CSET("CSET");
|
|
|
+ assertEquals(0x52, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ CSET mno1 = new CSET("CSET akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ CSET mno1 = new CSET("CSET 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ CSET mno1 = new CSET("CSET :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testDSET() throws SyntaxError {
|
|
|
+ DSET mno = new DSET("DSET");
|
|
|
+ assertEquals(0x53, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ DSET mno1 = new DSET("DSET akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ DSET mno1 = new DSET("DSET 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ DSET mno1 = new DSET("DSET :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testESET() throws SyntaxError {
|
|
|
+ ESET mno = new ESET("ESET");
|
|
|
+ assertEquals(0x5d, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ ESET mno1 = new ESET("ESET akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ ESET mno1 = new ESET("ESET 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ ESET mno1 = new ESET("ESET :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testFSET() throws SyntaxError {
|
|
|
+ FSET mno = new FSET("FSET");
|
|
|
+ assertEquals(0x5e, mno.getByte());
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ FSET mno1 = new FSET("FSET akfhaskh");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ FSET mno1 = new FSET("FSET 12");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+
|
|
|
+ Assertions.assertThrows(SyntaxError.class, () -> {
|
|
|
+ FSET mno1 = new FSET("FSET :label");
|
|
|
+ mno1.checkArgument();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testMnemonicFactory() throws SyntaxError {
|
|
|
+ Mnemonic mnemonic = MnemonicFactory.getMnemonic("SWAP", 0);
|
|
|
+ assertEquals(SWAP.class, mnemonic.getClass());
|
|
|
+
|
|
|
+ mnemonic = MnemonicFactory.getMnemonic("BSET", 0);
|
|
|
+ assertEquals(BSET.class, mnemonic.getClass());
|
|
|
+
|
|
|
+ mnemonic = MnemonicFactory.getMnemonic("CSET", 0);
|
|
|
+ assertEquals(CSET.class, mnemonic.getClass());
|
|
|
+
|
|
|
+ mnemonic = MnemonicFactory.getMnemonic("DSET", 0);
|
|
|
+ assertEquals(DSET.class, mnemonic.getClass());
|
|
|
+
|
|
|
+ mnemonic = MnemonicFactory.getMnemonic("ESET", 0);
|
|
|
+ assertEquals(ESET.class, mnemonic.getClass());
|
|
|
+
|
|
|
+ mnemonic = MnemonicFactory.getMnemonic("FSET", 0);
|
|
|
+ assertEquals(FSET.class, mnemonic.getClass());
|
|
|
+ }
|
|
|
+}
|