Flip Unit Testing Language Guide

Using Utml

This chapter describes the use of the Utml class.

Overview

The following describes the Utml static methods.

static void       write (DataConsumerBase & consumer, const BackEndIR & backend);
static BackEndIR  read (DataProviderBase & provider, const DataModelBase & model);

The first method write can be used to output a generated Utml content from a back-end. It can be used to generate test cases on the fly.

It takes a data consumer on input which might represents a file or a portion of memory.

The second method read is used to read utml content and, with the help of a data model, output a back-end intermediate representation that can then be used to fill a document.

Error reporting

When parsing utml content, if the parser encounters an error, it will fire an exception of type Utml::Error.

When generating utml content, one might trace the error to provide context.

Typically, reading utml will have this general structure :

try
{
   backend = Utml::read (provider, model);
}
catch (const Utml::Error & e)
{
   e.trace ();
}

Tracing the error will output the error message and its context on the standard output. The following shows typical examples of it :

<utml>:1:15: error: Unknown member `something'
flip.Root root{something = 15}
               ^~~~~~~~~
<utml>:1:20: error: Unexpected value `fals' for Bool type
flip.Root root{bool=fals}
                    ^~~~