mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-22 10:22:06 +03:00
Update test suite for corestrings and log module changes. Update test data for rejection of hostless http(s) urls.
This commit is contained in:
parent
42be1ffa7b
commit
ef6b20fe83
@ -22,9 +22,9 @@ urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
|
|||||||
urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
|
urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
|
||||||
urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
|
urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
|
||||||
|
|
||||||
nsurl_SRCS := utils/log.c utils/nsurl.c test/nsurl.c
|
nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c test/nsurl.c
|
||||||
nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet)
|
nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
|
||||||
nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet)
|
nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
|
||||||
|
|
||||||
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
|
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
|
||||||
nsoption_CFLAGS := -Dnsgtk
|
nsoption_CFLAGS := -Dnsgtk
|
||||||
|
38
test/nsurl.c
38
test/nsurl.c
@ -6,12 +6,10 @@
|
|||||||
#include <libwapcaplet/libwapcaplet.h>
|
#include <libwapcaplet/libwapcaplet.h>
|
||||||
|
|
||||||
#include "desktop/netsurf.h"
|
#include "desktop/netsurf.h"
|
||||||
|
#include "utils/corestrings.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/nsurl.h"
|
#include "utils/nsurl.h"
|
||||||
|
|
||||||
/* desktop/netsurf.h */
|
|
||||||
bool verbose_log = true;
|
|
||||||
|
|
||||||
struct test_pairs {
|
struct test_pairs {
|
||||||
const char* test;
|
const char* test;
|
||||||
const char* res;
|
const char* res;
|
||||||
@ -30,9 +28,10 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct test_pairs create_tests[] = {
|
static const struct test_pairs create_tests[] = {
|
||||||
{ "http:", "http:" },
|
{ "", NULL },
|
||||||
{ "http:/", "http:" },
|
{ "http:", NULL },
|
||||||
{ "http://", "http:" },
|
{ "http:/", NULL },
|
||||||
|
{ "http://", NULL },
|
||||||
{ "http:a", "http://a/" },
|
{ "http:a", "http://a/" },
|
||||||
{ "http:a/", "http://a/" },
|
{ "http:a/", "http://a/" },
|
||||||
{ "http:a/b", "http://a/b" },
|
{ "http:a/b", "http://a/b" },
|
||||||
@ -182,6 +181,13 @@ int main(void)
|
|||||||
const struct test_triplets *ttest;
|
const struct test_triplets *ttest;
|
||||||
int passed = 0;
|
int passed = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
nserror err;
|
||||||
|
|
||||||
|
verbose_log = true;
|
||||||
|
|
||||||
|
if (corestrings_init() != NSERROR_OK) {
|
||||||
|
assert(0 && "Failed to init corestrings.");
|
||||||
|
}
|
||||||
|
|
||||||
/* Create base URL */
|
/* Create base URL */
|
||||||
if (nsurl_create("http://a/b/c/d;p?q", &base) != NSERROR_OK) {
|
if (nsurl_create("http://a/b/c/d;p?q", &base) != NSERROR_OK) {
|
||||||
@ -228,8 +234,22 @@ int main(void)
|
|||||||
/* Create tests */
|
/* Create tests */
|
||||||
LOG(("Testing nsurl_create"));
|
LOG(("Testing nsurl_create"));
|
||||||
for (test = create_tests; test->test != NULL; test++) {
|
for (test = create_tests; test->test != NULL; test++) {
|
||||||
if (nsurl_create(test->test, &base) != NSERROR_OK) {
|
err = nsurl_create(test->test, &base);
|
||||||
LOG(("Failed to create URL:\n\t\t%s.", test->test));
|
if (err != NSERROR_OK || test->res == NULL) {
|
||||||
|
if (test->res == NULL && err != NSERROR_OK) {
|
||||||
|
LOG(("\tPASS: \"%s\"\t--> BAD INPUT",
|
||||||
|
test->test));
|
||||||
|
passed++;
|
||||||
|
} else if (test->res != NULL && err != NSERROR_OK) {
|
||||||
|
LOG(("Failed to create URL:\n\t\t%s.",
|
||||||
|
test->test));
|
||||||
|
} else {
|
||||||
|
LOG(("\tFAIL: \"%s\"\t--> %s",
|
||||||
|
test->test, nsurl_access(base)));
|
||||||
|
LOG(("\t\tExpecting BAD INPUT"));
|
||||||
|
}
|
||||||
|
if (err == NSERROR_OK)
|
||||||
|
nsurl_unref(base);
|
||||||
} else {
|
} else {
|
||||||
if (strcmp(nsurl_access(base), test->res) == 0) {
|
if (strcmp(nsurl_access(base), test->res) == 0) {
|
||||||
LOG(("\tPASS: \"%s\"\t--> %s",
|
LOG(("\tPASS: \"%s\"\t--> %s",
|
||||||
@ -286,6 +306,8 @@ int main(void)
|
|||||||
LOG(("Failed %d out of %d", count - passed, count));
|
LOG(("Failed %d out of %d", count - passed, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corestrings_fini();
|
||||||
|
|
||||||
LOG(("Remaining lwc strings:"));
|
LOG(("Remaining lwc strings:"));
|
||||||
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
|
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user