/* Ousía Copyright (C) 2014, 2015 Benjamin Paaßen, Andreas Stöckel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include namespace ousia { namespace xml { TEST(XMLNode, testSerialize) { Manager mgr{1}; Rooted html{new Element{mgr, {nullptr}, "html"}}; Rooted head{new Element{mgr, html, "head"}}; html->addChild(head); Rooted title{new Element{mgr, head, "title"}}; head->addChild(title); title->addChild(new Text(mgr, title, "my title")); Rooted body{new Element{mgr, html, "body"}}; html->addChild(body); // This div element contains our text. Rooted div{ new Element{mgr, body, "div", {{"class", "content"}, {"id", "1"}}}}; body->addChild(div); Rooted p{new Element{mgr, div, "p"}}; div->addChild(p); p->addChild(new Text(mgr, p, "A")); div->addChild(new Text(mgr, div, "B")); Rooted myTag{new Element{mgr, div, "myTag", {}, "myNameSpace"}}; div->addChild(myTag); myTag->addChild(new Text(mgr, myTag, "C")); // Now this is what we expect to see: std::string expected{ "\n" "\n" "\t\n" "\t\tmy title\n" "\t\n" "\t\n" "\t\t

A

BC
\n" "\t\n" "\n"}; // check if it is what we see std::stringstream ss; html->serialize(ss); ASSERT_EQ(expected, ss.str()); } } }