aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-14 13:03:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-23 13:53:50 +0200
commitbcd246076540a8353fa55fc0a5e19343c1a2dbc9 (patch)
tree9fe2c24ca33b3d670267a5cbc8c8c756589f359b /tests
parent24903813d11813f8ff9ac906d23b21e6c33b981d (diff)
Implement package search service mockup
Diffstat (limited to 'tests')
-rw-r--r--tests/web/xhtml/driver.cxx28
1 files changed, 28 insertions, 0 deletions
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 <iostream>
+#include <functional>
#include <xml/serializer>
@@ -11,11 +12,38 @@
using namespace std;
using namespace xml;
+static bool
+bad_sequence (const function<void(serializer& s)>& 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