text:
#include <sbml/common/common.h>
#include <sbml/common/extern.h>

#include <sbml/SBase.h>
#include <sbml/Model.h>
#include <sbml/SBMLDocument.h>
#include <sbml/SBMLWriter.h>
#include <sbml/annotation/CVTerm.h>
#include <sbml/annotation/ModelHistory.h>
#include <sbml/annotation/ModelCreator.h>
#include <sbml/annotation/Date.h>

#include <check.h>

LIBSBML_CPP_NAMESPACE_USE

/*
 * We create a lot of strings in this file, for testing, and we don't
 * do what this warning tries to help with, so we shut it up just
 * for this file.
 */
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wwrite-strings"
#endif

BEGIN_C_DECLS

static SBase *S;

void
SBaseTest_setup (void)
{
  S = new(std::nothrow) Model(2, 4);

  if (S == NULL)
  {
    fail("'new(std::nothrow) SBase;' returned a NULL pointer.");
  }

}

void
SBaseTest_teardown (void)
{
  delete S;
}

START_TEST (test_SBase_setMetaId)
{
  const char *metaid = "x12345";

  SBase_setMetaId(S, metaid);

  fail_unless( !strcmp(SBase_getMetaId(S), metaid), NULL );
  fail_unless( SBase_isSetMetaId(S)      , NULL );

  if (SBase_getMetaId(S) == metaid)
  {
    fail("SBase_setMetaId(...) did not make a copy of string.");
  }

  /* Reflexive case (pathological) */
  SBase_setMetaId(S, SBase_getMetaId(S));
  fail_unless( !strcmp(SBase_getMetaId(S), metaid), NULL );

  SBase_setMetaId(S, NULL);
  fail_unless( !SBase_isSetMetaId(S), NULL );

  if (SBase_getMetaId(S) != NULL)
  {
    fail("SBase_setMetaId(S, NULL) did not clear string.");
  }
}
END_TEST

START_TEST (test_SBase_setNotes)
{
  SBase_t *c = new(std::nothrow) Model(1, 2);
  XMLToken_t *token;
  XMLNode_t *node;

  token = XMLToken_createWithText("This is a test note");
  node = XMLNode_createFromToken(token);

  SBase_setNotes(c, node);

  fail_unless(SBase_isSetNotes(c) == 1);

  if (SBase_getNotes(c) == node)
  {
    fail("SBase_setNotes(...) did not make a copy of node.");
  }
  XMLNode_t *t1 = SBase_getNotes(c);

  fail_unless(XMLNode_getNumChildren(t1) == 1);
  fail_unless(!strcmp(XMLNode_getCharacters(XMLNode_getChild(t1,0)), "This is a test note"));

  /* Reflexive case (pathological)  */
  SBase_setNotes(c, SBase_getNotes(c));
  t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);
  const char * chars = XMLNode_getCharacters(XMLNode_getChild(t1,0));
  fail_unless(!strcmp(chars, "This is a test note"));

  SBase_setNotes(c, NULL);
  fail_unless(SBase_isSetNotes(c) == 0 );

  if (SBase_getNotes(c) != NULL)
  {
    fail("SBase_setNotes(c, NULL) did not clear string.");
  }

  SBase_setNotes(c, node);

  fail_unless(SBase_isSetNotes(c) == 1);

  /* test notes with character reference */

  token = XMLToken_createWithText("(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8");
  node  = XMLNode_createFromToken(token);

  SBase_setNotes(c, node);
  t1 = SBase_getNotes(c);

  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const char * s = XMLNode_toXMLString(XMLNode_getChild(t1,0));
  const char * expected = "(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8";

  fail_unless(!strcmp(s,expected));

  /* test notes with predefined entity */

  token = XMLToken_createWithText("& ' > < \" & ' > < "");
  node  = XMLNode_createFromToken(token);

  SBase_setNotes(c, node);
  t1 = SBase_getNotes(c);

  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const char * s2 = XMLNode_toXMLString(XMLNode_getChild(t1,0));
  const char * expected2 = "& ' > < " & ' > < "";

  fail_unless(!strcmp(s2,expected2));

  XMLToken_free(token);
  XMLNode_free(node);
}
END_TEST

START_TEST (test_SBase_setAnnotation)
{
  XMLToken_t *token;
  XMLNode_t *node;

  token = XMLToken_createWithText("This is a test note");
  node = XMLNode_createFromToken(token);

  SBase_setAnnotation(S, node);

  fail_unless(SBase_isSetAnnotation(S) == 1);

  XMLNode_t *t1 = SBase_getAnnotation(S);

  fail_unless(XMLNode_getNumChildren(t1) == 1);
  fail_unless(!strcmp(XMLNode_getCharacters(XMLNode_getChild(t1,0)), "This is a test note"));

  if (SBase_getAnnotation(S) == node)
  {
    fail("SBase_setAnnotation(...) did not make a copy of node.");
  }

  /* Reflexive case (pathological) */
  SBase_setAnnotation(S, SBase_getAnnotation(S));
  fail_unless(!strcmp(XMLNode_getCharacters(XMLNode_getChild(SBase_getAnnotation(S),0)), "This is a test note"));

  SBase_setAnnotation(S, NULL);
  fail_unless(SBase_isSetAnnotation(S) == 0 );

  if (SBase_getAnnotation(S) != NULL)
  {
    fail("SBase_setAnnotation(S, NULL) did not clear string.");
  }

  SBase_setAnnotation(S, node);

  fail_unless(SBase_isSetAnnotation(S) == 1);

  SBase_unsetAnnotation(S);

  fail_unless(SBase_isSetAnnotation(S) == 0);

  /* test annotations with character reference */

  token = XMLToken_createWithText("(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8");
  node  = XMLNode_createFromToken(token);

  SBase_setAnnotation(S, node);
  t1 = SBase_getAnnotation(S);

  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const char * s = XMLNode_toXMLString(XMLNode_getChild(t1,0));
  const char * expected = "(CR) ¨ ¨ ¨ (NOT CR) &#; &#x; &#00a8; &#0168 &#x00a8";

  fail_unless(!strcmp(s,expected));

  /* test notes with predefined entity */

  token = XMLToken_createWithText("& ' > < \" & ' > < "");
  node  = XMLNode_createFromToken(token);

  SBase_setAnnotation(S, node);
  t1 = SBase_getAnnotation(S);

  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const char * s2 = XMLNode_toXMLString(XMLNode_getChild(t1,0));
  const char * expected2 = "& ' > < " & ' > < "";

  fail_unless(!strcmp(s2,expected2));

  XMLToken_free(token);
  XMLNode_free(node);

}
END_TEST

START_TEST (test_SBase_unsetAnnotationWithCVTerms)
{
  CVTerm_t   *cv;

  const char *annt =
        "<annotation>\n"
        "  <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n"
        "</annotation>";

  const char *annt_with_cvterm =
        "<annotation>\n"
        "  <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n"
        "  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "
				"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
        "xmlns:dcterms=\"http://purl.org/dc/terms/\" "
				"xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" "
        "xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" "
				"xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
        "    <rdf:Description rdf:about=\"#_000001\">\n"
        "      <bqbiol:is>\n"
        "        <rdf:Bag>\n"
        "          <rdf:li rdf:resource=\"http://www.geneontology.org/#GO:0005895\"/>\n"
        "        </rdf:Bag>\n"
        "      </bqbiol:is>\n"
        "    </rdf:Description>\n"
        "  </rdf:RDF>\n"
        "</annotation>";

  SBase_setAnnotationString(S, (char*)annt);
  fail_unless(SBase_isSetAnnotation(S) == 1);
  fail_unless(!strcmp(SBase_getAnnotationString(S), annt));

  SBase_unsetAnnotation(S);
  fail_unless(SBase_isSetAnnotation(S) == 0);
  fail_unless(SBase_getAnnotation(S) == NULL);

  SBase_setAnnotationString(S, (char*)annt);
  SBase_setMetaId(S, "_000001");
  cv = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv, BQB_IS);
  CVTerm_addResource(cv, "http://www.geneontology.org/#GO:0005895");
  SBase_addCVTerm(S, cv);

  fail_unless(SBase_isSetAnnotation(S) == 1);
  fail_unless(!strcmp(SBase_getAnnotationString(S), annt_with_cvterm));

  SBase_unsetAnnotation(S);
  fail_unless(SBase_isSetAnnotation(S) == 0);
  fail_unless(SBase_getAnnotation(S) == NULL);

  CVTerm_free(cv);
}
END_TEST

