aboutsummaryrefslogtreecommitdiff
path: root/tests/cxx/serializer/validation/built-in/qname/driver.cxx
blob: f8e70cfd288e8ff13ea2a7254fc87162e5743844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// file      : tests/cxx/serializer/validation/built-in/qname/driver.cxx
// copyright : Copyright (c) 2006-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

// Test the built-in QName type validation.
//
#include <cassert>

#include <xsde/config.h>

// Let the runtime header sort out which version (stl/no-stl) to
// include.
//
#include <xsde/cxx/serializer/validating/xml-schema-simpl.hxx>

using namespace xsde::cxx;
using namespace xsde::cxx::serializer;
using namespace xsde::cxx::serializer::validating;

int
main ()
{
  {
    qname_simpl s;
    context c (0);
#ifdef XSDE_STL
    s.pre (qname ("a b"));
#else
    qname qn;
    qn.name_copy ("a b");
    s.pre (&qn);
#endif
    s._pre_impl (c);
    s._serialize_content ();
    assert (c.schema_error () == schema_error::invalid_qname_value);
  }

  {
    qname_simpl s;
    context c (0);
#ifdef XSDE_STL
    s.pre (qname ("ab", "a b"));
#else
    qname qn;
    qn.name_copy ("a b");
    qn.prefix_copy ("ab");
    s.pre (&qn);
#endif
    s._pre_impl (c);
    s._serialize_content ();
    assert (c.schema_error () == schema_error::invalid_qname_value);
  }

  {
    qname_simpl s;
    context c (0);
#ifdef XSDE_STL
    s.pre (qname ("a b", "ab"));
#else
    qname qn;
    qn.name_copy ("ab");
    qn.prefix_copy ("a b");
    s.pre (&qn);
#endif
    s._pre_impl (c);
    s._serialize_content ();
    assert (c.schema_error () == schema_error::invalid_qname_value);
  }

  return 0;
}