summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile17
-rw-r--r--test/test-determine_slotting.c170
2 files changed, 187 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..ebd4364
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,17 @@
+CC=gcc
+MYCFLAGS=-O3 -mcpu=ev67 -pipe
+WARN=-Wunused -Wextra -Wall -std=gnu99 -pedantic
+INC=-I ../include/
+MYLDFLAGS=-Wl,-z,now $(LDFLAGS)
+
+OBJS=test-determine_slotting.o
+
+all: $(DEPS) $(OBJS)
+
+clean:
+ /bin/rm -f cleanbench sysinfo.c $(OBJS)
+
+remake: clean all
+
+%: %.c
+ $(CC) $(MYCFLAGS) $(WARN) $<
diff --git a/test/test-determine_slotting.c b/test/test-determine_slotting.c
new file mode 100644
index 0000000..e54a4bf
--- /dev/null
+++ b/test/test-determine_slotting.c
@@ -0,0 +1,170 @@
+#include "../src/determine_slotting.c"
+
+#include <stdio.h>
+
+#define EXPAND(__octaword) \
+ __octaword.instr[3].slot, \
+ __octaword.instr[2].slot, \
+ __octaword.instr[1].slot, \
+ __octaword.instr[0].slot
+
+#define PRINT_DEBUG(__rule, __start, __end, __check) printf("%s: %c%c%c%c -> %c%c%c%c (%c%c%c%c)\n", __rule, __start, __end, __check)
+
+#define RULE(__octaword, _3, _2, _1, _0) \
+ __octaword.instr[3].slot = _3; \
+ __octaword.instr[2].slot = _2; \
+ __octaword.instr[1].slot = _1; \
+ __octaword.instr[0].slot = _0
+
+#define DEFINE(__start3, __start2, __start1, __start0, __end3, __end2, __end1, __end0, __rule) \
+ { \
+ .start.instr[3].slot = SLOT_##__start3, \
+ .start.instr[2].slot = SLOT_##__start2, \
+ .start.instr[1].slot = SLOT_##__start1, \
+ .start.instr[0].slot = SLOT_##__start0, \
+ .end.instr[3].slot = SLOT_##__end3, \
+ .end.instr[2].slot = SLOT_##__end2, \
+ .end.instr[1].slot = SLOT_##__end1, \
+ .end.instr[0].slot = SLOT_##__end0, \
+ .rule = __rule \
+ }
+
+struct {
+ struct octaword_t start;
+ struct octaword_t end;
+ const char rule[8];
+} test[] = {
+ DEFINE(U, U, U, U, U, U, U, U, "1A "),
+
+ DEFINE(L, L, L, L, L, L, L, L, "1B "),
+
+ DEFINE(E, U, U, U, L, U, U, U, "2A "),
+ DEFINE(U, E, U, U, U, L, U, U, "2A "),
+ DEFINE(U, U, E, U, U, U, L, U, "2A "),
+ DEFINE(U, U, U, E, U, U, U, L, "2A "),
+ DEFINE(L, U, U, U, L, U, U, U, "2A "),
+ DEFINE(U, L, U, U, U, L, U, U, "2A "),
+ DEFINE(U, U, L, U, U, U, L, U, "2A "),
+ DEFINE(U, U, U, L, U, U, U, L, "2A "),
+
+ DEFINE(E, L, L, L, U, L, L, L, "2B "),
+ DEFINE(L, E, L, L, L, U, L, L, "2B "),
+ DEFINE(L, L, E, L, L, L, U, L, "2B "),
+ DEFINE(L, L, L, E, L, L, L, U, "2B "),
+ DEFINE(U, L, L, L, U, L, L, L, "2B "),
+ DEFINE(L, U, L, L, L, U, L, L, "2B "),
+ DEFINE(L, L, U, L, L, L, U, L, "2B "),
+ DEFINE(L, L, L, U, L, L, L, U, "2B "),
+
+ DEFINE(U, U, E, E, U, U, L, L, "3A "),
+ DEFINE(U, U, E, L, U, U, L, L, "3A "),
+ DEFINE(U, U, L, E, U, U, L, L, "3A "),
+ DEFINE(U, E, U, E, U, L, U, L, "3A "),
+ DEFINE(U, E, U, L, U, L, U, L, "3A "),
+ DEFINE(U, L, U, E, U, L, U, L, "3A "),
+ DEFINE(U, E, E, U, U, L, L, U, "3A "),
+ DEFINE(U, E, L, U, U, L, L, U, "3A "),
+ DEFINE(U, L, E, U, U, L, L, U, "3A "),
+ DEFINE(E, U, U, E, L, U, U, L, "3A "),
+ DEFINE(E, U, U, L, L, U, U, L, "3A "),
+ DEFINE(L, U, U, E, L, U, U, L, "3A "),
+ DEFINE(E, U, E, U, L, U, L, U, "3A "),
+ DEFINE(L, U, E, U, L, U, L, U, "3A "),
+ DEFINE(E, U, L, U, L, U, L, U, "3A "),
+ DEFINE(E, E, U, U, L, L, U, U, "3A "),
+ DEFINE(E, L, U, U, L, L, U, U, "3A "),
+ DEFINE(L, E, U, U, L, L, U, U, "3A "),
+
+ DEFINE(L, L, E, E, L, L, U, U, "3B "),
+ DEFINE(L, L, E, U, L, L, U, U, "3B "),
+ DEFINE(L, L, U, E, L, L, U, U, "3B "),
+ DEFINE(L, E, L, E, L, U, L, U, "3B "),
+ DEFINE(L, U, L, E, L, U, L, U, "3B "),
+ DEFINE(L, E, L, U, L, U, L, U, "3B "),
+ DEFINE(L, E, E, L, L, U, U, L, "3B "),
+ DEFINE(L, U, E, L, L, U, U, L, "3B "),
+ DEFINE(L, E, U, L, L, U, U, L, "3B "),
+ DEFINE(E, L, L, E, U, L, L, U, "3B "),
+ DEFINE(E, L, L, U, U, L, L, U, "3B "),
+ DEFINE(U, L, L, E, U, L, L, U, "3B "),
+ DEFINE(E, L, E, L, U, L, U, L, "3B "),
+ DEFINE(E, L, U, L, U, L, U, L, "3B "),
+ DEFINE(U, L, E, L, U, L, U, L, "3B "),
+ DEFINE(E, E, L, L, U, U, L, L, "3B "),
+ DEFINE(E, U, L, L, U, U, L, L, "3B "),
+ DEFINE(U, E, L, L, U, U, L, L, "3B "),
+
+ DEFINE(U, U, L, L, U, U, L, L, "3AB "),
+ DEFINE(U, L, U, L, U, L, U, L, "3AB "),
+ DEFINE(U, L, L, U, U, L, L, U, "3AB "),
+ DEFINE(L, U, U, L, L, U, U, L, "3AB "),
+ DEFINE(L, U, L, U, L, U, L, U, "3AB "),
+ DEFINE(L, L, U, U, L, L, U, U, "3AB "),
+
+ DEFINE(E, L, E, U, U, L, L, U, "4AB "),
+ DEFINE(E, L, U, E, U, L, U, L, "4AB "),
+ DEFINE(E, U, E, L, L, U, U, L, "4AB "),
+ DEFINE(E, U, L, E, L, U, L, U, "4AB "),
+ DEFINE(U, E, E, L, U, L, U, L, "4AB "),
+ DEFINE(U, E, L, E, U, L, L, U, "4AB "),
+ DEFINE(L, E, E, U, L, U, L, U, "4AB "),
+ DEFINE(L, E, U, E, L, U, U, L, "4AB "),
+
+ DEFINE(E, U, E, E, L, U, L, U, "4AD "),
+ DEFINE(U, E, E, E, U, L, U, L, "4AD "),
+ DEFINE(E, L, E, E, U, L, U, L, "4BD "),
+ DEFINE(L, E, E, E, L, U, L, U, "4BD "),
+
+ DEFINE(L, U, E, E, L, U, L, U, "4ABD"),
+ DEFINE(U, L, E, E, U, L, U, L, "4ABD"),
+
+ DEFINE(E, E, E, U, U, L, L, U, "4CA "),
+ DEFINE(E, E, U, E, U, L, U, L, "4CA "),
+
+ DEFINE(E, E, L, E, U, L, L, U, "4CB "),
+ DEFINE(E, E, E, L, U, L, U, L, "4CB "),
+
+ DEFINE(E, E, U, L, U, L, U, L, "4CAB"),
+ DEFINE(E, E, L, U, U, L, L, U, "4CAB"),
+
+ DEFINE(E, E, E, E, U, L, U, L, "4CD "),
+};
+
+int main() {
+ struct octaword_t check;
+
+ const char * fail = "FAILURE, -> ";
+ const char * succ = " ";
+ const char * which;
+
+ int i;
+ for (i = 0; i < sizeof(test) / sizeof(test[0]); i++) {
+ check = determine_slotting(test[i].start);
+ if ((test[i].end.instr[3].slot != check.instr[3].slot)
+ || (test[i].end.instr[2].slot != check.instr[2].slot)
+ || (test[i].end.instr[1].slot != check.instr[1].slot)
+ || (test[i].end.instr[0].slot != check.instr[0].slot))
+ {
+ which = fail;
+ } else {
+ which = succ;
+ }
+ printf("%s", which);
+ PRINT_DEBUG(test[i].rule, EXPAND(test[i].start), EXPAND(test[i].end), EXPAND(check));
+ }
+
+#if 0
+ /* A.1 Rule 1 - Four of a Kind */
+ RULE(start, SLOT_U, SLOT_U, SLOT_U, SLOT_U);
+ end = determine_slotting(start);
+ PRINT_DEBUG("Rule 1A", EXPAND(start), EXPAND(end));
+
+ RULE(start, SLOT_L, SLOT_L, SLOT_L, SLOT_L);
+ end = determine_slotting(start);
+ PRINT_DEBUG("Rule 1B", EXPAND(start), EXPAND(end));
+
+ /* A.2 Rule 2 - Three of a Kind */
+#endif
+
+ return 0;
+}