START_TEST (test_SBase_unsetAnnotationWithModelHistory)
{
  ModelHistory_t *h = ModelHistory_create();
  ModelCreator_t *c = ModelCreator_create();
  Date_t *dc;
  Date_t *dm;

  const char *annt =
        "<annotation>\n"
        "  <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n"
        "</annotation>";

  const char *annt_with_modelhistory =
       "<annotation>\n"
       "  <test:test xmlns:test=\"http://test.org/test\">this is a test node</test:test>\n"
       "  <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "
			 "xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "
			 "xmlns:dcterms=\"http://purl.org/dc/terms/\" "
			 "xmlns:vCard=\"http://www.w3.org/2001/vcard-rdf/3.0#\" "
			 "xmlns:bqbiol=\"http://biomodels.net/biology-qualifiers/\" "
			 "xmlns:bqmodel=\"http://biomodels.net/model-qualifiers/\">\n"
       "    <rdf:Description rdf:about=\"#_000001\">\n"
       "      <dc:creator>\n"
       "        <rdf:Bag>\n"
       "          <rdf:li rdf:parseType=\"Resource\">\n"
       "            <vCard:N rdf:parseType=\"Resource\">\n"
       "              <vCard:Family>Keating</vCard:Family>\n"
       "              <vCard:Given>Sarah</vCard:Given>\n"
       "            </vCard:N>\n"
       "            <vCard:EMAIL>sbml-team@caltech.edu</vCard:EMAIL>\n"
       "          </rdf:li>\n"
       "        </rdf:Bag>\n"
       "      </dc:creator>\n"
       "      <dcterms:created rdf:parseType=\"Resource\">\n"
       "        <dcterms:W3CDTF>2005-12-29T12:15:45+02:00</dcterms:W3CDTF>\n"
       "      </dcterms:created>\n"
       "      <dcterms:modified rdf:parseType=\"Resource\">\n"
       "        <dcterms:W3CDTF>2005-12-30T12:15:45+02:00</dcterms:W3CDTF>\n"
       "      </dcterms:modified>\n"
       "    </rdf:Description>\n"
       "  </rdf:RDF>\n"
       "</annotation>";

  SBase_setAnnotationString(S, (char*)annt);
  fail_unless(SBase_isSetAnnotation(S) == 1);
  fail_unless(!strcmp(SBase_getAnnotationString(S), annt));

  SBase_unsetAnnotation(S);
  fail_unless(SBase_isSetAnnotation(S) == 0);
  fail_unless(SBase_getAnnotation(S) == NULL);

  SBase_setAnnotationString(S, (char*)annt);
  SBase_setMetaId(S, "_000001");

  ModelCreator_setFamilyName(c, (char *) "Keating");
  ModelCreator_setGivenName(c, (char *) "Sarah");
  ModelCreator_setEmail(c, (char *) "sbml-team@caltech.edu");

  ModelHistory_addCreator(h, c);
  dc =  Date_createFromValues(2005, 12, 29, 12, 15, 45, 1, 2, 0);
  ModelHistory_setCreatedDate(h, dc);
  dm =  Date_createFromValues(2005, 12, 30, 12, 15, 45, 1, 2, 0);
  ModelHistory_setModifiedDate(h, dm);
  Model_setModelHistory((Model_t*)S, h);

  fail_unless(SBase_isSetAnnotation(S) == 1);
  fail_unless(!strcmp(SBase_getAnnotationString(S), annt_with_modelhistory));

  SBase_unsetAnnotation(S);
  fail_unless(SBase_isSetAnnotation(S) == 0);
  fail_unless(SBase_getAnnotation(S) == NULL);

  ModelCreator_free(c);
  ModelHistory_free(h);
}
END_TEST

START_TEST (test_SBase_setNotesString)
{
  SBase_t *c = new(std::nothrow) Model(1,2);
  char * notes = "This is a test note";
  char * taggednotes = "<notes>This is a test note</notes>";

  SBase_setNotesString(c, notes);

  fail_unless(SBase_isSetNotes(c) == 1);

  if (strcmp(SBase_getNotesString(c), taggednotes))
  {
    fail("SBase_setNotesString(...) did not make a copy of node.");
  }
  XMLNode_t *t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const XMLNode_t *t2 = XMLNode_getChild(t1,0);
  fail_unless(!strcmp(XMLNode_getCharacters(t2), "This is a test note"));

  /* Reflexive case (pathological)  */
  SBase_setNotesString(c, SBase_getNotesString(c));
  t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);
  const char * chars = SBase_getNotesString(c);
  fail_unless(!strcmp(chars, taggednotes));

  SBase_setNotesString(c, (char *)"");
  fail_unless(SBase_isSetNotes(c) == 0 );

  if (SBase_getNotesString(c) != NULL)
  {
    fail("SBase_getNotesString(c, "") did not clear string.");
  }

  SBase_setNotesString(c, taggednotes);

  fail_unless(SBase_isSetNotes(c) == 1);

  if (strcmp(SBase_getNotesString(c), taggednotes))
  {
    fail("SBase_setNotesString(...) did not make a copy of node.");
  }
  t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  t2 = XMLNode_getChild(t1,0);
  fail_unless(!strcmp(XMLNode_getCharacters(t2), "This is a test note"));

}
END_TEST

START_TEST (test_SBase_setNotesString_l3)
{
  SBase_t *c = new(std::nothrow) Model(3, 1);
  char * notes = "This is a test note";
  char * taggednotes = "<notes>\n
This is a test note
\n</notes>";

  // this should not set the notes since they are invalid xhtml
  SBase_setNotesString(c, notes);

  fail_unless(SBase_isSetNotes(c) == 0);

}
END_TEST

START_TEST (test_SBase_setNotesString_l3_addMarkup)
{
  SBase_t *c = new(std::nothrow) Model(3, 1);
  char * notes = "This is a test note";
  char * taggednotes = "<notes>\n
This is a test note
\n</notes>";

  SBase_setNotesStringAddMarkup(c, notes);

  fail_unless(SBase_isSetNotes(c) == 1);

  if (strcmp(SBase_getNotesString(c), taggednotes))
  {
    fail("SBase_setNotesString(...) did not make a copy of node.");
  }
  XMLNode_t *t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const XMLNode_t *t2 = XMLNode_getChild(t1,0);
  fail_unless(XMLNode_getNumChildren(t2) == 1);

  const XMLNode_t *t3 = XMLNode_getChild(t2,0);
  fail_unless(!strcmp(XMLNode_getCharacters(t3), "This is a test note"));

  SBase_setNotesStringAddMarkup(c, taggednotes);

  fail_unless(SBase_isSetNotes(c) == 1);

  if (strcmp(SBase_getNotesString(c), taggednotes))
  {
    fail("SBase_setNotesString(...) did not make a copy of node.");
  }
  t1 = SBase_getNotes(c);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  t2 = XMLNode_getChild(t1,0);
  fail_unless(XMLNode_getNumChildren(t2) == 1);

  t3 = XMLNode_getChild(t2,0);
  fail_unless(!strcmp(XMLNode_getCharacters(t3), "This is a test note"));

}
END_TEST

