Flip Unit Testing Language Guide

Utml Overview

This chapter gives a quick overview of Flip Utml (Unit Testing Markup Language) and practical examples.

What is Utml ?

Utml is a simple and compact markup language that can easily produce documents given an utml document and a data model. Since it is very compact, it can be used to generate unit testing easily.

Note: Utml is not a backend format, it shall not be used in production.

Example of Utml

Let's consider the following Flip data model declaration :

class Note : public Object
   Float position;
   Float duration;
using Notes = Collection <Note>;
class Track : public Object
   String name;
   Notes  notes;
using Tracks = Array <Track>;
class Song : public Object
   Bool   playing;
   Tracks tracks;

Utml can be used to generate quickly a full song. The following exposes an example of a song with one track named "Bass" which contains two notes and is also in a playing state.

Song {
   tracks = {
      Track {
         name = "Bass"
         notes = {
            Note { duration = 2 }
            Note { position = 1.5 duration = 2.3 }
   playing = true

In the previous example, because the Note position is not defined it is assumed to be 0.

Members can also be defined in whatever order, they don't need to follow the C++ model declaration.

The client can then make a Flip document out of this utml source.

#include "flip/contrib/Utml.h"
std::string utml_source = [utml source above];
std::vector <uint8_t> data (utml_source.begin (), utml_source.end ());
DataProviderMemory provider (data);
BackEndIR backend = Utml::read (provider, Model::use ());
document.read (backend);