aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-03 18:51:13 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-05 05:53:41 +0200
commita105630199bb4be80b3a8228a2c3e5b0c7347625 (patch)
treedbb50d356d6201085362250a2891c6ab22ae8e59 /tests
parent3ca7ed72c2f3a046e94213a8c26d80eafde9585c (diff)
Make url parsing better by using a list of valid tlds. Make urls blue in text
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/tests/main.cpp b/tests/main.cpp
index 647fdff..c5138e3 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -6,44 +6,45 @@
int main() {
std::vector<std::string> urls;
+ const char *str;
- urls.clear();
- QuickMedia::extract_urls("example.com", urls);
+ str = "example.com";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 1);
assert_equals(urls[0], "example.com");
- urls.clear();
- QuickMedia::extract_urls("example.com, is where I like to go", urls);
+ str = "example.com, is where I like to go";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 1);
assert_equals(urls[0], "example.com");
- urls.clear();
- QuickMedia::extract_urls("The website I like to go to is example.com", urls);
+ str = "The website I like to go to is example.com";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 1);
assert_equals(urls[0], "example.com");
- urls.clear();
- QuickMedia::extract_urls("example.com. Is also a website", urls);
+ str = "example.com. Is also a website";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 1);
assert_equals(urls[0], "example.com");
- urls.clear();
- QuickMedia::extract_urls("these. are. not. websites.", urls);
+ str = "these. are. not. websites.";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 0);
- urls.clear();
- QuickMedia::extract_urls("This is not an url: example.", urls);
+ str = "This is not an url: example.";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 0);
- urls.clear();
- QuickMedia::extract_urls("the.se/~#423-_/2f.no/3df a.re considered sub.websit.es", urls);
+ str = "the.se/~#423-_/2f.no/3df a.re considered sub.websit.es, this.is.not";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 3);
assert_equals(urls[0], "the.se/~#423-_/2f.no/3df");
assert_equals(urls[1], "a.re");
assert_equals(urls[2], "sub.websit.es");
- urls.clear();
- QuickMedia::extract_urls("(see https://emojipedia.org/emoji/%23%EF%B8%8F%E2%83%A3/)", urls);
+ str = "(see https://emojipedia.org/emoji/%23%EF%B8%8F%E2%83%A3/)";
+ urls = QuickMedia::ranges_get_strings(str, QuickMedia::extract_urls(str));
assert_equals(urls.size(), 1);
assert_equals(urls[0], "https://emojipedia.org/emoji/%23%EF%B8%8F%E2%83%A3/");
return 0;