START_TEST (test_SBase_setAnnotationString)
{
  char * annotation = "This is a test note";
  char * taggedannotation = "<annotation>This is a test note</annotation>";

  SBase_setAnnotationString(S, annotation);

  fail_unless(SBase_isSetAnnotation(S) == 1);

  if (strcmp(SBase_getAnnotationString(S), taggedannotation))
  {
    fail("SBase_setAnnotationString(...) did not make a copy of node.");
  }
  XMLNode_t *t1 = SBase_getAnnotation(S);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  fail_unless(!strcmp(XMLNode_getCharacters(XMLNode_getChild(t1,0)), "This is a test note"));

  /* Reflexive case (pathological)  */
  SBase_setAnnotationString(S, SBase_getAnnotationString(S));
  t1 = SBase_getAnnotation(S);
  fail_unless(XMLNode_getNumChildren(t1) == 1);
  const char * chars = SBase_getAnnotationString(S);
  fail_unless(!strcmp(chars, taggedannotation));

  SBase_setAnnotationString(S, "");
  fail_unless(SBase_isSetAnnotation(S) == 0 );

  if (SBase_getAnnotationString(S) != NULL)
  {
    fail("SBase_getAnnotationString(S, "") did not clear string.");
  }

  SBase_setAnnotationString(S, taggedannotation);

  fail_unless(SBase_isSetAnnotation(S) == 1);

  if (strcmp(SBase_getAnnotationString(S), taggedannotation))
  {
    fail("SBase_setAnnotationString(...) did not make a copy of node.");
  }
  t1 = SBase_getAnnotation(S);
  fail_unless(XMLNode_getNumChildren(t1) == 1);

  const XMLNode_t *t2 = XMLNode_getChild(t1,0);
  fail_unless(!strcmp(XMLNode_getCharacters(t2), "This is a test note"));
}
END_TEST

START_TEST (test_SBase_appendNotes)
{ // add a p tag to a p tag
  XMLToken_t *token;
  XMLNode_t *node;
  XMLToken_t *token1;
  XMLNode_t *node1;
  XMLNode_t * node2;
  XMLTriple_t *triple = XMLTriple_createWith("p", "", "");
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLToken_t *token4 = XMLToken_createWithText("This is my text");
  XMLNode_t *node4 = XMLNode_createFromToken(token4);
  XMLToken_t *token5 = XMLToken_createWithText("This is additional text");
  XMLNode_t *node5 = XMLNode_createFromToken(token5);

  token = XMLToken_createWithTripleAttrNS(triple, att, ns);
  node = XMLNode_createFromToken(token);
  XMLNode_addChild(node, node4);

  SBase_setNotes(S, node);

  fail_unless(SBase_isSetNotes(S) == 1);

  token1 = XMLToken_createWithTripleAttrNS(triple, att, ns);
  node1 = XMLNode_createFromToken(token1);
  XMLNode_addChild(node1, node5);

  SBase_appendNotes(S, node1);

  fail_unless(SBase_isSetNotes(S) == 1);

  node2 = SBase_getNotes(S);

  fail_unless(XMLNode_getNumChildren(node2) == 2);
  fail_unless(!strcmp(XMLNode_getName(XMLNode_getChild(node2, 0)), "p"));
  fail_unless(XMLNode_getNumChildren(XMLNode_getChild(node2, 0)) == 1);
  fail_unless(!strcmp(XMLNode_getName(XMLNode_getChild(node2, 1)), "p"));
  fail_unless(XMLNode_getNumChildren(XMLNode_getChild(node2, 1)) == 1);

  const char * chars1 = XMLNode_getCharacters(XMLNode_getChild(
    XMLNode_getChild(node2, 0), 0));
  const char * chars2 = XMLNode_getCharacters(XMLNode_getChild(
    XMLNode_getChild(node2, 1), 0));

  fail_unless(!strcmp(chars1, "This is my text"));
  fail_unless(!strcmp(chars2, "This is additional text"));

  XMLNode_free(node);
  XMLNode_free(node1);
}
END_TEST

