Fix test Error.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-01-13 23:06:29 +01:00
parent c652d288e0
commit d7274d4a8d

View File

@@ -45,12 +45,11 @@ bool found_route(restd_server_t *server, const char *method, const char *path)
while (hooks->getnext(hooks, &obj, false) == true) while (hooks->getnext(hooks, &obj, false) == true)
{ {
restd_hook_t *hook = (restd_hook_t *)obj.data; restd_hook_t *hook = (restd_hook_t *)obj.data;
if (hook->method && method && strcmp(hook->method, method)==0) if (hook->method && method && strcmp(hook->method, method) == 0)
{ {
if (hook->path && path && strcmp(hook->path, path)==0) if (hook->path && path && strcmp(hook->path, path) == 0)
return true; return true;
} }
} }
return false; return false;
@@ -58,7 +57,7 @@ bool found_route(restd_server_t *server, const char *method, const char *path)
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
bool contain (const char *src, const char *dest, int len) bool contain(const char *src, const char *dest, int len)
{ {
int len_src, len_dest; int len_src, len_dest;
int i = 0; int i = 0;
@@ -66,6 +65,7 @@ bool contain (const char *src, const char *dest, int len)
len_src = strlen(src); len_src = strlen(src);
if (len_src < len) if (len_src < len)
return false; return false;
len_dest = strlen(dest); len_dest = strlen(dest);
if (len_dest < len) if (len_dest < len)
return false; return false;
@@ -91,7 +91,7 @@ bool found_special_route(restd_server_t *server, const char *method, const char
while (hooks->getnext(hooks, &obj, false) == true) while (hooks->getnext(hooks, &obj, false) == true)
{ {
restd_hook_t *hook = (restd_hook_t *)obj.data; restd_hook_t *hook = (restd_hook_t *)obj.data;
if (hook->method && method && strcmp(hook->method, method)==0) if (hook->method && method && strcmp(hook->method, method) == 0)
{ {
if (hook->path && path) if (hook->path && path)
{ {
@@ -103,19 +103,19 @@ bool found_special_route(restd_server_t *server, const char *method, const char
pos = i; pos = i;
i++; i++;
} }
printf("pos: %d\n", pos); // printf("hook path: %s, path: %s\n", hook->path, path);
printf("contain: %s\n", contain(hook->path, path, pos)?"TRUE":"FALSE"); // printf("pos: %d\n", pos);
if ( pos != -1 && contain(hook->path, path, pos)) // printf("contain: %s\n", contain(hook->path, path, pos) ? "TRUE" : "FALSE");
if (pos != -1 && contain(hook->path, path, pos))
{ {
const char *buffer = &path[i]; const char *buffer = &path[pos];
printf("buffer: %s\n", buffer); // printf("buffer: <%s>\n", buffer);
*id = atoi(buffer);
return true; return true;
} }
else if (strcmp(hook->path, path)==0) else if (strcmp(hook->path, path) == 0)
return true; return true;
} }
return true;
} }
} }
@@ -170,10 +170,10 @@ TEST("Rest - create access regular route free\t")
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
TEST("Rest - create access regex route free\t") TEST("Rest - create access route with param free\t")
{ {
restd_server_t *rest_server; restd_server_t *rest_server;
int id = 0; int id = 0;
rest_server = restd_server_new(); rest_server = restd_server_new();
ASSERT_NOT_NULL(rest_server); ASSERT_NOT_NULL(rest_server);