diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-16 23:47:21 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-16 23:47:24 +0100 |
commit | 338694c827320467dc5bff124c25ff82603e51a6 (patch) | |
tree | e83502c7166ddfb8f760e147a90c71d8f49cf63f /tests | |
parent | 459f11326feb68947905e267960b736ba0dff8a2 (diff) |
Exclude last parenthesis in url extraction if unbalanced, fix tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index 38dd534..647fdff 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -7,32 +7,44 @@ int main() { std::vector<std::string> urls; - urls = QuickMedia::extract_urls("example.com"); + urls.clear(); + QuickMedia::extract_urls("example.com", urls); assert_equals(urls.size(), 1); assert_equals(urls[0], "example.com"); - urls = QuickMedia::extract_urls("example.com, is where I like to go"); + urls.clear(); + QuickMedia::extract_urls("example.com, is where I like to go", urls); assert_equals(urls.size(), 1); assert_equals(urls[0], "example.com"); - urls = QuickMedia::extract_urls("The website I like to go to is example.com"); + urls.clear(); + QuickMedia::extract_urls("The website I like to go to is example.com", urls); assert_equals(urls.size(), 1); assert_equals(urls[0], "example.com"); - urls = QuickMedia::extract_urls("example.com. Is also a website"); + urls.clear(); + QuickMedia::extract_urls("example.com. Is also a website", urls); assert_equals(urls.size(), 1); assert_equals(urls[0], "example.com"); - urls = QuickMedia::extract_urls("these. are. not. websites."); + urls.clear(); + QuickMedia::extract_urls("these. are. not. websites.", urls); assert_equals(urls.size(), 0); - urls = QuickMedia::extract_urls("This is not an url: example."); + urls.clear(); + QuickMedia::extract_urls("This is not an url: example.", urls); assert_equals(urls.size(), 0); - urls = QuickMedia::extract_urls("the.se/~#423-_/2f.no/3df a.re considered sub.websit.es"); + urls.clear(); + QuickMedia::extract_urls("the.se/~#423-_/2f.no/3df a.re considered sub.websit.es", urls); 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); + assert_equals(urls.size(), 1); + assert_equals(urls[0], "https://emojipedia.org/emoji/%23%EF%B8%8F%E2%83%A3/"); return 0; } |