C++ contract check script structure

A C++ Contract Check Script (.otc script) describes assertions for a set of classes. Each C++ class can be associated to a Contract Check CLASS block. When built, the script instruments the source code under test.

The scripts, being descriptions, are made of statements only. As a consequence, the order of execution is irrelevant. There is no hierarchical structure.

The Contract Check CLASS block describes assertions for a C++ class.

Note   The evaluation of the contract should not have any side effects. The contract evaluation does not alter the state of the corresponding system. For more specific information refer to REQUIRE, ENSURE, INVARIANT and STATE sections.

Basic structure

A typical Component Testing .otc contract check script structure looks like this:

CLASS VCR {

       STATE Empty {

             (media_present() == false)

}

       STATE Loaded {

             (media_present() == true)

             (mode () == m_stop;)

       }

       STATE Playing {

             (media_present() == true)

             (mode() == m_play || mode() == m_pause)

       }

 

       TRANSITION Empty TO Loaded;

       TRANSITION Loaded TO Playing;

       TRANSITION Playing TO Loaded;

       TRANSITION Playing TO Empty;

       TRANSITION Loaded TO Empty;

}

 

All instructions in a test script have the following characteristics:

Related Topics

C++ contract check script (.otc)C++ test script keywords