test_bxml.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * This is a test for bxml in $package$
  3. */
  4. #include "si_test.h"
  5. #include "bxml.h"
  6. TEST_FUNC(bxml) {
  7. Bxml * xml, * c1, * c2, * c3, * t1, * t2, * t3;
  8. xml = bxml_new(BXML_ROOT);
  9. TEST_NOTNULL(xml);
  10. TEST_NOTNULL(bxml_new_attribute(xml, "hello" , "world"));
  11. TEST_NOTNULL(bxml_new_attribute(xml, "hello2", "world2"));
  12. TEST_NOTNULL(bxml_new_attribute(xml, "hello3", "world3"));
  13. TEST_STREQ("world2", bxml_get_attribute(xml, "hello2"));
  14. TEST_STREQ("world", bxml_get_attribute(xml, "hello"));
  15. TEST_STREQ("world3", bxml_get_attribute(xml, "hello3"));
  16. TEST_NULL(bxml_get_attribute(xml, "hello22"));
  17. c1 = bxml_new_child(xml, BXML_TAG , "map");
  18. c2 = bxml_new_child(xml, BXML_TEXT, "this is my text");
  19. c3 = bxml_new_child(c1, BXML_TAG, "level");
  20. t1 = bxml_get_sibling_at(xml, 0);
  21. TEST_NULL(bxml_get_sibling_at(xml, 1));
  22. TEST_NOTNULL(t1);
  23. TEST_PTREQ(xml, t1);
  24. t1 = bxml_get_child_at(xml, 0);
  25. t2 = bxml_get_child_at(xml, 1);
  26. TEST_PTREQ(c1, t1);
  27. TEST_PTREQ(c2, t2);
  28. bxml_free(xml);
  29. TEST_DONE();
  30. }
  31. TEST_FUNC(bxml_parse) {
  32. Bxml * xml;
  33. xml = bxmlparser_parse_filename("data/map/map_0001.tmx");
  34. TEST_NOTNULL(xml);
  35. bxml_free(xml);
  36. TEST_DONE();
  37. }
  38. int main(void) {
  39. TEST_INIT();
  40. TEST_RUN(bxml);
  41. TEST_RUN(bxml_parse);
  42. TEST_REPORT();
  43. }