START_TEST (test_SBase_appendNotes1)
{
  // add a html tag to an html tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *html_triple = XMLTriple_createWith("html", "", "");
  XMLTriple_t *head_triple = XMLTriple_createWith("head", "", "");
  XMLTriple_t *title_triple = XMLTriple_createWith("title", "", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *html_token = XMLToken_createWithTripleAttrNS(html_triple, att, ns);
  XMLToken_t *head_token = XMLToken_createWithTripleAttr(head_triple, att);
  XMLToken_t *title_token = XMLToken_createWithTripleAttr(title_triple, att);
  XMLToken_t *body_token = XMLToken_createWithTripleAttr(body_triple, att);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *html_node = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *html_node1 = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node1 = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node1 = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);
  XMLNode_addChild(head_node, title_node);
  XMLNode_addChild(html_node, head_node);
  XMLNode_addChild(html_node, body_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);
  XMLNode_addChild(head_node1, title_node1);
  XMLNode_addChild(html_node1, head_node1);
  XMLNode_addChild(html_node1, body_node1);

  SBase_setNotes(S, html_node);
  SBase_appendNotes(S, html_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "html"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(html_triple);
  XMLTriple_free(head_triple);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(html_token);
  XMLToken_free(head_token);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLNode_free(html_node);
  XMLNode_free(head_node);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(html_node1);
  XMLNode_free(head_node1);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes2)
{// add a body tag to an html tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *html_triple = XMLTriple_createWith("html", "", "");
  XMLTriple_t *head_triple = XMLTriple_createWith("head", "", "");
  XMLTriple_t *title_triple = XMLTriple_createWith("title", "", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *html_token = XMLToken_createWithTripleAttrNS(html_triple, att, ns);
  XMLToken_t *head_token = XMLToken_createWithTripleAttr(head_triple, att);
  XMLToken_t *title_token = XMLToken_createWithTripleAttr(title_triple, att);
  XMLToken_t *body_token = XMLToken_createWithTripleAttr(body_triple, att);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *html_node = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *body_token1 = XMLToken_createWithTripleAttrNS(body_triple, att, ns);
  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token1);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);
  XMLNode_addChild(head_node, title_node);
  XMLNode_addChild(html_node, head_node);
  XMLNode_addChild(html_node, body_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);

  SBase_setNotes(S, html_node);
  SBase_appendNotes(S, body_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "html"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(html_triple);
  XMLTriple_free(head_triple);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(html_token);
  XMLToken_free(head_token);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLToken_free(body_token1);
  XMLNode_free(html_node);
  XMLNode_free(head_node);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes3)
{
  // add a p tag to an html tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *html_triple = XMLTriple_createWith("html", "", "");
  XMLTriple_t *head_triple = XMLTriple_createWith("head", "", "");
  XMLTriple_t *title_triple = XMLTriple_createWith("title", "", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *html_token = XMLToken_createWithTripleAttrNS(html_triple, att, ns);
  XMLToken_t *head_token = XMLToken_createWithTripleAttr(head_triple, att);
  XMLToken_t *title_token = XMLToken_createWithTripleAttr(title_triple, att);
  XMLToken_t *body_token = XMLToken_createWithTripleAttr(body_triple, att);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *html_node = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *p_token1 = XMLToken_createWithTripleAttrNS(p_triple, att, ns);
  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token1);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);
  XMLNode_addChild(head_node, title_node);
  XMLNode_addChild(html_node, head_node);
  XMLNode_addChild(html_node, body_node);

  XMLNode_addChild(p_node1, text_node1);

  SBase_setNotes(S, html_node);
  SBase_appendNotes(S, p_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "html"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(html_triple);
  XMLTriple_free(head_triple);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(html_token);
  XMLToken_free(head_token);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLToken_free(p_token1);
  XMLNode_free(html_node);
  XMLNode_free(head_node);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes4)
{
  // add a html tag to a body tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *html_triple = XMLTriple_createWith("html", "", "");
  XMLTriple_t *head_triple = XMLTriple_createWith("head", "", "");
  XMLTriple_t *title_triple = XMLTriple_createWith("title", "", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *html_token = XMLToken_createWithTripleAttrNS(html_triple, att, ns);
  XMLToken_t *head_token = XMLToken_createWithTripleAttr(head_triple, att);
  XMLToken_t *title_token = XMLToken_createWithTripleAttr(title_triple, att);
  XMLToken_t *body_token = XMLToken_createWithTripleAttr(body_triple, att);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *body_token1 = XMLToken_createWithTripleAttrNS(body_triple, att, ns);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *body_node = XMLNode_createFromToken(body_token1);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *html_node1 = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node1 = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node1 = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);
  XMLNode_addChild(head_node1, title_node1);
  XMLNode_addChild(html_node1, head_node1);
  XMLNode_addChild(html_node1, body_node1);

  SBase_setNotes(S, body_node);
  SBase_appendNotes(S, html_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "html"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(html_triple);
  XMLTriple_free(head_triple);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLToken_free(body_token1);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(html_node1);
  XMLNode_free(head_node1);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes5)
{
  // add a html tag to a p tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *html_triple = XMLTriple_createWith("html", "", "");
  XMLTriple_t *head_triple = XMLTriple_createWith("head", "", "");
  XMLTriple_t *title_triple = XMLTriple_createWith("title", "", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *html_token = XMLToken_createWithTripleAttrNS(html_triple, att, ns);
  XMLToken_t *head_token = XMLToken_createWithTripleAttr(head_triple, att);
  XMLToken_t *title_token = XMLToken_createWithTripleAttr(title_triple, att);
  XMLToken_t *body_token = XMLToken_createWithTripleAttr(body_triple, att);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *p_token1 = XMLToken_createWithTripleAttrNS(p_triple, att, ns);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *p_node = XMLNode_createFromToken(p_token1);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *html_node1 = XMLNode_createFromToken(html_token);
  XMLNode_t *head_node1 = XMLNode_createFromToken(head_token);
  XMLNode_t *title_node1 = XMLNode_createFromToken(title_token);
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);
  XMLNode_addChild(head_node1, title_node1);
  XMLNode_addChild(html_node1, head_node1);
  XMLNode_addChild(html_node1, body_node1);

  SBase_setNotes(S, p_node);
  SBase_appendNotes(S, html_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "html"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(html_triple);
  XMLTriple_free(head_triple);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(p_token1);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(html_node1);
  XMLNode_free(head_node1);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes6)
{// add a body tag to an body tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *body_token = XMLToken_createWithTripleAttrNS(body_triple, att, ns);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *body_node = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);

  SBase_setNotes(S, body_node);
  SBase_appendNotes(S, body_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes7)
{// add a body tag to an p tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *body_token = XMLToken_createWithTripleAttrNS(body_triple, att, ns);
  XMLToken_t *p_token1 = XMLToken_createWithTripleAttrNS(p_triple, att, ns);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token1);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *body_node1 = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);

  XMLNode_addChild(p_node1, text_node1);
  XMLNode_addChild(body_node1, p_node1);

  SBase_setNotes(S, p_node);
  SBase_appendNotes(S, body_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(p_token1);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(body_node1);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotes8)
{
  // add a p tag to an body tag
  XMLAttributes_t * att = XMLAttributes_create ();
  XMLNamespaces_t *ns = XMLNamespaces_create();
  XMLNamespaces_add(ns, "http://www.w3.org/1999/xhtml", "");
  XMLTriple_t *body_triple = XMLTriple_createWith("body", "", "");
  XMLTriple_t *p_triple = XMLTriple_createWith("p", "", "");
  XMLToken_t *body_token = XMLToken_createWithTripleAttrNS(body_triple, att, ns);
  XMLToken_t *p_token = XMLToken_createWithTripleAttr(p_triple, att);
  XMLToken_t *text_token = XMLToken_createWithText("This is my text");
  XMLNode_t *body_node = XMLNode_createFromToken(body_token);
  XMLNode_t *p_node = XMLNode_createFromToken(p_token);
  XMLNode_t *text_node = XMLNode_createFromToken(text_token);

  XMLToken_t *p_token1 = XMLToken_createWithTripleAttrNS(p_triple, att, ns);
  XMLToken_t *text_token1 = XMLToken_createWithText("This is more text");
  XMLNode_t *p_node1 = XMLNode_createFromToken(p_token1);
  XMLNode_t *text_node1 = XMLNode_createFromToken(text_token1);

  XMLNode_t * notes;
  const XMLNode_t *child, *child1;

  XMLNode_addChild(p_node, text_node);
  XMLNode_addChild(body_node, p_node);

  XMLNode_addChild(p_node1, text_node1);

  SBase_setNotes(S, body_node);
  SBase_appendNotes(S, p_node1);

  notes = SBase_getNotes(S);

  fail_unless(!strcmp(XMLNode_getName(notes), "notes"));
  fail_unless(XMLNode_getNumChildren(notes) == 1);

  child = XMLNode_getChild(notes, 0);

  fail_unless(!strcmp(XMLNode_getName(child), "body"));
  fail_unless(XMLNode_getNumChildren(child) == 2);

  child1 = XMLNode_getChild(child, 0);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is my text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  child1 = XMLNode_getChild(child, 1);

  fail_unless(!strcmp(XMLNode_getName(child1), "p"));
  fail_unless(XMLNode_getNumChildren(child1) == 1);

  child1 = XMLNode_getChild(child1, 0);

  fail_unless(!strcmp(XMLNode_getCharacters(child1), "This is more text"));
  fail_unless(XMLNode_getNumChildren(child1) == 0);

  XMLAttributes_free(att);
  XMLNamespaces_free(ns);
  XMLTriple_free(body_triple);
  XMLTriple_free(p_triple);
  XMLToken_free(body_token);
  XMLToken_free(p_token);
  XMLToken_free(text_token);
  XMLToken_free(text_token1);
  XMLToken_free(p_token1);
  XMLNode_free(body_node);
  XMLNode_free(p_node);
  XMLNode_free(text_node);
  XMLNode_free(p_node1);
  XMLNode_free(text_node1);
}
END_TEST

START_TEST (test_SBase_appendNotesString)
{
  // add p to p
  char * notes = "
This is a test note
";
  char * taggednewnotes = "<notes>\n"
                       "
This is a test note
\n"
                       "
This is more test notes
\n"
                       "</notes>";
  char * taggednewnotes2 = "<notes>\n"
                       "
This is a test note
\n"
                       "
This is more test notes 1
\n"
                       "
This is more test notes 2
\n"
                       "</notes>";
  char * newnotes = "
This is more test notes
";
  char * newnotes2 = "
This is more test notes 1
"
                     "
This is more test notes 2
";
  char * newnotes3= "<notes>\n"
                    "
This is more test notes
\n"
                    "</notes>";
  char * newnotes4 = "<notes>\n"
                     "
This is more test notes 1
\n"
                     "
This is more test notes 2
\n"
                     "</notes>";

  SBase_setNotesString(S, notes);

  fail_unless(SBase_isSetNotes(S) == 1);

  //
  // add one p tag
  //
  SBase_appendNotesString(S, newnotes);

  const char * notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  //
  // add two p tags
  //
  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, newnotes2);

  const char * notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes2));

  //
  // add one p tag with notes tag
  //
  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, newnotes3);

  const char * notes3 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes3));

  //
  // add two p tags with notes tag
  //
  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, newnotes4);

  const char * notes4 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes4));
}
END_TEST

START_TEST (test_SBase_appendNotesString1)
{ // add html to html
  char * notes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is a test note
\n"
                 "  \n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is more test notes
\n"
                 "  \n"
                 "";
  char * addnotes2 =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";

  // add html tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add html tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));

}
END_TEST

START_TEST (test_SBase_appendNotesString2)
{ // add body to html
  char * notes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is a test note
\n"
                 "  \n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                    "
This is more test notes
\n"
                    "\n";
  char * addnotes2 =
                    "<notes>\n"
                    "  \n"
                    "
This is more test notes
\n"
                    "  \n"
                    "</notes>";

  // add body tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add body tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));
}
END_TEST

START_TEST (test_SBase_appendNotesString3)
{ // add p to html
  char * notes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is a test note
\n"
                 "  \n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * taggednewnotes2 =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes 1
\n"
                 "
This is more test notes 2
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * addnotes = "
This is more test notes
\n";
  char * addnotes2 = "
This is more test notes 1
\n"
                     "
This is more test notes 2
";
  char * addnotes3 = "<notes>\n"
                     "
This is more test notes
\n"
                     "</notes>";
  char * addnotes4 = "<notes>\n"
                     "
This is more test notes 1
\n"
                     "
This is more test notes 2
\n"
                     "</notes>";

  // add one p tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add two p tags

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes2));

  // add one p tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes3);

  const char *notes3 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes3));

  // add two p tags with notes tags

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes4);

  const char *notes4 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes4));
}
END_TEST

