Add tests for extract_urls
This commit is contained in:
		
							parent
							
								
									c562c6441a
								
							
						
					
					
						commit
						65bcce652c
					
				
							
								
								
									
										47
									
								
								test/menu.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								test/menu.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | ||||
| #include "../src/menu.c" | ||||
| 
 | ||||
| #include "greatest.h" | ||||
| 
 | ||||
| #include <glib.h> | ||||
| 
 | ||||
| TEST test_extract_urls_from_empty_string(void) | ||||
| { | ||||
|         char *urls = extract_urls(""); | ||||
|         ASSERT_EQ_FMT(NULL, (void*)urls, "%p"); | ||||
|         g_free(urls); | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| TEST test_extract_urls_from_no_urls_string(void) | ||||
| { | ||||
|         char *urls = extract_urls("You got a new message from your friend"); | ||||
|         ASSERT_EQ_FMT(NULL, (void*)urls, "%p"); | ||||
|         g_free(urls); | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| TEST test_extract_urls_from_one_url_string(void) | ||||
| { | ||||
|         char *urls = extract_urls("Hi from https://www.example.com!"); | ||||
|         ASSERT_STR_EQ("https://www.example.com", urls); | ||||
|         g_free(urls); | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| TEST test_extract_urls_from_two_url_string(void) | ||||
| { | ||||
|         char *urls = extract_urls("Hi from https://www.example.com and ftp://www.example.com!"); | ||||
|         ASSERT_STR_EQ("https://www.example.com\nftp://www.example.com", urls); | ||||
|         g_free(urls); | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| SUITE(suite_menu) | ||||
| { | ||||
|         RUN_TEST(test_extract_urls_from_empty_string); | ||||
|         RUN_TEST(test_extract_urls_from_no_urls_string); | ||||
|         RUN_TEST(test_extract_urls_from_one_url_string); | ||||
|         RUN_TEST(test_extract_urls_from_two_url_string); | ||||
| } | ||||
| /* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ | ||||
| @ -18,6 +18,7 @@ SUITE_EXTERN(suite_icon); | ||||
| SUITE_EXTERN(suite_queues); | ||||
| SUITE_EXTERN(suite_dunst); | ||||
| SUITE_EXTERN(suite_log); | ||||
| SUITE_EXTERN(suite_menu); | ||||
| 
 | ||||
| GREATEST_MAIN_DEFS(); | ||||
| 
 | ||||
| @ -42,6 +43,7 @@ int main(int argc, char *argv[]) { | ||||
|         RUN_SUITE(suite_queues); | ||||
|         RUN_SUITE(suite_dunst); | ||||
|         RUN_SUITE(suite_log); | ||||
|         RUN_SUITE(suite_menu); | ||||
|         GREATEST_MAIN_END(); | ||||
| 
 | ||||
|         base = NULL; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Andrew Benson
						Andrew Benson