fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit f3a04337d26ff5e4313010b8ac48239cbb10dd7d
parent 23904b0490cc3f535cbdc91f77ce850fa57da6b0
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Tue, 17 Jan 2017 18:15:47 -0800

Add test for large input

Diffstat:
Mtest/fzytest.c | 31++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git 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();