START_TEST (test_SBase_appendNotesString4)
{ // add html to body
  char * notes = "\n"
                 "
This is a test note
\n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is more test notes
\n"
                 "  \n"
                 "";
  char * addnotes2 =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";

  // add html tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add html tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));
}
END_TEST

START_TEST (test_SBase_appendNotesString5)
{ // add html to p
  char * notes = "
This is a test note
";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                 "  \n"
                 "    <title/>\n"
                 "  \n"
                 "  \n"
                 "
This is more test notes
\n"
                 "  \n"
                 "";
  char * addnotes2 =
                 "<notes>\n"
                 "  \n"
                 "    \n"
                 "      <title/>\n"
                 "    \n"
                 "    \n"
                 "
This is more test notes
\n"
                 "    \n"
                 "  \n"
                 "</notes>";

  // add html tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add html tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));

}
END_TEST

START_TEST (test_SBase_appendNotesString6)
{ // add body to body
  char * notes = "\n"
                 "
This is a test note
\n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                 "
This is more test notes
\n"
                 "";
  char * addnotes2 =
                 "<notes>\n"
                 "  \n"
                 "
This is more test notes
\n"
                 "  \n"
                 "</notes>";

  // add body tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add body tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));

}
END_TEST

START_TEST (test_SBase_appendNotesString7)
{ // add body to p
  char * notes = "
This is a test note
";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "  \n"
                 "</notes>";
  char * addnotes = "\n"
                 "
This is more test notes
\n"
                 "";
  char * addnotes2 =
                 "<notes>\n"
                 "  \n"
                 "
This is more test notes
\n"
                 "  \n"
                 "</notes>";

  // add body tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add body tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes2));

}
END_TEST

START_TEST (test_SBase_appendNotesString8)
{ // add p to body
  char * notes = "\n"
                 "
This is a test note
\n"
                 "";
  char * taggednewnotes =
                 "<notes>\n"
                 "  \n"
                 "
This is a test note
\n"
                 "
This is more test notes
\n"
                 "  \n"
                 "</notes>";
  char * taggednewnotes2 =
                 "<notes>\n"
                 "  \n"
                 "
This is a test note
\n"
                 "
This is more test notes 1
\n"
                 "
This is more test notes 2
\n"
                 "  \n"
                 "</notes>";
  char * addnotes = "
This is more test notes
";
  char * addnotes2 = "
This is more test notes 1
\n"
                     "
This is more test notes 2
";
  char * addnotes3 =
                 "<notes>\n"
                 "
This is more test notes
\n"
                 "</notes>";
  char * addnotes4 =
                 "<notes>\n"
                 "
This is more test notes 1
\n"
                 "
This is more test notes 2
\n"
                 "</notes>";

  // add one p tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes);

  const char *notes1 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes1));

  // add two p tags

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes2);

  const char *notes2 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes2));

  // add one p tag with notes tag

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes3);

  const char *notes3 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes, notes3));

  // add two p tags with notes tags

  SBase_setNotesString(S, notes);
  SBase_appendNotesString(S, addnotes4);

  const char *notes4 = SBase_getNotesString(S);

  fail_unless(SBase_isSetNotes(S) == 1);
  fail_unless(!strcmp(taggednewnotes2, notes4));

}
END_TEST

START_TEST(test_SBase_CVTerms)
{
  CVTerm_t * cv = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv, BQB_IS);
  CVTerm_addResource(cv, "foo");

  fail_unless(SBase_getNumCVTerms(S) == 0);
  fail_unless(SBase_getCVTerms(S) == NULL);

  SBase_setMetaId(S, "_id");
  SBase_addCVTerm(S, cv);
  fail_unless(SBase_getNumCVTerms(S) == 1);
  fail_unless(SBase_getCVTerms(S) != NULL);

  fail_unless(SBase_getCVTerm(S, 0) != cv);

  CVTerm_free(cv);

}
END_TEST

START_TEST(test_SBase_addCVTerms)
{
  CVTerm_t * cv = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv, BQB_ENCODES);
  CVTerm_addResource(cv, "foo");
  SBase_setMetaId(S, "sbase1");

  SBase_addCVTerm(S, cv);

  fail_unless(SBase_getNumCVTerms(S) == 1);
  fail_unless(SBase_getCVTerms(S) != NULL);

  XMLAttributes_t *res = CVTerm_getResources(SBase_getCVTerm(S, 0));
  fail_unless(!strcmp(res->getValue(0).c_str(), "foo"));

  CVTerm_t * cv1 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv1, BQB_IS);
  CVTerm_addResource(cv1, "bar");

  SBase_addCVTerm(S, cv1);

  fail_unless(SBase_getNumCVTerms(S) == 2);

  /* same qualifier so should just add to resources of existing term */
  CVTerm_t * cv2 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv2, BQB_IS);
  CVTerm_addResource(cv2, "bar1");

  SBase_addCVTerm(S, cv2);

  fail_unless(SBase_getNumCVTerms(S) == 2);

  res = CVTerm_getResources(SBase_getCVTerm(S, 1));

  fail_unless(XMLAttributes_getLength(res) == 2);
  fail_unless(!strcmp(res->getValue(0).c_str(), "bar"));
  fail_unless(!strcmp(res->getValue(1).c_str(), "bar1"));

  /* existing term shouldnt get added*/
  CVTerm_t * cv4 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv4, BQB_IS);
  CVTerm_addResource(cv4, "bar1");

  SBase_addCVTerm(S, cv4);

  fail_unless(SBase_getNumCVTerms(S) == 2);

  res = CVTerm_getResources(SBase_getCVTerm(S, 1));

  fail_unless(XMLAttributes_getLength(res) == 2);
  fail_unless(!strcmp(res->getValue(0).c_str(), "bar"));
  fail_unless(!strcmp(res->getValue(1).c_str(), "bar1"));

  /* existing term with different qualifier shouldnt get added*/
  CVTerm_t * cv5 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv5, BQB_HAS_PART);
  CVTerm_addResource(cv5, "bar1");

  SBase_addCVTerm(S, cv5);

  fail_unless(SBase_getNumCVTerms(S) == 2);

  res = CVTerm_getResources(SBase_getCVTerm(S, 1));

  fail_unless(XMLAttributes_getLength(res) == 2);
  fail_unless(!strcmp(res->getValue(0).c_str(), "bar"));
  fail_unless(!strcmp(res->getValue(1).c_str(), "bar1"));

  CVTerm_free(cv);
  CVTerm_free(cv2);
  CVTerm_free(cv1);
  CVTerm_free(cv4);

}
END_TEST

START_TEST(test_SBase_unsetCVTerms)
{
  CVTerm_t * cv = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv, BQB_ENCODES);
  CVTerm_addResource(cv, "foo");

  SBase_setMetaId(S, "sbase1");
  SBase_addCVTerm(S, cv);
  CVTerm_t * cv1 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv1, BQB_IS);
  CVTerm_addResource(cv1, "bar");

  SBase_addCVTerm(S, cv1);
  CVTerm_t * cv2 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv2, BQB_IS);
  CVTerm_addResource(cv2, "bar1");

  SBase_addCVTerm(S, cv2);
  CVTerm_t * cv4 = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv4, BQB_IS);
  CVTerm_addResource(cv4, "bar1");

  SBase_addCVTerm(S, cv4);

  fail_unless(SBase_getNumCVTerms(S) == 2);

  SBase_unsetCVTerms(S);

  fail_unless(SBase_getNumCVTerms(S) == 0);
  fail_unless(SBase_getCVTerms(S) == NULL);

  CVTerm_free(cv);
  CVTerm_free(cv2);
  CVTerm_free(cv1);
  CVTerm_free(cv4);
}
END_TEST

START_TEST(test_SBase_getQualifiersFromResources)
{
  CVTerm_t * cv = CVTerm_createWithQualifierType(BIOLOGICAL_QUALIFIER);
  CVTerm_setBiologicalQualifierType(cv, BQB_ENCODES);
  CVTerm_addResource(cv, "foo");

  SBase_setMetaId(S, "sbase1");
  SBase_addCVTerm(S, cv);

  fail_unless(SBase_getResourceBiologicalQualifier(S, "foo") == BQB_ENCODES);

  CVTerm_t * cv1 = CVTerm_createWithQualifierType(MODEL_QUALIFIER);
  CVTerm_setModelQualifierType(cv1, BQM_IS);
  CVTerm_addResource(cv1, "bar");

  SBase_addCVTerm(S, cv1);

  fail_unless(SBase_getResourceModelQualifier(S, "bar") == BQM_IS);

  CVTerm_free(cv);
  CVTerm_free(cv1);

}
END_TEST

