mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Add tests/t1001-rcxml-nodenames-simple.c
This commit is contained in:
		
							parent
							
								
									1f5d8c3812
								
							
						
					
					
						commit
						31ba3b958d
					
				
					 3 changed files with 59 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -52,8 +52,10 @@ static void entry(xmlNode *node, char *nodename, char *content)
 | 
			
		|||
		if (is_attribute)
 | 
			
		||||
			buf_add(nodename_buffer, "@");
 | 
			
		||||
		buf_add(nodename_buffer, nodename);
 | 
			
		||||
		if (content) {
 | 
			
		||||
			buf_add(nodename_buffer, ": ");
 | 
			
		||||
			buf_add(nodename_buffer, content);
 | 
			
		||||
		}
 | 
			
		||||
		buf_add(nodename_buffer, "\n");
 | 
			
		||||
	}
 | 
			
		||||
	if (!content)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,3 +13,11 @@ t1000 = executable(
 | 
			
		|||
  link_with: rcxml_lib,
 | 
			
		||||
)
 | 
			
		||||
test('t1000', t1000)
 | 
			
		||||
 | 
			
		||||
t1001 = executable(
 | 
			
		||||
  't1001-rcxml-nodenames-simple',
 | 
			
		||||
  sources: ['t1001-rcxml-nodenames-simple.c', 'tap.c'],
 | 
			
		||||
  include_directories: [labwc_inc],
 | 
			
		||||
  link_with: rcxml_lib,
 | 
			
		||||
)
 | 
			
		||||
test('t1001', t1001)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										47
									
								
								tests/t1001-rcxml-nodenames-simple.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								tests/t1001-rcxml-nodenames-simple.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,47 @@
 | 
			
		|||
#define _POSIX_C_SOURCE 200809L
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "rcxml.h"
 | 
			
		||||
#include "tap.h"
 | 
			
		||||
 | 
			
		||||
struct rcxml rc = { 0 };
 | 
			
		||||
 | 
			
		||||
static char src[] =
 | 
			
		||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 | 
			
		||||
"<openbox_config>\n"
 | 
			
		||||
"<lab>\n"
 | 
			
		||||
"  <csd>yes</csd>\n"
 | 
			
		||||
"</lab>\n"
 | 
			
		||||
"</openbox_config>\n";
 | 
			
		||||
 | 
			
		||||
static char expect[] =
 | 
			
		||||
"openbox_config\n"
 | 
			
		||||
"lab\n"
 | 
			
		||||
"csd.lab\n"
 | 
			
		||||
"csd.lab: yes\n";
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	struct buf actual, source;
 | 
			
		||||
 | 
			
		||||
	buf_init(&actual);
 | 
			
		||||
	buf_init(&source);
 | 
			
		||||
	buf_add(&source, src);
 | 
			
		||||
 | 
			
		||||
	plan(1);
 | 
			
		||||
	diag("Parse simple rc.xml and read nodenames");
 | 
			
		||||
 | 
			
		||||
	rcxml_init(&rc);
 | 
			
		||||
	rcxml_get_nodenames(&actual);
 | 
			
		||||
	rcxml_parse_xml(&source);
 | 
			
		||||
	printf("%s\n", actual.buf);
 | 
			
		||||
	printf("%s\n", expect);
 | 
			
		||||
 | 
			
		||||
	ok1(!strcmp(expect, actual.buf));
 | 
			
		||||
	free(actual.buf);
 | 
			
		||||
	return exit_status();
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue