Test notification_format_message
This commit is contained in:
		
							parent
							
								
									6988a6e04d
								
							
						
					
					
						commit
						1b4ca786cd
					
				| @ -117,6 +117,17 @@ TEST test_notification_referencing(void) | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| TEST test_notification_format_message(struct notification *n, const char *format, const char *exp) | ||||
| { | ||||
|         n->format = format; | ||||
|         notification_format_message(n); | ||||
| 
 | ||||
|         ASSERT_STR_EQ(exp, n->msg); | ||||
| 
 | ||||
|         PASS(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| SUITE(suite_notification) | ||||
| { | ||||
|         cmdline_load(0, NULL); | ||||
| @ -147,6 +158,37 @@ SUITE(suite_notification) | ||||
|         RUN_TEST(test_notification_replace_single_field); | ||||
|         RUN_TEST(test_notification_referencing); | ||||
| 
 | ||||
|         // TEST notification_format_message
 | ||||
|         a = notification_create(); | ||||
|         a->appname = g_strdup("MyApp"); | ||||
|         a->summary = g_strdup("I've got a summary!"); | ||||
|         a->body =    g_strdup("Look at my shiny <notification>"); | ||||
|         a->icon =    g_strdup("/this/is/my/icoknpath.png"); | ||||
|         a->progress = 95; | ||||
| 
 | ||||
|         const char *strings[] = { | ||||
|                 "%a", "MyApp", | ||||
|                 "%s", "I've got a summary!", | ||||
|                 "%b", "Look at my shiny <notification>", | ||||
|                 "%I", "icoknpath.png", | ||||
|                 "%i", "/this/is/my/icoknpath.png", | ||||
|                 "%p", "[ 95%]", | ||||
|                 "%n", "95", | ||||
|                 "%%", "%", | ||||
|                 "%",  "%", | ||||
|                 "%UNKNOWN", "%UNKNOWN", | ||||
|                 NULL | ||||
|         }; | ||||
| 
 | ||||
|         const char **in = strings; | ||||
|         const char **out = strings+1; | ||||
|         while (*in && *out) { | ||||
|                 RUN_TESTp(test_notification_format_message, a, *in, *out); | ||||
|                 in +=2; | ||||
|                 out+=2; | ||||
|         } | ||||
|         g_clear_pointer(&a, notification_unref); | ||||
| 
 | ||||
|         g_clear_pointer(&settings.icon_path, g_free); | ||||
|         g_free(config_path); | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine