summaryrefslogtreecommitdiff
path: root/tests/vec.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-10-16 21:12:00 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-10-16 21:12:00 +0300
commite962c7a4c70b6e2c3f2df89be176c491d62739e7 (patch)
treea5c22494b81fdc52ff053fc417f5039a2efb6dba /tests/vec.c
parent717eb9512cbd98e965c1b842cbc9d84e218c37c2 (diff)
downloadconts-e962c7a4c70b6e2c3f2df89be176c491d62739e7.tar.gz
conts-e962c7a4c70b6e2c3f2df89be176c491d62739e7.zip
use different iteration values for test/benchHEADmaster
+ Regular tests are pretty darn slow with valgrind on certain virtual machines, speed them up a bit
Diffstat (limited to 'tests/vec.c')
-rw-r--r--tests/vec.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/vec.c b/tests/vec.c
index af36b5c..09a8deb 100644
--- a/tests/vec.c
+++ b/tests/vec.c
@@ -32,16 +32,16 @@ int main()
assert(false && "iterating empty vec");
}
- for (int i = 0; i < 1000000; ++i) {
+ for (int i = 0; i < ITER; ++i) {
if (!ints_append(&ints, i)) {
fprintf(stderr, "failed appending %d to vec\n", i);
ints_destroy(&ints);
return -1;
}
}
- assert(ints_len(&ints) == 1000000);
+ assert(ints_len(&ints) == ITER);
- for (int i = 0; i < 1000000; ++i) {
+ for (int i = 0; i < ITER; ++i) {
int *v = ints_at(&ints, i);
assert(v && *v == i);
}
@@ -52,8 +52,7 @@ int main()
i++;
}
- /* TEN million !!1! */
- if (!ints_reserve(&ints, 10000000)) {
+ if (!ints_reserve(&ints, 10 * ITER)) {
fprintf(stderr, "failed reserving vec\n");
ints_destroy(&ints);
return -1;
@@ -63,13 +62,13 @@ int main()
* (is shrink necessary when we already have reserve? I
* guess it shows intention a bit better and just asserts instead of
* maybe fails?) */
- ints_shrink(&ints, 1000000);
+ ints_shrink(&ints, ITER);
/* so the above is equivalent to */
- assert(ints_reserve(&ints, 1000000));
- assert(ints_len(&ints) == 1000000);
+ assert(ints_reserve(&ints, ITER));
+ assert(ints_len(&ints) == ITER);
- for (int i = 1000000 - 1; i >= 0; --i) {
+ for (int i = ITER - 1; i >= 0; --i) {
ints_remove(&ints, i);
}
assert(ints_len(&ints) == 0);