summaryrefslogtreecommitdiff
path: root/support/dktools/test-dk4maaul.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/test-dk4maaul.c
Initial commit
Diffstat (limited to 'support/dktools/test-dk4maaul.c')
-rw-r--r--support/dktools/test-dk4maaul.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/support/dktools/test-dk4maaul.c b/support/dktools/test-dk4maaul.c
new file mode 100644
index 0000000000..1b439c5c7c
--- /dev/null
+++ b/support/dktools/test-dk4maaul.c
@@ -0,0 +1,109 @@
+/*
+ WARNING: This file was generated by dkct.
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: test-dk4maaul.ctr
+*/
+
+/** @file test-dk4maaul.c The test-dk4maaul module.
+*/
+
+
+#line 1 "test-dk4maaul.ctr"
+#include "dk4conf.h"
+
+#include <stdio.h>
+
+#include "dk4error.h"
+#include "dk4maaul.h"
+
+
+
+#line 9 "test-dk4maaul.ctr"
+
+
+static
+void
+show_error(dk4_er_t *erp)
+{
+ if (DK4_E_NONE != erp->ec) {
+ switch(erp->ec) {
+ case DK4_E_MATH_OVERFLOW: {
+ printf(" overflow");
+ } break;
+ case DK4_E_MATH_DIVZERO: {
+ printf(" divzero");
+ } break;
+ default: {
+ printf(" %d", erp->ec);
+ } break;
+ }
+ }
+}
+
+
+
+int main(void)
+{
+ char buffer[128]; /* Input line buffer */
+ dk4_er_t er; /* Error report */
+ unsigned long i1; /* First operand */
+ unsigned long i2; /* Second operand */
+ int exc; /* Exit code */
+ int cc; /* Flag: Can continue */
+ unsigned long c1; /* First operand as char */
+ unsigned long c2; /* Second operand as char */
+ unsigned long c3; /* Result as char */
+
+
+
+#line 45 "test-dk4maaul.ctr"
+
+
+#line 46 "test-dk4maaul.ctr"
+ exc = 0;
+ cc = 1;
+ while((1 == cc) && (fgets(buffer, sizeof(buffer), stdin))) {
+ if (sscanf(buffer, "%lu %lu", &i1, &i2) == 2) {
+ c1 = i1;
+ c2 = i2;
+ printf("%lu %lu\n", c1, c2);
+ dk4error_init(&er);
+ c3 = dk4ma_ulong_add(c1, c2, &er);
+ printf("\t+ %lu", c3);
+ show_error(&er);
+ printf("\n");
+
+ dk4error_init(&er);
+ c3 = dk4ma_ulong_sub(c1, c2, &er);
+ printf("\t- %lu", c3);
+ show_error(&er);
+ printf("\n");
+
+ dk4error_init(&er);
+ c3 = dk4ma_ulong_mul(c1, c2, &er);
+ printf("\t* %lu", c3);
+ show_error(&er);
+ printf("\n");
+
+ dk4error_init(&er);
+ c3 = dk4ma_ulong_div(c1, c2, &er);
+ printf("\t/ %lu", c3);
+ show_error(&er);
+ printf("\n");
+ } else {
+ exc = 1;
+ fprintf(stderr, "test-dk4maac:ERROR: Invalid input line!\n");
+ fflush(stderr);
+ cc = 0;
+ }
+ }
+
+
+#line 84 "test-dk4maaul.ctr"
+
+
+#line 85 "test-dk4maaul.ctr"
+ return exc;
+}
+