void setOrAppendNotes(SBase* base, std::string note)
{
	if ( base->isSetNotes() )
	{
			base->appendNotes(note);
	}
	else
	{
		base->setNotes(note);
	}
}

START_TEST(test_SBase_appendNotesWithGlobalNamespace)
{

  char * notes =
		"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
		"<sbml xmlns=\"http://www.sbml.org/sbml/level2/version4\" xmlns:html=\"http://www.w3.org/1999/xhtml\" level=\"2\" version=\"4\">\n"
		"  <model id=\"test\" name=\"name\">\n"
		"    <notes>\n"
		"      DATE: 2010/12/08 13:00:00\n"
		"      VERSION: 0.99\n"
		"      TAXONOMY: 9606\n"
		"    </notes>\n"
		"  </model>\n"
		"</sbml>\n";

	SBMLDocument sbmlDoc (2, 4);
    sbmlDoc.getNamespaces()->add("http://www.w3.org/1999/xhtml", "html");
    Model *sbmlModel  = sbmlDoc.createModel();
    sbmlModel->setId("test");
    sbmlModel->setName("name");
    setOrAppendNotes(sbmlModel, "DATE: 2010/12/08 13:00:00");
    setOrAppendNotes(sbmlModel, "VERSION: 0.99");
    setOrAppendNotes(sbmlModel, "TAXONOMY: 9606");

	SBMLWriter ttt;
	std::string documentString = ttt.writeToString(&sbmlDoc);
	fail_unless(!strcmp(documentString.c_str(), notes));
}
END_TEST

START_TEST(test_SBase_hasValidLevelVersionNamespaceCombination)
{

	Species *species = new Species(3, 1);
	// should be valid from start
	fail_unless(species->hasValidLevelVersionNamespaceCombination() == true);
	delete species;

	XMLNamespaces invalidNamespaces;
	species = new Species(3, 1);
	species->setNamespaces( &invalidNamespaces );

	// libsbml actually allows an undeclared SBML namespace
	//// sbml namespace missing
    //fail_unless(species->hasValidLevelVersionNamespaceCombination() == false);

	// hasValidLevelVersionNamespaceCombination actually would allow for the two
	// namespaces defined if they had an empty prefix!

	// wrong level / version combination
	invalidNamespaces.add(SBMLNamespaces::getSBMLNamespaceURI(2, 3), "sbml23");
    species->setNamespaces( &invalidNamespaces);
	fail_unless(species->hasValidLevelVersionNamespaceCombination() == false);

	// multiple SBML namespaces
	invalidNamespaces.add(SBMLNamespaces::getSBMLNamespaceURI(3, 1), "sbml31");
	species->setNamespaces( &invalidNamespaces );
	fail_unless(species->hasValidLevelVersionNamespaceCombination() == false);

	// now all should be well
	invalidNamespaces.clear();
	invalidNamespaces.add(SBMLNamespaces::getSBMLNamespaceURI(3, 1), "sbml31");
	species->setNamespaces( &invalidNamespaces );
	fail_unless(species->hasValidLevelVersionNamespaceCombination() == true);
	delete species;
}
END_TEST

START_TEST(test_SBase_addCVTerms_num_check)
{
  // test model  qualifiers
	for (int i = (int)BQM_IS; i<(int)BQM_UNKNOWN; i++)
	{
    CVTerm *term1 = new CVTerm();
    term1->setQualifierType(MODEL_QUALIFIER);
    term1->setModelQualifierType((ModelQualifierType_t)i);
    term1->addResource("http://myresource1");

    CVTerm *term2 = new CVTerm();
    term2->setQualifierType(MODEL_QUALIFIER);
    term2->setModelQualifierType((ModelQualifierType_t)i);
    term2->addResource("http://myresource2");

    Species *species = new Species(3, 1);
    species->setMetaId("meta1");

    fail_unless (species->addCVTerm(term1, false) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 1);

    // add term 2 (should be merged with term 1)
    fail_unless (species->addCVTerm(term2, false) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 1);

    species->getCVTerm(0)->removeResource(term2->getResourceURI(0));

    // add term 2 (added as separate bag)
    fail_unless (species->addCVTerm(term2, true) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 2);

    delete term1;
    delete term2;
    delete species;

	}

  // test biol qualifiers

  for (int i = (int)BQB_IS; i<(int)BQB_UNKNOWN; i++)
	{
    CVTerm *term1 = new CVTerm();
    term1->setQualifierType(BIOLOGICAL_QUALIFIER);
    term1->setBiologicalQualifierType((BiolQualifierType_t)i);
    term1->addResource("http://myresource1");

    CVTerm *term2 = new CVTerm();
    term2->setQualifierType(BIOLOGICAL_QUALIFIER);
    term2->setBiologicalQualifierType((BiolQualifierType_t)i);
    term2->addResource("http://myresource2");

    Species *species = new Species(3, 1);
    species->setMetaId("meta1");

    fail_unless (species->addCVTerm(term1, false) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 1);

    // add term 2 (should be merged with term 1)
    fail_unless (species->addCVTerm(term2, false) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 1);

    species->getCVTerm(0)->removeResource(term2->getResourceURI(0));

    // add term 2 (added as separate bag)
    fail_unless (species->addCVTerm(term2, true) == LIBSBML_OPERATION_SUCCESS);
    fail_unless (species->getNumCVTerms() == 2);

    delete term1;
    delete term2;
    delete species;

	}

}
END_TEST

START_TEST(test_SBase_matchesSBMLNamespaces)
{
  SBMLNamespaces *sbmlns1 = new SBMLNamespaces(3,1);
  SBMLNamespaces *sbmlns2 = new SBMLNamespaces(2,4);

  Species * s = new Species(sbmlns1);
  Parameter * p = new Parameter(sbmlns1);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(p)) == true);
  fail_unless(p->matchesSBMLNamespaces((SBase *)(s)) == true);

  p = new Parameter(sbmlns2);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(p)) == false);
  fail_unless(p->matchesSBMLNamespaces((SBase *)(s)) == false);

  sbmlns1->addNamespace("http:foo", "bar");

  Compartment *c = new Compartment(sbmlns1);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(c)) == false);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(s)) == false);
  fail_unless(p->matchesSBMLNamespaces((SBase *)(c)) == false);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(p)) == false);

  s = new Species(sbmlns1);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(c)) == true);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(s)) == true);

  sbmlns2 = new SBMLNamespaces(3,1);
  c = new Compartment(sbmlns2);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(c)) == false);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(s)) == false);

  sbmlns2->addNamespace("http:foo1", "bar1");
  c = new Compartment(sbmlns2);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(c)) == false);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(s)) == false);

  sbmlns2->addNamespace("http:foo", "bar");
  sbmlns1->addNamespace("http:foo1", "bar1");
  s = new Species(sbmlns1);
  c = new Compartment(sbmlns2);

  fail_unless(s->matchesSBMLNamespaces((SBase *)(c)) == true);
  fail_unless(c->matchesSBMLNamespaces((SBase *)(s)) == true);

  delete s;
  delete p;
  delete c;
}
END_TEST

