Generated Test Functions
The -genTest option causes test functions to be generated. These functions can be used to populate variables of generated types with random test data or data from an existing XML instance. They have two main purposes:
The second item is quite useful to users because generated data types can become very complex as the schemas become more complex. It is sometimes difficult to figure out how to navigate all of the lists and pointers. Using -genTest can provide code that may be modified to accomplish the population of a data variable with any type of data.
where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd and -test is specified, test functions will be written to xTest.c. If the file being processed is a WSDL file, the suffix would be WSDLTest.c (for example, x.wsdl would produce xWSDLTest.c).
where <elemName> is the name of the XSD global element for which the function is being generated and <ns> is an optional namespace setting that can be used to disambiguate names from multiple sources (note: this should not be confused with XML namespaces which are different). Note that test routines are generated only for global elements within a specification.
<typeName>* pvalue = <testFunc> (OSCTXT* pctxt)The pctxt argument is used to hold a context pointer to keep track of dynamic memory allocation parameters. This is a basic "handle" variable that is used to make the function reentrant so that it can be used in an asynchronous or threaded application. The user is required to supply a pointer to a variable of this type declared somewhere in his or her program. The variable must be initialized using either the rtxInitContext or rtXmlInitContext run-time function before use.
The pvalue argument is a pointer to hold the populated data variable. This variable is of the type generated for the XSD type of the global element. The test function will automatically allocate dynamic memory using the run-time memory management for the main variable as well as variable length fields within the structure. This memory is tracked within the context structure and is released when the context structure is freed.
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |