aboutsummaryrefslogtreecommitdiff
path: root/tests/web/xhtml/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/web/xhtml/driver.cxx')
-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