From bcd246076540a8353fa55fc0a5e19343c1a2dbc9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 14 Aug 2015 13:03:08 +0200 Subject: Implement package search service mockup --- tests/web/xhtml/driver.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/web/xhtml/driver.cxx') diff --git a/tests/web/xhtml/driver.cxx b/tests/web/xhtml/driver.cxx index 23531f7..9f393fd 100644 --- a/tests/web/xhtml/driver.cxx +++ b/tests/web/xhtml/driver.cxx @@ -3,6 +3,7 @@ // license : MIT; see accompanying LICENSE file #include +#include #include @@ -11,11 +12,38 @@ using namespace std; using namespace xml; +static bool +bad_sequence (const function& f) +{ + ostringstream o; + serializer s (o, "osstream"); + + try + { + f (s); + return false; + } + catch (const serialization&) + { + return true; + } +} + int main () { using namespace web::xhtml; + assert (bad_sequence ([](serializer& s) {s << HTML << ~HEAD;})); + assert (bad_sequence ([](serializer& s) {s << HTML << DIV << ~P << ~HTML;})); + assert (bad_sequence ([](serializer& s) {s << HTML << DIV << ~A << ~HTML;})); + assert (bad_sequence ([](serializer& s) {s << P << A << "a" << ~P << ~P;})); + assert (bad_sequence ([](serializer& s) {s << P << A << "a" << ~I << ~P;})); + + assert ( + bad_sequence ( + [](serializer& s) {s << P << A << ID << "A" << ~HREF << ~A << ~P;})); + serializer s (cout, "output"); s << HTML -- cgit v1.1