MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/stl/url.cpp:9–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include "fl/stl/url.h"
8
9FL_TEST_FILE(FL_FILEPATH) {
10
11using namespace fl;
12
13FL_TEST_CASE("Url - basic http") {
14 url u("http://example.com/path");
15 FL_CHECK(u.isValid());
16 FL_CHECK(u.scheme() == "http");
17 FL_CHECK(u.host() == "example.com");
18 FL_CHECK(u.path() == "/path");
19 FL_CHECK(u.port() == 80);
20 FL_CHECK(u.port_str().empty());
21 FL_CHECK(u.query().empty());
22 FL_CHECK(u.fragment().empty());
23 FL_CHECK(u.userinfo().empty());
24}
25
26FL_TEST_CASE("Url - full URL with all components") {
27 url u("https://user:pass@api.example.com:8080/foo/bar?key=val&a=b#section");
28 FL_CHECK(u.isValid());
29 FL_CHECK(u.scheme() == "https");
30 FL_CHECK(u.userinfo() == "user:pass");
31 FL_CHECK(u.host() == "api.example.com");
32 FL_CHECK(u.port() == 8080);
33 FL_CHECK(u.port_str() == "8080");
34 FL_CHECK(u.path() == "/foo/bar");
35 FL_CHECK(u.query() == "key=val&a=b");
36 FL_CHECK(u.fragment() == "section");
37 FL_CHECK(u.authority() == "user:pass@api.example.com:8080");
38}
39
40FL_TEST_CASE("Url - default ports") {
41 url http("http://h.com/");
42 FL_CHECK(http.port() == 80);
43
44 url https("https://h.com/");
45 FL_CHECK(https.port() == 443);
46
47 url ws("ws://h.com/");
48 FL_CHECK(ws.port() == 80);
49
50 url wss("wss://h.com/");
51 FL_CHECK(wss.port() == 443);
52
53 url ftp("ftp://h.com/");
54 FL_CHECK(ftp.port() == 21);
55}
56
57FL_TEST_CASE("Url - missing components") {
58 // No path
59 url u1("http://example.com");
60 FL_CHECK(u1.isValid());
61 FL_CHECK(u1.host() == "example.com");
62 FL_CHECK(u1.path().empty());
63
64 // No query/fragment
65 url u2("http://example.com/p");
66 FL_CHECK(u2.query().empty());

Callers

nothing calls this directly

Calls 15

parse_lnkFunction · 0.85
parse_lnk_with_metadataFunction · 0.85
schemeMethod · 0.80
hostMethod · 0.80
port_strMethod · 0.80
fragmentMethod · 0.80
userinfoMethod · 0.80
authorityMethod · 0.80
wasRepairedMethod · 0.80
string_viewClass · 0.50
stringClass · 0.50
isValidMethod · 0.45

Tested by

no test coverage detected