Files
libprozilla/tests/url_parse_test.c
T
2026-07-14 17:01:03 +02:00

29 lines
774 B
C

#include <prozilla.h>
#include <url.h>
#include <stdio.h>
static int check(const char *text, uerr_t protocol, unsigned short port)
{
urlinfo url;
uerr_t result = proz_parse_url(text, &url, 0);
if (result != URLOK || url.proto != protocol || url.port != port)
{
fprintf(stderr, "failed to parse %s (result=%d protocol=%d port=%u)\n",
text, result, url.proto, url.port);
return 1;
}
proz_free_url(&url, 0);
return 0;
}
int main(void)
{
return check("http://example.invalid/file", URLHTTP, 80)
|| check("https://example.invalid/file", URLHTTPS, 443)
|| check("ftp://example.invalid/file", URLFTP, 21)
|| check("ftps://example.invalid/file", URLFTPS, 990)
|| check("sftp://example.invalid/file", URLSFTP, 22);
}