diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-17 07:15:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-09-17 07:15:29 +0200 |
commit | f0510d2f90467de8e8f260b47d79a9baaf9bef17 (patch) | |
tree | 0b9929946f06a9cbe9b9e8f2a7600dae4e048f79 /tests/cxx/tree/enumeration/ctor |
Start tracking XSD with git
Diffstat (limited to 'tests/cxx/tree/enumeration/ctor')
-rw-r--r-- | tests/cxx/tree/enumeration/ctor/driver.cxx | 32 | ||||
-rw-r--r-- | tests/cxx/tree/enumeration/ctor/makefile | 82 | ||||
-rw-r--r-- | tests/cxx/tree/enumeration/ctor/test.xsd | 41 |
3 files changed, 155 insertions, 0 deletions
diff --git a/tests/cxx/tree/enumeration/ctor/driver.cxx b/tests/cxx/tree/enumeration/ctor/driver.cxx new file mode 100644 index 0000000..238d446 --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/driver.cxx @@ -0,0 +1,32 @@ +// file : tests/cxx/tree/enumeration/ctor/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test enumeration constructors. +// +#include <string> + +#include "test.hxx" + +using namespace std; +using namespace test; + +int +main () +{ + // Test ctor(const char*). + // + { + string_enum se ("a"); + type t ("a", 1); + } + + // Test ctor(const std::string&) + // + { + string const s ("c"); + string_enum se (s); + type t (s, 3); + } +} diff --git a/tests/cxx/tree/enumeration/ctor/makefile b/tests/cxx/tree/enumeration/ctor/makefile new file mode 100644 index 0000000..3ea7b8e --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/makefile @@ -0,0 +1,82 @@ +# file : tests/cxx/tree/enumeration/ctor/makefile +# author : Boris Kolpackov <boris@codesynthesis.com> +# copyright : Copyright (c) 2006-2009 Code Synthesis Tools CC +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../../../build/bootstrap.make + +xsd := test.xsd +cxx := driver.cxx + +obj := $(addprefix $(out_base)/,$(cxx:.cxx=.o) $(xsd:.xsd=.o)) +dep := $(obj:.o=.o.d) + +driver := $(out_base)/driver +test := $(out_base)/.test +clean := $(out_base)/.clean + + +# Import. +# +$(call import,\ + $(scf_root)/import/libxerces-c/stub.make,\ + l: xerces_c.l,cpp-options: xerces_c.l.cpp-options) + + +# Build. +# +$(driver): $(obj) $(xerces_c.l) + +$(obj) $(dep): cpp_options := -I$(src_root)/libxsd +$(obj) $(dep): $(xerces_c.l.cpp-options) + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd := $(out_root)/xsd/xsd + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): xsd_options := --generate-default-ctor \ +--generate-from-base-ctor --generate-doxygen + +$(out_base)/$(xsd:.xsd=.hxx) \ +$(out_base)/$(xsd:.xsd=.ixx) \ +$(out_base)/$(xsd:.xsd=.cxx): $(out_root)/xsd/xsd + +$(call include-dep,$(dep)) + +# Convenience alias for default target. +# +.PHONY: $(out_base)/ +$(out_base)/: $(driver) + + +# Test. +# +.PHONY: $(test) + +$(test): driver := $(driver) +$(test): $(driver) + $(call message,test $$1,$$1,$(driver)) + +# Clean. +# +.PHONY: $(clean) + +$(clean): $(driver).o.clean \ + $(addsuffix .cxx.clean,$(obj)) \ + $(addsuffix .cxx.clean,$(dep)) \ + $(addprefix $(out_base)/,$(xsd:.xsd=.cxx.xsd.clean)) + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(scf_root)/xsd/tree/xsd-cxx.make) + + +# Dependencies. +# +$(call import,$(src_root)/xsd/makefile) diff --git a/tests/cxx/tree/enumeration/ctor/test.xsd b/tests/cxx/tree/enumeration/ctor/test.xsd new file mode 100644 index 0000000..c5d625a --- /dev/null +++ b/tests/cxx/tree/enumeration/ctor/test.xsd @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test" targetNamespace="test"> + + <simpleType name="string-enum-base"> + <restriction base="string"> + <enumeration value="a"/> + <enumeration value="b"/> + <enumeration value="c"/> + </restriction> + </simpleType> + + <simpleType name="string-enum"> + <restriction base="t:string-enum-base"> + <enumeration value="a"/> + <enumeration value="c"/> + </restriction> + </simpleType> + + <simpleType name="int-enum-base"> + <restriction base="int"> + <enumeration value="1"/> + <enumeration value="2"/> + <enumeration value="3"/> + </restriction> + </simpleType> + + <simpleType name="int-enum"> + <restriction base="t:int-enum-base"> + <enumeration value="1"/> + <enumeration value="3"/> + </restriction> + </simpleType> + + <complexType name="type"> + <sequence> + <element name="a" type="t:string-enum"/> + <element name="b" type="t:int-enum"/> + </sequence> + </complexType> + +</schema> |