Add mxmlSaveString tests.

web
Michael R Sweet 21 years ago
parent c754d6984e
commit 64f6f21711
  1. 2
      CHANGES
  2. 20
      Makefile.in
  3. 12
      testmxml.c

@ -9,6 +9,8 @@ CHANGES IN Mini-XML 1.1
capped at 16383, 255, and 255 bytes, respectively.
- Added a new mxmlLoadString() function for loading an
XML node tree from a string.
- Added a new mxmlSaveString() function for saving an
XML node tree to a string.
- Add emulation of strdup() if the local platform does
not provide the function.

@ -1,5 +1,5 @@
#
# "$Id: Makefile.in,v 1.10 2003/07/20 13:41:17 mike Exp $"
# "$Id: Makefile.in,v 1.11 2003/07/20 13:49:09 mike Exp $"
#
# Makefile for mini-XML, a small XML-like file parsing library.
#
@ -189,13 +189,19 @@ mxmldoc.o: mxml.h
testmxml: libmxml.a testmxml.o
$(CC) $(LDFLAGS) -o $@ testmxml.o libmxml.a
@echo Testing library...
./testmxml test.xml >temp1.xml
./testmxml temp1.xml >temp2.xml
./testmxml test.xml >temp1.xml 2>temp1s.xml
./testmxml temp1.xml >temp2.xml 2>temp2s.xml
@if cmp temp1.xml temp2.xml; then \
echo Test passed!; \
$(RM) temp1.xml temp2.xml; \
echo File test passed!; \
$(RM) temp2.xml temp2s.xml; \
else \
echo Test failed!; \
echo File test failed!; \
fi
@if cmp temp1.xml temp1s.xml; then \
echo String test passed!; \
$(RM) temp1.xml temp1s.xml; \
else \
echo String test failed!; \
fi
testmxml.o: mxml.h
@ -218,5 +224,5 @@ $(OBJS): Makefile config.h
#
# End of "$Id: Makefile.in,v 1.10 2003/07/20 13:41:17 mike Exp $".
# End of "$Id: Makefile.in,v 1.11 2003/07/20 13:49:09 mike Exp $".
#

@ -1,5 +1,5 @@
/*
* "$Id: testmxml.c,v 1.10 2003/07/20 13:41:17 mike Exp $"
* "$Id: testmxml.c,v 1.11 2003/07/20 13:49:09 mike Exp $"
*
* Test program for mini-XML, a small XML-like file parsing library.
*
@ -50,6 +50,7 @@ main(int argc, /* I - Number of command-line args */
FILE *fp; /* File to read */
mxml_node_t *tree, /* XML tree */
*node; /* Node which should be in test.xml */
char buffer[16384]; /* Save string */
static const char *types[] = /* Strings for node types */
{
"MXML_ELEMENT",
@ -287,6 +288,13 @@ main(int argc, /* I - Number of command-line args */
mxmlSaveFile(tree, stdout, whitespace_cb);
/*
* Save the XML tree to a string and print it...
*/
if (mxmlSaveString(tree, buffer, sizeof(buffer), whitespace_cb) > 0)
fputs(buffer, stderr);
/*
* Delete the tree and return...
*/
@ -384,5 +392,5 @@ whitespace_cb(mxml_node_t *node, /* I - Element node */
/*
* End of "$Id: testmxml.c,v 1.10 2003/07/20 13:41:17 mike Exp $".
* End of "$Id: testmxml.c,v 1.11 2003/07/20 13:49:09 mike Exp $".
*/

Loading…
Cancel
Save