test_bxml.c 1.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/**
* This is a test for bxml in $package$
*/
#include "si_test.h"
#include "bxml.h"


TEST_FUNC(bxml) {
  Bxml * xml, * c1, * c2, * c3, * t1, * t2, * t3;
  xml = bxml_new(BXML_ROOT);
  TEST_NOTNULL(xml);
  TEST_NOTNULL(bxml_new_attribute(xml, "hello" , "world"));
  TEST_NOTNULL(bxml_new_attribute(xml, "hello2", "world2"));
  TEST_NOTNULL(bxml_new_attribute(xml, "hello3", "world3"));
  
  
  TEST_STREQ("world2", bxml_get_attribute(xml, "hello2"));
  TEST_STREQ("world", bxml_get_attribute(xml, "hello"));
  TEST_STREQ("world3", bxml_get_attribute(xml, "hello3"));
  TEST_NULL(bxml_get_attribute(xml, "hello22"));
  
  c1 = bxml_new_child(xml, BXML_TAG , "map");
  c2 = bxml_new_child(xml, BXML_TEXT, "this is my text");
  c3 = bxml_new_child(c1, BXML_TAG, "level");
  
  t1 = bxml_get_sibling_at(xml, 0);
  TEST_NULL(bxml_get_sibling_at(xml, 1));
  
  TEST_NOTNULL(t1);
  TEST_PTREQ(xml, t1);
  
  t1 = bxml_get_child_at(xml, 0);
  t2 = bxml_get_child_at(xml, 1);
    
  TEST_PTREQ(c1, t1);
  TEST_PTREQ(c2, t2);
  

  bxml_free(xml);
  TEST_DONE();
}


TEST_FUNC(bxml_parse) {
  Bxml * xml;  
46
  xml = bxmlparser_parse_filename("data/map/map_0001.tmx");
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
  TEST_NOTNULL(xml);
  bxml_free(xml);
  TEST_DONE();
}


int main(void) {
  TEST_INIT();
  TEST_RUN(bxml);
  TEST_RUN(bxml_parse);
  TEST_REPORT();
}