~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Infrastructure: Switch testing over to Autotest.
[mLib]
/
struct
/
t
/
assoc-test.c
diff --git
a/struct/assoc-test.c
b/struct/t/assoc-test.c
similarity index 86%
rename from
struct/assoc-test.c
rename to
struct/t/assoc-test.c
index
5949857
..
05a05d9
100644
(file)
--- a/
struct/assoc-test.c
+++ b/
struct/t/assoc-test.c
@@
-1,3
+1,4
@@
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-23,14
+24,14
@@
int main(void)
char *p;
atom_table at;
assoc_table t;
char *p;
atom_table at;
assoc_table t;
- size_t n = 0;
+ size_t n = 0
, j
;
atom_createtable(&at);
assoc_create(&t);
while (fgets(buf, sizeof(buf), stdin)) {
atom_createtable(&at);
assoc_create(&t);
while (fgets(buf, sizeof(buf), stdin)) {
+/* printf("+++ %s", buf); */
buf[strlen(buf) - 1] = 0;
buf[strlen(buf) - 1] = 0;
-/* printf("# %s\n", buf); */
p = strtok(buf, " ");
if (strcmp(p, "set") == 0) {
p = strtok(buf, " ");
if (strcmp(p, "set") == 0) {
@@
-71,17
+72,23
@@
int main(void)
puts("*NOMEM*");
continue;
}
puts("*NOMEM*");
continue;
}
- for (vv = v, assoc_mkiter(&i, &t); (w = assoc_next(&i)) != 0; vv++)
+ for (vv = v, assoc_mkiter(&i, &t), j = 0;
+ (w = assoc_next(&i)) != 0;
+ vv++, j++) {
+ assert(j < n);
*vv = w;
*vv = w;
+ }
+ assert(j == n);
qsort(v, n, sizeof(*v), cmp);
printf("%s:%i", ATOM_NAME(ASSOC_ATOM(*v)), (*v)->i);
qsort(v, n, sizeof(*v), cmp);
printf("%s:%i", ATOM_NAME(ASSOC_ATOM(*v)), (*v)->i);
- for (vv = v + 1; --
n
; vv++)
+ for (vv = v + 1; --
j
; vv++)
printf(" %s:%i", ATOM_NAME(ASSOC_ATOM(*vv)), (*vv)->i);
free(v);
putchar('\n');
}
} else
puts("*BAD*");
printf(" %s:%i", ATOM_NAME(ASSOC_ATOM(*vv)), (*vv)->i);
free(v);
putchar('\n');
}
} else
puts("*BAD*");
+/* printf("--- %d\n", n); */
}
assoc_destroy(&t);
}
assoc_destroy(&t);