fixed broken test with constant ov array size set to 30
This commit is contained in:
parent
3ae3da52c7
commit
07443aa8a8
3 changed files with 31 additions and 8 deletions
|
@ -0,0 +1,25 @@
|
|||
Building with CMAKE on Windows using VCPKG
|
||||
=======================================
|
||||
|
||||
This document describes how to compile, build and install libr3 on Windows using CMake, MSVC compiler and VCPKG
|
||||
|
||||
VCPKG can be installed from
|
||||
|
||||
https://github.com/Microsoft/vcpkg
|
||||
|
||||
Once VCPKG is installed you must install libcheck and pcre before running the folloiwing command to configure build
|
||||
|
||||
cmake -H"." -B"<BUILD_DIRECTORY>" -G"<GENERATOR_NAME>" -DCMAKE_TOOLCHAIN_FILE=<VCPKG_TOOLCHAIN_FILE> -DVCPKG_TARGET_TRIPLET=<VCPKG_TARGET_TRIPLET>
|
||||
|
||||
Then to perform build
|
||||
|
||||
cmake --build -B"<BUILD_DIRECTORY>" --target ALL_BUILD --config "<CMAKE_BUILD_TYPE>"
|
||||
|
||||
Then to run tests, you must copy pcre.dll and pcre.pdb file to output directory prior to running tests
|
||||
|
||||
cmake --build -B"<BUILD_DIRECTORY>" --target RUN_TESTS --config "<CMAKE_BUILD_TYPE>"
|
||||
|
||||
Window build is currently WIP.
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,8 @@
|
|||
// PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
#define MAX_SUBSTRINGS 30
|
||||
|
||||
#include "r3.h"
|
||||
#include "r3_slug.h"
|
||||
#include "slug.h"
|
||||
|
@ -329,7 +331,7 @@ R3Node * r3_tree_matchl(const R3Node * n, const char * path, unsigned int path_l
|
|||
info("COMPARE PCRE_PATTERN\n");
|
||||
const char *substring_start = 0;
|
||||
int substring_length = 0;
|
||||
int *ov = malloc(sizeof(int) * n->ov_cnt);
|
||||
int ov[MAX_SUBSTRINGS];
|
||||
int rc;
|
||||
|
||||
info("pcre matching %s on %s\n", n->combined_pattern, path);
|
||||
|
@ -360,7 +362,6 @@ R3Node * r3_tree_matchl(const R3Node * n, const char * path, unsigned int path_l
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
free(ov);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -388,7 +389,6 @@ R3Node * r3_tree_matchl(const R3Node * n, const char * path, unsigned int path_l
|
|||
str_array_append(&entry->vars, substring_start, substring_length);
|
||||
}
|
||||
|
||||
free(ov);
|
||||
// since restlen == 0 return the edge quickly.
|
||||
return e->child && e->child->endpoint ? e->child : NULL;
|
||||
}
|
||||
|
@ -415,12 +415,10 @@ R3Node * r3_tree_matchl(const R3Node * n, const char * path, unsigned int path_l
|
|||
str_array_append(&entry->vars , substring_start, substring_length);
|
||||
}
|
||||
|
||||
free(ov);
|
||||
// get the length of orginal string: $0
|
||||
return r3_tree_matchl( e->child, path + (ov[1] - ov[0]), restlen, entry);
|
||||
}
|
||||
// does not match
|
||||
free(ov);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ START_TEST (test_compile)
|
|||
|
||||
entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") );
|
||||
m = r3_tree_matchl( n , "/foo/xxx", strlen("/foo/xxx"), entry);
|
||||
// ck_assert( m );
|
||||
ck_assert( m );
|
||||
match_entry_free(entry);
|
||||
|
||||
entry = match_entry_createl( "/some_id" , strlen("/some_id") );
|
||||
|
@ -472,8 +472,8 @@ START_TEST (test_pcre_patterns_insert_2)
|
|||
// r3_tree_dump(n, 0);
|
||||
R3Node *matched;
|
||||
matched = r3_tree_match(n, "/post/11/22", NULL);
|
||||
// ck_assert(matched);
|
||||
// ck_assert(matched->endpoint > 0);
|
||||
ck_assert(matched);
|
||||
ck_assert(matched->endpoint > 0);
|
||||
|
||||
r3_tree_free(n);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue