summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2017-01-17 18:15:47 -0800
committerJohn Hawthorn <john.hawthorn@gmail.com>2017-01-26 22:09:16 -0800
commit618be61d1b9d83c624e001ca3c2c6b251e8e53fb (patch)
tree3ab0e2d3d55dad9b68b0b113b16eb05e9114ec5c /test
parent1f77253e52439a9441daa5748cb4e4f4a98bd18d (diff)
Add test for large input
Diffstat (limited to 'test')
-rw-r--r--test/fzytest.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/test/fzytest.c b/test/fzytest.c
index 3786cd7..7c9d1cd 100644
--- a/test/fzytest.c
+++ b/test/fzytest.c
@@ -1,6 +1,8 @@
+#define _GNU_SOURCE
+#include <malloc.h>
+#include <signal.h>
#include <stdio.h>
#include <string.h>
-#include <signal.h>
#include "../config.h"
#include "match.h"
@@ -279,6 +281,32 @@ void test_choices_unicode() {
choices_destroy(&choices);
}
+void test_choices_large_input() {
+ choices_t choices;
+ choices_init(&choices);
+
+ int N = 100000;
+ char *strings[N];
+
+ for(int i = 0; i < N; i++) {
+ asprintf(&strings[i], "%i", i);
+ choices_add(&choices, strings[i]);
+ }
+
+ choices_search(&choices, "12");
+
+ /* Must match `seq 0 99999 | grep '.*1.*2.*' | wc -l` */
+ assert(choices.available == 8146);
+
+ assert_streq(choices_get(&choices, 0), "12")
+
+ for(int i = 0; i < N; i++) {
+ free(strings[i]);
+ }
+
+ choices_destroy(&choices);
+}
+
void summary() {
printf("%i tests, %i assertions, %i failures\n", testsrun, assertionsrun, testsfailed);
}
@@ -310,6 +338,7 @@ int main(int argc, char *argv[]) {
runtest(test_choices_2);
runtest(test_choices_without_search);
runtest(test_choices_unicode);
+ runtest(test_choices_large_input);
summary();