1 #include "../src/menu.c" 2 3 #include "greatest.h" 4 5 #include <glib.h> 6 7 TEST test_extract_urls_from_empty_string(void) 8 { 9 char *urls = extract_urls(""); 10 ASSERT_EQ_FMT(NULL, (void*)urls, "%p"); 11 12 urls = extract_urls(NULL); 13 ASSERT(!urls); 14 PASS(); 15 } 16 17 TEST test_extract_urls_from_no_urls_string(void) 18 { 19 char *urls = extract_urls("You got a new message from your friend"); 20 ASSERT(!urls); 21 PASS(); 22 } 23 24 TEST test_extract_urls_from_one_url_string(void) 25 { 26 char *urls = extract_urls("Hi from https://www.example.com!"); 27 ASSERT_STR_EQ("https://www.example.com", urls); 28 g_free(urls); 29 PASS(); 30 } 31 32 TEST test_extract_urls_from_two_url_string(void) 33 { 34 char *urls = extract_urls("Hi from https://www.example.com and ftp://www.example.com!"); 35 ASSERT_STR_EQ("https://www.example.com\nftp://www.example.com", urls); 36 g_free(urls); 37 PASS(); 38 } 39 40 TEST test_extract_urls_from_one_url_port(void) 41 { 42 char *urls = extract_urls("Hi from https://www.example.com:8100 and have a nice day!"); 43 ASSERT_STR_EQ("https://www.example.com:8100", urls); 44 g_free(urls); 45 PASS(); 46 } 47 48 TEST test_extract_urls_from_one_url_path(void) 49 { 50 char *urls = extract_urls("Hi from https://www.example.com:8100/testpath and have a nice day!"); 51 ASSERT_STR_EQ("https://www.example.com:8100/testpath", urls); 52 g_free(urls); 53 PASS(); 54 } 55 56 TEST test_extract_urls_from_one_url_anchor(void) 57 { 58 char *urls = extract_urls("Hi from https://www.example.com:8100/testpath#anchor and have a nice day!"); 59 ASSERT_STR_EQ("https://www.example.com:8100/testpath#anchor", urls); 60 g_free(urls); 61 PASS(); 62 } 63 64 SUITE(suite_menu) _dorand48(unsigned short xseed[3])65{ 66 RUN_TEST(test_extract_urls_from_empty_string); 67 RUN_TEST(test_extract_urls_from_no_urls_string); 68 RUN_TEST(test_extract_urls_from_one_url_string); 69 RUN_TEST(test_extract_urls_from_two_url_string); 70 RUN_TEST(test_extract_urls_from_one_url_port); 71 RUN_TEST(test_extract_urls_from_one_url_path); 72 RUN_TEST(test_extract_urls_from_one_url_anchor); 73 } 74 /* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ 75