#include "platform.h"
#include "regex_test_lib.h"
#include "gnunet_util_lib.h"
#include "regex_internal.h"
Go to the source code of this file.
Functions | |
static char | get_random_literal () |
Get a (pseudo) random valid literal for building a regular expression. More... | |
char * | REGEX_TEST_generate_random_regex (size_t rx_length, char *matching_str) |
Generate a (pseudo) random regular expression of length 'rx_length', as well as a (optional) string that will be matched by the generated regex. More... | |
char * | REGEX_TEST_generate_random_string (size_t max_len) |
Generate a random string of maximum length 'max_len' that only contains literals allowed in a regular expression. More... | |
|
static |
Get a (pseudo) random valid literal for building a regular expression.
Definition at line 37 of file regex_test_random.c.
References ALLOWED_LITERALS, GNUNET_CRYPTO_QUALITY_WEAK, and GNUNET_CRYPTO_random_u32().
Referenced by REGEX_TEST_generate_random_regex(), and REGEX_TEST_generate_random_string().
char * REGEX_TEST_generate_random_regex | ( | size_t | rx_length, |
char * | matching_str | ||
) |
Generate a (pseudo) random regular expression of length 'rx_length', as well as a (optional) string that will be matched by the generated regex.
The returned regex needs to be freed.
rx_length | length of the random regex. |
matching_str | (optional) pointer to a string that will contain a string that will be matched by the generated regex, if 'matching_str' pointer was not NULL. Make sure you allocated at least rx_length+1 bytes for this string. |
Definition at line 64 of file regex_test_random.c.
References get_random_literal(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), and GNUNET_malloc.
char * REGEX_TEST_generate_random_string | ( | size_t | max_len | ) |
Generate a random string of maximum length 'max_len' that only contains literals allowed in a regular expression.
The string might be 0 chars long but is garantueed to be shorter or equal to 'max_len'.
max_len | maximum length of the string that should be generated. |
Definition at line 155 of file regex_test_random.c.
References get_random_literal(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_malloc, and GNUNET_strdup.