From 4463fd7df891648582c366a4570ca67da9d0b5f1 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 18 Oct 2021 11:32:02 -0700 Subject: [PATCH] ... --- test/unit/test_utils.c | 2 ++ test/unit/test_utils.h | 2 ++ test/unit/tree.tests.c | 49 ++++++++++++++++++++++++++++++------------ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/test/unit/test_utils.c b/test/unit/test_utils.c index 0b0520c..6320b86 100644 --- a/test/unit/test_utils.c +++ b/test/unit/test_utils.c @@ -15,6 +15,8 @@ void reset_env() { void setup_env() { clean_env(); + //srand(time(NULL)); + create_test_directory(TEST_DIRECTORY); create_test_file(TEST_FILE_1,TEST_FILE_1_CONTENTS); create_test_file(TEST_FILE_2,TEST_FILE_2_CONTENTS); diff --git a/test/unit/test_utils.h b/test/unit/test_utils.h index 9fc057d..2d7e4e6 100644 --- a/test/unit/test_utils.h +++ b/test/unit/test_utils.h @@ -2,6 +2,8 @@ #define __TEST_UTILS_H_ #include +#include +#include #include #include diff --git a/test/unit/tree.tests.c b/test/unit/tree.tests.c index cf53058..b498633 100644 --- a/test/unit/tree.tests.c +++ b/test/unit/tree.tests.c @@ -3,6 +3,7 @@ #include int main(); +static char *create_random_path(); static void tree_add_basic_test(); static void tree_add_extended_test(); static void tree_init_basic_test(); @@ -54,28 +55,48 @@ static void tree_add_basic_test() { tree_free(tree); } -static void tree_add_extended_test() { - struct tree *tree; - struct file *file; +static char *create_random_path() { + char *str; + int len, index; char valid[] = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; + str = malloc(100); + assert(str!=NULL); + + // make sure string is at least 1 character long (not including '\0' + len = rand()%98; + len+=2; + + index = 0; + while(len>1) { + for(int i=0;i