const bool testElements()

in modules/xml/xml-test.cpp [171:225]


const bool testElements() {
    {
        const list<value> ad = mklist<value>(mklist<value>("city", string("san francisco")), mklist<value>("state", string("ca")));
        const list<value> ac1 = mklist<value>(mklist<value>("id", string("1234")), mklist<value>("balance", 1000));
        const list<value> ac2 = mklist<value>(mklist<value>("id", string("6789")), mklist<value>("balance", 2000));
        const list<value> ac3 = mklist<value>(mklist<value>("id", string("4567")), mklist<value>("balance", 3000));
        {
            const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", string("jdoe")), cons<value>("address", ad), mklist<value>("account", mklist<value>(ac1, ac2, ac3))));
            const list<value> e = valuesToElements(c);
            const list<value> v = elementsToValues(e);
            assert(v == c);

            ostringstream os;
            writeElements<ostream*>(xmlWriter, &os, e);
            assert(str(os) == customerXML);
        }
        {
            const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", string("jdoe")), cons<value>("address", ad), cons<value>("account", ac1), cons<value>("account", ac2), cons<value>("account", ac3)));
            const list<value> e = valuesToElements(c);
            const list<value> v = elementsToValues(e);

            ostringstream os;
            writeElements<ostream*>(xmlWriter, &os, e);
            assert(str(os) == customerXML);
        }
    }
    {
        istringstream is(abcXML);
        const list<value> c = content(readElements(streamList(is)));
        const list<value> v = elementsToValues(c);
        const list<value> e = valuesToElements(v);
        ostringstream os;
        writeElements<ostream*>(xmlWriter, &os, e);
        assert(str(os) == abcXML);
    }
    {
        istringstream is(xyzXML);
        const list<value> c = content(readElements(streamList(is)));
        const list<value> v = elementsToValues(c);
        const list<value> e = valuesToElements(v);
        ostringstream os;
        writeElements<ostream*>(xmlWriter, &os, e);
        assert(str(os) == xyzXML);
    }
    {
        istringstream is(customerXML);
        const list<value> c = content(readElements(streamList(is)));
        const list<value> v = elementsToValues(c);
        const list<value> e = valuesToElements(v);
        ostringstream os;
        writeElements<ostream*>(xmlWriter, &os, e);
        assert(str(os) == customerXML);
    }
    return true;
}