diff options
author | defanor <defanor@uberspace.net> | 2023-09-29 20:24:16 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2023-09-29 20:24:16 +0300 |
commit | ccdb748c81abc9bb30b8989e27d22bbbb219f9a0 (patch) | |
tree | 295be2ea605c8acbe56116ea3ce119b99e3e0440 /tests/xml_parse_and_print.c | |
parent | 04e6fd5194481798bc30abc7a690664d5af36aeb (diff) |
Add more checks, tests, and documentation
Diffstat (limited to 'tests/xml_parse_and_print.c')
-rw-r--r-- | tests/xml_parse_and_print.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/xml_parse_and_print.c b/tests/xml_parse_and_print.c new file mode 100644 index 0000000..ad6bbca --- /dev/null +++ b/tests/xml_parse_and_print.c @@ -0,0 +1,27 @@ +#include <string.h> +#include <stdlib.h> +#include "rexmpp_xml.h" + +int main () { + int ret = 0; + + char *str = "<foo bar=\"baz\">" + "<qux xmlns=\"urn:test\">a b c d</qux>" + "<quux e=\"f\" g=\"h\"/>" + "</foo>"; + rexmpp_xml_t *xml = rexmpp_xml_parse (str, strlen(str)); + + if (xml == NULL) { + ret = -1; + } else { + char *str_new = rexmpp_xml_serialize (xml, 0); + if (str_new == NULL) { + ret = -2; + } else { + ret = strcmp(str, str_new); + free(str_new); + } + rexmpp_xml_free(xml); + } + return ret; +} |