START_TEST(test_SBase_matchesRequiredSBMLNamespacesForAddition)
{
  SBMLNamespaces *sbmlns1 = new SBMLNamespaces(3,1);
  SBMLNamespaces *sbmlns2 = new SBMLNamespaces(2,4);

  Species * s = new Species(sbmlns1);
  Parameter * p = new Parameter(sbmlns1);

  fail_unless(s->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == true);
  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(s)) == true);

  p = new Parameter(sbmlns2);

  fail_unless(s->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == false);
  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(s)) == false);

  sbmlns1->addNamespace("http:foo", "bar");

  Compartment *c = new Compartment(sbmlns1);

  fail_unless(s->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == true);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(s)) == true);
  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == false);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == false);

  sbmlns1->addNamespace("http://www.sbml.org/sbml/level3/version1/qual/version1", "bar1");
  s = new Species(sbmlns1);

  fail_unless(s->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == true);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(s)) == false);

  sbmlns2 = new SBMLNamespaces(3,1);
  sbmlns2->addNamespace("http://www.sbml.org/sbml/level3/version1/qual/version1", "bar1");
  c = new Compartment(sbmlns2);

  fail_unless(s->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == true);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(s)) == true);

  sbmlns1 = new SBMLNamespaces(3,1);
  p = new Parameter(sbmlns1);

  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == false);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == true);

  sbmlns1->addNamespace("http://www.sbml.org/sbml/level3/version1/qual/version2", "bar2");
  p = new Parameter(sbmlns1);

  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == false);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == false);

  sbmlns1 = new SBMLNamespaces(3,1);
  sbmlns1->addNamespace("http://www.sbml.org/sbml/level3/version1/qual/version1", "bar1");
  sbmlns1->removeNamespace(SBMLNamespaces::getSBMLNamespaceURI(3,1));
  p = new Parameter(sbmlns1);

  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == false);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == false);

  sbmlns1 = new SBMLNamespaces(3,1);
  sbmlns1->addNamespace("http://www.sbml.org/sbml/level3/version1/qual/version1", "bar1");
  sbmlns1->addNamespace("http://www.sbml.org/sbml/level3/version1/comp/version1", "comp");
  p = new Parameter(sbmlns1);

  fail_unless(p->matchesRequiredSBMLNamespacesForAddition((SBase *)(c)) == true);
  fail_unless(c->matchesRequiredSBMLNamespacesForAddition((SBase *)(p)) == false);

  delete s;
  delete p;
  delete c;
}
END_TEST

START_TEST(test_SBase_prefixMetaIdSBO)
{
  Species species(3,1);
  species.setMetaId("meta1");
  species.setSBOTerm(245);

  std::string noPrefix = species.toSBML();
  fail_unless (noPrefix.find(" metaid=") != std::string::npos);
  fail_unless (noPrefix.find(" sboTerm=") != std::string::npos);

  species.getNamespaces()->remove("");
  species.getNamespaces()->add(SBMLNamespaces::getSBMLNamespaceURI(3, 1), "l3v1");

  std::string prefix = species.toSBML();
  fail_unless (prefix.find(" l3v1:metaid=") != std::string::npos);
  fail_unless (prefix.find(" l3v1:sboTerm=") != std::string::npos);

  fail_unless (noPrefix != prefix);

}
END_TEST

START_TEST(test_SBase_userData)
{
  Species s1(3, 1);
  int myValue = 10;
  fail_unless(s1.getUserData() == NULL);
  fail_unless(s1.setUserData(&myValue) == LIBSBML_OPERATION_SUCCESS);
  fail_unless((*(int*)s1.getUserData()) == 10);

  // make sure that cloning also clones the pointer to the data
  Species *s2 = s1.clone();
  fail_unless((*(int*)s2->getUserData()) == 10);
  delete s2;

  // for whatever reason unsetting the user data returns a failure for now
  // we should revisit whether that is what we want ... i'll add it as test case
  // for now

  fail_unless(s1.setUserData(NULL) == LIBSBML_OPERATION_FAILED);
  fail_unless(s1.getUserData() == NULL);

  // test that when accessed with NULL arguments nothing bad happens

  fail_unless(SBase_getUserData(NULL) == NULL);
  fail_unless(SBase_setUserData(NULL, NULL) == LIBSBML_INVALID_OBJECT);

}
END_TEST

Suite *
create_suite_SBase (void)
{
  Suite *suite = suite_create("SBase");
  TCase *tcase = tcase_create("SBase");

  tcase_add_checked_fixture(tcase, SBaseTest_setup, SBaseTest_teardown);

  tcase_add_test(tcase, test_SBase_setMetaId     );
 // tcase_add_test(tcase, test_SBase_setNotes      );
  tcase_add_test(tcase, test_SBase_setAnnotation );
  tcase_add_test(tcase, test_SBase_setNotes);
  tcase_add_test(tcase, test_SBase_setNotesString);
  tcase_add_test(tcase, test_SBase_setNotesString_l3);
  tcase_add_test(tcase, test_SBase_setNotesString_l3_addMarkup);
  tcase_add_test(tcase, test_SBase_setAnnotationString);
  tcase_add_test(tcase, test_SBase_unsetAnnotationWithCVTerms );
  tcase_add_test(tcase, test_SBase_unsetAnnotationWithModelHistory );

  tcase_add_test(tcase, test_SBase_appendNotes );
  tcase_add_test(tcase, test_SBase_appendNotes1 );
  tcase_add_test(tcase, test_SBase_appendNotes2 );
  tcase_add_test(tcase, test_SBase_appendNotes3 );
  tcase_add_test(tcase, test_SBase_appendNotes4 );
  tcase_add_test(tcase, test_SBase_appendNotes5 );
  tcase_add_test(tcase, test_SBase_appendNotes6 );
  tcase_add_test(tcase, test_SBase_appendNotes7 );
  tcase_add_test(tcase, test_SBase_appendNotes8 );
  tcase_add_test(tcase, test_SBase_appendNotesString );
  tcase_add_test(tcase, test_SBase_appendNotesString1);
  tcase_add_test(tcase, test_SBase_appendNotesString2);
  tcase_add_test(tcase, test_SBase_appendNotesString3);
  tcase_add_test(tcase, test_SBase_appendNotesString4);
  tcase_add_test(tcase, test_SBase_appendNotesString5);
  tcase_add_test(tcase, test_SBase_appendNotesString6);
  tcase_add_test(tcase, test_SBase_appendNotesString7);
  tcase_add_test(tcase, test_SBase_appendNotesString8);
  tcase_add_test(tcase, test_SBase_appendNotesWithGlobalNamespace );

  tcase_add_test(tcase, test_SBase_CVTerms );
  tcase_add_test(tcase, test_SBase_addCVTerms );
  tcase_add_test(tcase, test_SBase_addCVTerms_num_check );
  tcase_add_test(tcase, test_SBase_unsetCVTerms );
  tcase_add_test(tcase, test_SBase_getQualifiersFromResources );
  tcase_add_test(tcase, test_SBase_hasValidLevelVersionNamespaceCombination);
  tcase_add_test(tcase, test_SBase_matchesSBMLNamespaces);
  tcase_add_test(tcase, test_SBase_matchesRequiredSBMLNamespacesForAddition);
  tcase_add_test(tcase, test_SBase_userData);

  tcase_add_test(tcase, test_SBase_prefixMetaIdSBO);

  suite_add_tcase(suite, tcase);

  return suite;
}

END_C_DECLS

redpajama_set_name: RedPajamaGithub


