#include "patprep.h" #include // Below is a series of test cases that were not present in the original. The // purpose of this function is to output the test cases that will go into the // rust version of the project, to assert that they behave correctly. char *cases[] = {"testing", "test*", "/foo/bar/whatever[0-9]", "/foo/bar/whatever*[0-9]", "/foo/bar/whatever[0-9]", "/foo/bar/whatever[0-9]*", "/foo/bar/*whatever[0-9]", "fooz]", NULL}; // Since patprep gives us the END of the array, we need to search for // the beginning. And both ends are null terminated, because Unix. // There is a ton of undefined behavior here, all of which is predicated // on never sending patprep something it can't parse, or a zero-length // string. void main() { int i; char *c; char *g; for (i = 0, c = cases[0]; cases[i] != NULL; ++i, c = cases[i]) { g = patprep(c); while (*g != 0) { g--; } g++; printf("assert_eq!(prepare_pattern(b\"%s\"), b\"%s\");\n", c, g); } }