From 338694c827320467dc5bff124c25ff82603e51a6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 16 Nov 2020 23:47:21 +0100 Subject: Exclude last parenthesis in url extraction if unbalanced, fix tests --- tests/main.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'tests') 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 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; } -- cgit v1.2.3