text:
In Support of Atlanta's Streetcar Proposal
Yesterday, we featured a post from Yonah Freemark at The Transport Politic about Atlanta's decision to put a streetcar project in line for federal TIGER funds before another local transit proposal known as the Beltline. Yonah argued that the Beltline — a ring of recreational amenities and transit features that would circle the city — was the more innovative of the two projects. He questioned whether the city would be able to move forward with such an ambitious idea while simultaneously pouring resources into a streetcar downtown.
An artist's rendering of a streetcar in Atlanta. Image: SkyScraperPage forum
Today, we offer a counterpoint from CCTgirl at MARTA Rocks!, who thinks the streetcar project is the right choice. CCTgirl doesn't oppose the Beltway, but says the concept is simply not advanced enough to be a compelling candidate for federal funding right now:
I personally think the streetcar is a stronger project at this point.
They have guaranteed operating funds for twenty years, the federally
required minimum to qualify for funds, and it has the backing of the
city, downtown businesses, and even received a letter of endorsement
from GDOT. Further, $20 million has been designated to the project,
showing local commitment and making it a strong application. I just
don't think The Beltline was there.
The Beltline is a good project. I don't think it's the amazing savior of the city people tout it as and they make fools out of
themselves at times, like in the recent Buckhead Reporter. The Reporter
recently ran an article in which the Beltline was stated to have
transit in six or seven years, but they don't know what type yet.
Awfully optimistic…
The streetcar isn't perfect either, it's a touristy line catering to
business. It won't move a bunch of natives, but it's a good start at
showing Atlanta what transit can be. It'll clean up the area, make the
interstate underpass safe, and be a shiny new example of good transit to
a city that looks down its nose at public transportation, which, if
executed well, will help The Beltline. And they do intend to
accommodate bicyclists. It could be the best step forward in transit we
can take and lead to further advancements for Atlanta.
Thanks to both bloggers for highlighting the arguments for two important transit proposals. In the end, the biggest lingering question may be whether we'd be having this debate if federal investment in transit was more robust.
Elsewhere on the Network today, Indigo Country, White City breaks down the media reaction to the death of a cycling advocate in South Carolina; Sprawled Out looks at a new study linking sprawl to the loss of social capital; and PA Walks & Bikes celebrates the news that walking and biking projects will be spared from transportation cuts caused by the loss of federal funding in Pennsylvania.
In Support of Atlanta's Streetcar Proposal
By Angie Schmitt	| Aug 25, 2010
Yesterday, we featured a post from Yonah Freemark at The Transport Politic about Atlanta's decision to put a streetcar project in line for federal TIGER funds before another local transit proposal known as the Beltline. Yonah argued that the Beltline — a ring of recreational amenities and transit features that would circle the city — […]
In Atlanta's TIGER Bid, Innovative "Beltline" Takes Backseat to Streetcar
For years, the city of Atlanta has been developing ambitious plans to connect its radial transit lines with a circular "beltline." As envisioned, the $2.8 billion project would include 22 miles of light rail and recreational amenities, circling the central city, taking advantage of existing freight lines. For now, however, those plans are getting less […]
Atlanta's Transit Flaws Are State's Fault
By Aaron Short	| Sep 25, 2019
Atlanta is set to spend more than half a billion dollars to build a 22-mile light rail line — but the vital public infrastructure won't likely be done until 2050 because the city isn't getting state or federal funding. And that's the problem.
Cincinnati Will Complete Its Streetcar
"We're gonna have a streetcar." That was the announcement, met with cheers, from Cincinnati Mayor John Cranley this afternoon. With an active proposal in the City Council to resume construction on the streetcar, Cranley said he "would not sign the legislation because" he "thinks it's wrong." But he was flanked by Council Member Kevin Flynn, […]
Atlanta Beltline Staff: "We Still Have a Project to Build"
The Atlanta Beltline project isn't going away. Project staff want to make that clear. Sure, last week, Atlanta turned down — by a wide margin — a major transportation spending package that would have awarded $600 million to the Beltline project. But this project — an innovative transit and trails corridor that will circle Atlanta's central city — has seen […]
Will Atlanta Double Down on Its Streetcar Mistake?
By Angie Schmitt	| May 22, 2018
The streetcar is slow because it runs in mixed traffic. Atlanta's new light rail lines might also share lanes with cars.

redpajama_set_name: RedPajamaCommonCrawl


2.3 These Terms were last updated on 21/02/2018.
b) immediately notify us if you become aware of any disclosure or unauthorised use of your User ID, by sending an email to hello@kytbags.com.
4.4 You must obtain our written permission to establish a link to our Website. If you wish to do so, email your request to hello@kytbags.com.
7.2 Except to the extent permitted by law, nothing in these Terms has the effect of contracting out of the New Zealand Consumer Guarantees Act 1993 or any other consumer protection law that cannot be excluded. To the extent our liability cannot be excluded but can be limited, our liability is limited to NZD 345.
7.3 To the maximum extent permitted by law and only to the extent clauses 7.1 and 7.2 of these Terms do not apply, our total liability to you under or in connection with these Terms, or in connection with the Website, or your access and use of (or inability to access or use) the Website, must not exceed NZD 345.


If you have ever tried to tug a poorly fitting pair of size 16 jeans over your hips in a changing space before collapsing in a dejected heap on the floor, you are not alone. We take the function of the mother of the bride and how she looks really seriously right here at Style & the Bride. The mother of the bride has a pivotal job - she'll help you by way of those stressful organizing dilemmas and will be armed with tissues, hugs and plenty of help when the wedding finally arrives. She plays a enormous part and we know that she's going to want to look and really feel fabulous all day long. With this in mind, Style & the Bride has come up with some specialist mother of the bride style tips to help her find the excellent outfit for your additional unique day. If you should wear a longer dress, contemplate wearing some opaque tights that match the color of your boot. The ideal combination is black boots and black tights. This will make your legs appear longer. Decide your physique sort. Realizing what sort of physique you have will aid you make a decision what dress types will be most flattering on you even just before you attempt them on, saving you time in the shop.Prepared-To-Put on Ensembles: Have ready-to-put on ensembles hanging in your closet (yes, even the shoes and if you are actually keen, the accessories as well). They will come in handy when you either have totally nothing to put on or when you happen to be in a rush to pull an outfit with each other. It's greater to have a couple of for various occasions - a single corporate, 1 casual and a single glamourous look. You can thank us for this tip later.Gemma says: This tip isn't about getting slim - it really is about thinking about the shape about your physique that your clothes make, whatever your size. You want it to be powerful and clean, with sufficient room to breathe and sufficient material not to cling to tricky zones. A visible muffin top is the antithesis of a sturdy silhouette, so never squeeze your self into clothes that are also little. Purchase ones that give you the best outline. This dress is terrific for that and it also ties into the massive celebrity trend of optical illusion dresses.CH: All ships are supposed to be buoyant, but this one particular may truly make you buoyant, or at least it may slightly reduce that sinking feeling. It is a ship that promises to remove plastic waste from the ocean. Lots of it. Five tons each and every day. The project is the brainchild of Norwegian billionaire Kjell Roekke, in partnership with the Globe Wildife Fund, or WWF. And it really is not just his brainchild, it is also his wallet-kid: Mr. Roekke, who's made his fortune in the oil sector - is paying for the ship in complete.When to wear it: formal events that are held outdoors, such as a cruise line or nation club dinners, weddings, and galas. Trousers are also out, because I get an overspill of fat around my waistband. Rather, I favor effectively-reduce skirts and dresses with a panel at the front to flatten and smooth my stomach.Understand, initial, to pass off something that itches, is unflattering in shape or takes festivity too actually. In the finish, it all boils down to this: You're going to be on your feet all evening lengthy, air-kissing a lot of individuals you barely know and scrambling for cocktails (with out even mentioning the queue for the loos). What your outfit wants is mileage and glamour in equal measure.Any time you are wearing a jacket. No exceptions. Invest in an outfit - Picking a good quality outfit will not only give you a excellent silhouette, you'll also have an outfit that will final a lifetime. If you're brief and petite, dress buying could be a lot more challenging cocktail dresses become complete gowns and party dresses turn out to be cocktail dresses. Nonetheless, with plenty of time ahead, you can get these tailored to your size.For company dinners, workplace wear is acceptable (offered your workplace isn't overly casual): trousers with a refined sweater or a blouse and blazer. If you are going to a function celebration straight from the workplace, try a sheath or a wrap dress in a dark shade, or put on a suit and bring along a feminine blouse and evening-acceptable footwear, like in a metallic shade," suggests Leah Ingram, an etiquette authority and the founder of , primarily based in New Hope, Pennsylvania. Or you could merely swap your jewelry for one thing a small bolder―a chunky necklace instead of pearls." As for that firm picnic, choose knee-length shorts and a brief-sleeve top, or a sundress with sandals―nothing ripped, frayed, or strapless.Wear mini skirts. The mini skirt came to the forefront of style in the 80s and has never ever really left. Look for skintight skirts in supplies like denim, PVC and cotton and pair them with an more than-sized, off the shoulder t-shirt (tucked into the skirt) and some legwarmers for correct 80s style cred.Cocktail parties aren't just for cocktail dresses. Skirts are an remarkable alternative and completely versatile. Mix it up with a cocktail dresses printed blouse or develop a look that resembles a dress with a matching set. Make positive your hemline is not as well short, though. There is a fine line among classy and trashy. A very good rule of thumb? Make sure your finger suggestions can touch your hem when your arms are by your sides.