fix: fix testing code
ci/woodpecker/push/woodpecker Pipeline was successful Details

trie-skips
Jef Roosens 2022-12-03 21:00:07 +01:00
parent 2d89c5e80f
commit a6e7b1dfd3
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 20 additions and 17 deletions

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
typedef struct fuzzyconfig {
int seed;
@ -29,12 +30,14 @@ void random_clean_string(char* s, int len) {
}
void random_string(char* s, int len) {
// len - 1 ensures that we can still set the null byte for the final byte
int val;
int val = rand();
for (int i = 0; i < len - 1; i++) {
// String can't be an empty string as they aren't supported
s[0] = (char)(val % 255 + 1);
for (int i = 1; i < len - 1; i++) {
val = rand();
s[i] = ((char *) &val)[0];
s[i] = (char)(val % 256);
}
// Just in case no null characters were created