chiark / gitweb /
testrig: Provide useful interface for more complicated test rigs.
[mLib] / da-test.c
index 6a73b0bb270029bad21f4c65a7df8fca7ed7f0d0..38b6055c52e8510b535a779c53f1b47d00825e88 100644 (file)
--- a/da-test.c
+++ b/da-test.c
@@ -64,7 +64,7 @@ int main(void)
        vec vv;
        char *q = p;
        DA_CREATE(&vv);
-/*     putchar('#'); */
+/*     putchar('#'); */
        while ((p = strtok(0, " ")) != 0) {
          int n = atoi(p);
          DA_PUSH(&vv, n);
@@ -82,10 +82,10 @@ int main(void)
        DA_DESTROY(&vv);
       } else if (strcmp(p, "delete") == 0) {
        int n = atoi(strtok(0, " "));
-       DA_SLIDE(&v, -n);
+       DA_UNSLIDE(&v, n);
       } else if (strcmp(p, "reduce") == 0) {
        int n = atoi(strtok(0, " "));
-       DA_EXTEND(&v, -n);
+       DA_SHRINK(&v, n);
       } else if (strcmp(p, "set") == 0) {
        size_t i = atoi(strtok(0, " "));
        int n = atoi(strtok(0, " "));
@@ -103,6 +103,10 @@ int main(void)
          puts("*RANGE*");
        else
          printf("%i\n", DA(&v)[i]);
+      } else if (strcmp(p, "first") == 0) {
+       printf("%i\n", DA_FIRST(&v));
+      } else if (strcmp(p, "last") == 0) {
+       printf("%i\n", DA_LAST(&v));
       } else if (strcmp(p, "show") == 0) {
        if (DA_LEN(&v) == 0)
          puts("*EMPTY*");